glibc-2.19.patch 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052
  1. diff --git a/Makeconfig b/Makeconfig
  2. index 1908f27..cf34ba1 100644
  3. --- a/Makeconfig
  4. +++ b/Makeconfig
  5. @@ -775,7 +775,8 @@ endif # $(+cflags) == ""
  6. # current directory.
  7. +includes = -I$(..)include $(if $(subdir),$(objpfx:%/=-I%)) \
  8. $(+sysdep-includes) $(includes) \
  9. - $(patsubst %/,-I%,$(..)) $(libio-include) -I. $(sysincludes)
  10. + $(patsubst %/,-I%,$(..)) $(libio-include) -I. $(sysincludes) \
  11. + -I$(common-objpfx)../shim/include
  12. # Since libio has several internal header files, we use a -I instead
  13. # of many little headers in the include directory.
  14. @@ -1033,7 +1034,7 @@ all-subdirs = csu assert ctype locale intl catgets math setjmp signal \
  15. grp pwd posix io termios resource misc socket sysvipc gmon \
  16. gnulib iconv iconvdata wctype manual shadow gshadow po argp \
  17. crypt localedata timezone rt conform debug \
  18. - $(add-on-subdirs) dlfcn elf
  19. + $(add-on-subdirs) dlfcn elf libos
  20. ifndef avoid-generated
  21. # sysd-sorted itself will contain rules making the sysd-sorted target
  22. diff --git a/Makefile b/Makefile
  23. index 51d4690..d72c4b0 100644
  24. --- a/Makefile
  25. +++ b/Makefile
  26. @@ -177,6 +177,8 @@ $(inst_includedir)/gnu/stubs.h: $(+force)
  27. install-others-nosubdir: $(installed-stubs)
  28. endif
  29. +# For Graphene
  30. +CFLAGS-syscalldb.c = -fPIC
  31. # Since stubs.h is never needed when building the library, we simplify the
  32. # hairy installation process by producing it in place only as the last part
  33. diff --git a/Versions.def b/Versions.def
  34. index 759c754..e1a270e 100644
  35. --- a/Versions.def
  36. +++ b/Versions.def
  37. @@ -41,6 +41,7 @@ libc {
  38. GCC_3.0
  39. %endif
  40. GLIBC_PRIVATE
  41. + SHIM
  42. }
  43. libcrypt {
  44. GLIBC_2.0
  45. @@ -50,6 +51,7 @@ libdl {
  46. GLIBC_2.1
  47. GLIBC_2.3.3
  48. GLIBC_2.3.4
  49. + SHIM
  50. }
  51. libm {
  52. GLIBC_2.0
  53. @@ -108,6 +110,7 @@ libpthread {
  54. GLIBC_2.18
  55. GLIBC_2.19
  56. GLIBC_PRIVATE
  57. + SHIM
  58. }
  59. libresolv {
  60. GLIBC_2.0
  61. @@ -135,6 +138,7 @@ ld {
  62. GLIBC_2.3
  63. GLIBC_2.4
  64. GLIBC_PRIVATE
  65. + SHIM
  66. }
  67. libthread_db {
  68. GLIBC_2.1.3
  69. @@ -148,3 +152,6 @@ libanl {
  70. libcidn {
  71. GLIBC_PRIVATE
  72. }
  73. +liblibos {
  74. + GLIBC_2.12
  75. +}
  76. diff --git a/configure b/configure
  77. index fc023d0..b71c1f9 100755
  78. --- a/configure
  79. +++ b/configure
  80. @@ -630,7 +630,8 @@ SED
  81. MAKEINFO
  82. MSGFMT
  83. MAKE
  84. -LD
  85. +LD_GOLD
  86. +LD_BFD
  87. AS
  88. OBJCOPY
  89. OBJDUMP
  90. @@ -4593,17 +4594,22 @@ if test $ac_verc_fail = yes; then
  91. AS=: critic_missing="$critic_missing as"
  92. fi
  93. -for ac_prog in $LD
  94. +LD_BFD=
  95. +LD_GOLD=
  96. +ld_is_gold="`$LD --version | sed -n 's/^GNU \(gold\).*$/\1/p'`"
  97. +if test -z "$ld_is_gold"; then
  98. + LD_BFD=$LD
  99. + for ac_prog in $LD_BFD
  100. do
  101. # Extract the first word of "$ac_prog", so it can be a program name with args.
  102. set dummy $ac_prog; ac_word=$2
  103. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
  104. $as_echo_n "checking for $ac_word... " >&6; }
  105. -if ${ac_cv_prog_LD+:} false; then :
  106. +if ${ac_cv_prog_LD_BFD+:} false; then :
  107. $as_echo_n "(cached) " >&6
  108. else
  109. - if test -n "$LD"; then
  110. - ac_cv_prog_LD="$LD" # Let the user override the test.
  111. + if test -n "$LD_BFD"; then
  112. + ac_cv_prog_LD_BFD="$LD_BFD" # Let the user override the test.
  113. else
  114. as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
  115. for as_dir in $PATH
  116. @@ -4612,7 +4618,7 @@ do
  117. test -z "$as_dir" && as_dir=.
  118. for ac_exec_ext in '' $ac_executable_extensions; do
  119. if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
  120. - ac_cv_prog_LD="$ac_prog"
  121. + ac_cv_prog_LD_BFD="$ac_prog"
  122. $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
  123. break 2
  124. fi
  125. @@ -4622,26 +4628,26 @@ IFS=$as_save_IFS
  126. fi
  127. fi
  128. -LD=$ac_cv_prog_LD
  129. -if test -n "$LD"; then
  130. - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
  131. -$as_echo "$LD" >&6; }
  132. +LD_BFD=$ac_cv_prog_LD_BFD
  133. +if test -n "$LD_BFD"; then
  134. + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD_BFD" >&5
  135. +$as_echo "$LD_BFD" >&6; }
  136. else
  137. { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
  138. $as_echo "no" >&6; }
  139. fi
  140. - test -n "$LD" && break
  141. + test -n "$LD_BFD" && break
  142. done
  143. -if test -z "$LD"; then
  144. +if test -z "$LD_BFD"; then
  145. ac_verc_fail=yes
  146. else
  147. # Found it, now check the version.
  148. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking version of $LD" >&5
  149. -$as_echo_n "checking version of $LD... " >&6; }
  150. - ac_prog_version=`$LD --version 2>&1 | sed -n 's/^.*GNU ld.* \([0-9][0-9]*\.[0-9.]*\).*$/\1/p'`
  151. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking version of $LD_BFD" >&5
  152. +$as_echo_n "checking version of $LD_BFD... " >&6; }
  153. + ac_prog_version=`$LD_BFD --version 2>&1 | sed -n 's/^.*GNU ld.* \([0-9][0-9]*\.[0-9.]*\).*$/\1/p'`
  154. case $ac_prog_version in
  155. '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
  156. 2.1[0-9][0-9]*|2.[2-9][0-9]*|[3-9].*|[1-9][0-9]*)
  157. @@ -4653,9 +4659,80 @@ $as_echo_n "checking version of $LD... " >&6; }
  158. $as_echo "$ac_prog_version" >&6; }
  159. fi
  160. if test $ac_verc_fail = yes; then
  161. - LD=: critic_missing="$critic_missing ld"
  162. + LD_BFD=:
  163. fi
  164. +else
  165. +# Accept gold 1.11 or higher.
  166. + LD_GOLD=$LD
  167. + for ac_prog in $LD_GOLD
  168. +do
  169. + # Extract the first word of "$ac_prog", so it can be a program name with args.
  170. +set dummy $ac_prog; ac_word=$2
  171. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
  172. +$as_echo_n "checking for $ac_word... " >&6; }
  173. +if ${ac_cv_prog_LD_GOLD+:} false; then :
  174. + $as_echo_n "(cached) " >&6
  175. +else
  176. + if test -n "$LD_GOLD"; then
  177. + ac_cv_prog_LD_GOLD="$LD_GOLD" # Let the user override the test.
  178. +else
  179. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
  180. +for as_dir in $PATH
  181. +do
  182. + IFS=$as_save_IFS
  183. + test -z "$as_dir" && as_dir=.
  184. + for ac_exec_ext in '' $ac_executable_extensions; do
  185. + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
  186. + ac_cv_prog_LD_GOLD="$ac_prog"
  187. + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
  188. + break 2
  189. + fi
  190. +done
  191. + done
  192. +IFS=$as_save_IFS
  193. +
  194. +fi
  195. +fi
  196. +LD_GOLD=$ac_cv_prog_LD_GOLD
  197. +if test -n "$LD_GOLD"; then
  198. + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD_GOLD" >&5
  199. +$as_echo "$LD_GOLD" >&6; }
  200. +else
  201. + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
  202. +$as_echo "no" >&6; }
  203. +fi
  204. +
  205. +
  206. + test -n "$LD_GOLD" && break
  207. +done
  208. +
  209. +if test -z "$LD_GOLD"; then
  210. + ac_verc_fail=yes
  211. +else
  212. + # Found it, now check the version.
  213. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking version of $LD_GOLD" >&5
  214. +$as_echo_n "checking version of $LD_GOLD... " >&6; }
  215. + ac_prog_version=`$LD_GOLD --version 2>&1 | sed -n 's/^.*GNU gold.* \([0-9][0-9]*\.[0-9.]*\).*$/\1/p'`
  216. + case $ac_prog_version in
  217. + '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
  218. + 1.1[1-9]*|1.[2-9][0-9]*|1.1[0-9][0-9]*|[2-9].*|[1-9][0-9]*)
  219. + ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
  220. + *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
  221. +
  222. + esac
  223. + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_prog_version" >&5
  224. +$as_echo "$ac_prog_version" >&6; }
  225. +fi
  226. +if test $ac_verc_fail = yes; then
  227. + LD_GOLD=:
  228. +fi
  229. +
  230. +fi
  231. +# Neither ld nor gold are new enough.
  232. +if test -z "$LD_BFD" && test -z "$LD_GOLD"; then
  233. + critic_missing="$critic_missing ld"
  234. +fi
  235. # These programs are version sensitive.
  236. @@ -6391,6 +6468,16 @@ $as_echo "$libc_cv_use_default_link" >&6; }
  237. use_default_link=$libc_cv_use_default_link
  238. fi
  239. +# The gold linker has no builtin default linker script,
  240. +# and the fallback of editing the builtin linker
  241. +# script is not available. Therefore if use_default_link
  242. +# is `no' then we can't use gold. This check is independent
  243. +# of gold's version and is used to sanity check that the
  244. +# linker continues to produce a useful shared link.
  245. +if test "$ld_is_gold" && test "$use_default_link" = "no"; then
  246. + as_fn_error $? "$LD did not generate a useful shared link. Try using GNU ld.bfd?" "$LINENO" 5
  247. +fi
  248. +
  249. { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker output format" >&5
  250. $as_echo_n "checking linker output format... " >&6; }
  251. if ${libc_cv_output_format+:} false; then :
  252. @@ -6409,6 +6496,17 @@ fi
  253. $as_echo "$libc_cv_output_format" >&6; }
  254. +# The gold linker has no builtin default linker script,
  255. +# and the fallback of parsing the builtin linker
  256. +# script to determine the target is not available.
  257. +# Therefore if libc_cv_output_format is `unknown' then
  258. +# we can't use gold. This check is independent of gold's
  259. +# version and is used to sanity check that the linker
  260. +# continues to support --print-output-format.
  261. +if test "$ld_is_gold" && test "$libc_cv_output_format" = "unknown"; then
  262. + as_fn_error $? "$LD did not support --print-output-format. Try using GNU ld.bfd?" "$LINENO" 5
  263. +fi
  264. +
  265. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -fno-toplevel-reorder -fno-section-anchors" >&5
  266. $as_echo_n "checking for -fno-toplevel-reorder -fno-section-anchors... " >&6; }
  267. if ${libc_cv_fno_toplevel_reorder+:} false; then :
  268. diff --git a/dlfcn/Versions b/dlfcn/Versions
  269. index 97902f0..c1874c1 100644
  270. --- a/dlfcn/Versions
  271. +++ b/dlfcn/Versions
  272. @@ -14,4 +14,7 @@ libdl {
  273. GLIBC_PRIVATE {
  274. _dlfcn_hook;
  275. }
  276. + SHIM {
  277. + syscalldb;
  278. + }
  279. }
  280. diff --git a/elf/Makefile b/elf/Makefile
  281. index 4c58fc9..0ae2fa8 100644
  282. --- a/elf/Makefile
  283. +++ b/elf/Makefile
  284. @@ -21,7 +21,7 @@ subdir := elf
  285. include ../Makeconfig
  286. -headers = elf.h bits/elfclass.h link.h bits/link.h
  287. +headers = elf.h bits/elfclass.h link.h bits/link.h syscalldb.h
  288. routines = $(dl-routines) dl-support dl-iteratephdr \
  289. dl-addr enbl-secure dl-profstub \
  290. dl-origin dl-libc dl-sym dl-tsd dl-sysdep
  291. @@ -31,7 +31,8 @@ routines = $(dl-routines) dl-support dl-iteratephdr \
  292. dl-routines = $(addprefix dl-,load lookup object reloc deps hwcaps \
  293. runtime error init fini debug misc \
  294. version profile conflict tls origin scope \
  295. - execstack caller open close trampoline)
  296. + execstack caller open close trampoline) \
  297. + syscalldb syscallas
  298. ifeq (yes,$(use-ldconfig))
  299. dl-routines += dl-cache
  300. endif
  301. diff --git a/elf/Versions b/elf/Versions
  302. index 2383992..98687f6 100644
  303. --- a/elf/Versions
  304. +++ b/elf/Versions
  305. @@ -24,14 +24,15 @@ libc {
  306. _dl_sym; _dl_vsym;
  307. __libc_dlclose; __libc_dlopen_mode; __libc_dlsym;
  308. }
  309. + SHIM {
  310. + syscalldb; glibc_option;
  311. + }
  312. }
  313. ld {
  314. GLIBC_2.0 {
  315. # Function from libc.so which must be shared with libc.
  316. __libc_memalign; calloc; free; malloc; realloc;
  317. -
  318. - _r_debug;
  319. }
  320. GLIBC_2.1 {
  321. # functions used in other libraries
  322. @@ -57,9 +58,12 @@ ld {
  323. _rtld_global; _rtld_global_ro;
  324. # Only here for gdb while a better method is developed.
  325. - _dl_debug_state;
  326. + __libc_r_debug; __libc_dl_debug_state;
  327. # Pointer protection.
  328. __pointer_chk_guard;
  329. }
  330. + SHIM {
  331. + syscalldb; glibc_version; glibc_option; register_library;
  332. + }
  333. }
  334. diff --git a/elf/circleload1.c b/elf/circleload1.c
  335. index 990ff84..ccf92d3 100644
  336. --- a/elf/circleload1.c
  337. +++ b/elf/circleload1.c
  338. @@ -5,7 +5,7 @@
  339. #include <stdlib.h>
  340. #include <string.h>
  341. -#define MAPS ((struct link_map *) _r_debug.r_map)
  342. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  343. static int
  344. check_loaded_objects (const char **loaded)
  345. diff --git a/elf/dl-close.c b/elf/dl-close.c
  346. index 5bf1de7..a887133 100644
  347. --- a/elf/dl-close.c
  348. +++ b/elf/dl-close.c
  349. @@ -473,7 +473,7 @@ _dl_close_worker (struct link_map *map)
  350. /* Notify the debugger we are about to remove some loaded objects. */
  351. struct r_debug *r = _dl_debug_initialize (0, nsid);
  352. r->r_state = RT_DELETE;
  353. - _dl_debug_state ();
  354. + __libc_dl_debug_state ();
  355. LIBC_PROBE (unmap_start, 2, nsid, r);
  356. if (unload_global)
  357. @@ -739,7 +739,7 @@ _dl_close_worker (struct link_map *map)
  358. /* Notify the debugger those objects are finalized and gone. */
  359. r->r_state = RT_CONSISTENT;
  360. - _dl_debug_state ();
  361. + __libc_dl_debug_state ();
  362. LIBC_PROBE (unmap_complete, 2, nsid, r);
  363. /* Recheck if we need to retry, release the lock. */
  364. diff --git a/elf/dl-debug.c b/elf/dl-debug.c
  365. index 4e7c593..3e0bff4 100644
  366. --- a/elf/dl-debug.c
  367. +++ b/elf/dl-debug.c
  368. @@ -34,7 +34,7 @@ extern const int verify_link_map_members[(VERIFY_MEMBER (l_addr)
  369. normally finds it via the DT_DEBUG entry in the dynamic section, but in
  370. a statically-linked program there is no dynamic section for the debugger
  371. to examine and it looks for this particular symbol name. */
  372. -struct r_debug _r_debug;
  373. +struct r_debug __libc_r_debug __attribute__((weak));
  374. /* Initialize _r_debug if it has not already been done. The argument is
  375. @@ -48,7 +48,7 @@ _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns)
  376. struct r_debug *r;
  377. if (ns == LM_ID_BASE)
  378. - r = &_r_debug;
  379. + r = &__libc_r_debug;
  380. else
  381. r = &GL(dl_ns)[ns]._ns_debug;
  382. @@ -56,9 +56,9 @@ _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns)
  383. {
  384. /* Tell the debugger where to find the map of loaded objects. */
  385. r->r_version = 1 /* R_DEBUG_VERSION XXX */;
  386. - r->r_ldbase = ldbase ?: _r_debug.r_ldbase;
  387. + r->r_ldbase = ldbase ?: __libc_r_debug.r_ldbase;
  388. r->r_map = (void *) GL(dl_ns)[ns]._ns_loaded;
  389. - r->r_brk = (ElfW(Addr)) &_dl_debug_state;
  390. + r->r_brk = (ElfW(Addr)) &__libc_dl_debug_state;
  391. }
  392. return r;
  393. @@ -70,7 +70,7 @@ _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns)
  394. examining the r_brk member of struct r_debug, but GDB 4.15 in fact looks
  395. for this particular symbol name in the PT_INTERP file. */
  396. void
  397. -_dl_debug_state (void)
  398. +__libc_dl_debug_state (void)
  399. {
  400. }
  401. -rtld_hidden_def (_dl_debug_state)
  402. +__attribute__((weak));
  403. diff --git a/elf/dl-load.c b/elf/dl-load.c
  404. index 1be7a3c..c560ec1 100644
  405. --- a/elf/dl-load.c
  406. +++ b/elf/dl-load.c
  407. @@ -39,6 +39,8 @@
  408. #include <dl-dst.h>
  409. +#include <glibc-version.h>
  410. +
  411. /* On some systems, no flag bits are given to specify file mapping. */
  412. #ifndef MAP_FILE
  413. # define MAP_FILE 0
  414. @@ -902,7 +904,7 @@ lose (int code, int fd, const char *name, char *realname, struct link_map *l,
  415. if (r != NULL)
  416. {
  417. r->r_state = RT_CONSISTENT;
  418. - _dl_debug_state ();
  419. + __libc_dl_debug_state ();
  420. LIBC_PROBE (map_failed, 2, nsid, r);
  421. }
  422. @@ -1048,7 +1050,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
  423. call _dl_debug_initialize in a static program in case dynamic
  424. linking has not been used before. */
  425. r->r_state = RT_ADD;
  426. - _dl_debug_state ();
  427. + __libc_dl_debug_state ();
  428. LIBC_PROBE (map_start, 2, nsid, r);
  429. make_consistent = true;
  430. }
  431. @@ -1595,6 +1597,9 @@ cannot enable executable stack as shared object requires");
  432. DL_AFTER_LOAD (l);
  433. #endif
  434. + /* register the library to SHIM */
  435. + register_library(l->l_name, l->l_addr);
  436. +
  437. /* Now that the object is fully initialized add it to the object list. */
  438. _dl_add_to_namespace_list (l, nsid);
  439. diff --git a/elf/dl-open.c b/elf/dl-open.c
  440. index a9ca6b3..829d212 100644
  441. --- a/elf/dl-open.c
  442. +++ b/elf/dl-open.c
  443. @@ -290,7 +290,7 @@ dl_open_worker (void *a)
  444. /* Notify the debugger all new objects are now ready to go. */
  445. struct r_debug *r = _dl_debug_initialize (0, args->nsid);
  446. r->r_state = RT_CONSISTENT;
  447. - _dl_debug_state ();
  448. + __libc_dl_debug_state ();
  449. LIBC_PROBE (map_complete, 3, args->nsid, r, new);
  450. /* Print scope information. */
  451. diff --git a/elf/link.h b/elf/link.h
  452. index d5905d1..f4e108a 100644
  453. --- a/elf/link.h
  454. +++ b/elf/link.h
  455. @@ -64,7 +64,7 @@ struct r_debug
  456. };
  457. /* This is the instance of that structure used by the dynamic linker. */
  458. -extern struct r_debug _r_debug;
  459. +extern struct r_debug __libc_r_debug;
  460. /* This symbol refers to the "dynamic structure" in the `.dynamic' section
  461. of whatever module refers to `_DYNAMIC'. So, to find its own
  462. diff --git a/elf/loadtest.c b/elf/loadtest.c
  463. index 727469b..568ddef 100644
  464. --- a/elf/loadtest.c
  465. +++ b/elf/loadtest.c
  466. @@ -70,7 +70,7 @@ static const struct
  467. #include <include/link.h>
  468. -#define MAPS ((struct link_map *) _r_debug.r_map)
  469. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  470. #define OUT \
  471. for (map = MAPS; map != NULL; map = map->l_next) \
  472. diff --git a/elf/neededtest.c b/elf/neededtest.c
  473. index 3cea499..e098d48 100644
  474. --- a/elf/neededtest.c
  475. +++ b/elf/neededtest.c
  476. @@ -5,7 +5,7 @@
  477. #include <stdlib.h>
  478. #include <string.h>
  479. -#define MAPS ((struct link_map *) _r_debug.r_map)
  480. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  481. static int
  482. check_loaded_objects (const char **loaded)
  483. diff --git a/elf/neededtest2.c b/elf/neededtest2.c
  484. index 17c75f2..5a73a95 100644
  485. --- a/elf/neededtest2.c
  486. +++ b/elf/neededtest2.c
  487. @@ -5,7 +5,7 @@
  488. #include <stdlib.h>
  489. #include <string.h>
  490. -#define MAPS ((struct link_map *) _r_debug.r_map)
  491. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  492. static int
  493. check_loaded_objects (const char **loaded)
  494. diff --git a/elf/neededtest3.c b/elf/neededtest3.c
  495. index 41970cf..5126615 100644
  496. --- a/elf/neededtest3.c
  497. +++ b/elf/neededtest3.c
  498. @@ -5,7 +5,7 @@
  499. #include <stdlib.h>
  500. #include <string.h>
  501. -#define MAPS ((struct link_map *) _r_debug.r_map)
  502. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  503. static int
  504. check_loaded_objects (const char **loaded)
  505. diff --git a/elf/neededtest4.c b/elf/neededtest4.c
  506. index 0ae0b7f..f883910 100644
  507. --- a/elf/neededtest4.c
  508. +++ b/elf/neededtest4.c
  509. @@ -5,7 +5,7 @@
  510. #include <stdlib.h>
  511. #include <string.h>
  512. -#define MAPS ((struct link_map *) _r_debug.r_map)
  513. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  514. static int
  515. check_loaded_objects (const char **loaded)
  516. diff --git a/elf/rtld.c b/elf/rtld.c
  517. index 6dcbabc..c87c773 100644
  518. --- a/elf/rtld.c
  519. +++ b/elf/rtld.c
  520. @@ -356,6 +356,23 @@ _dl_start_final (void *arg, struct dl_start_final_info *info)
  521. return start_addr;
  522. }
  523. +/* For graphene, check if glibc version match to the compatible SHIM
  524. + library. If not, tell the user to update glibc. */
  525. +#include "glibc-version.h"
  526. +
  527. +volatile const int glibc_version __attribute__((weak)) = GLIBC_VERSION;
  528. +
  529. +static void __attribute__((noinline,optimize("-O0")))
  530. +check_glibc_version (void)
  531. +{
  532. + if (glibc_version != GLIBC_VERSION)
  533. + {
  534. + _dl_fatal_printf ("Warning from Graphene: "
  535. + "Glibc version is incorrect. Please rebuild Glibc.\n");
  536. + _exit (1);
  537. + }
  538. +}
  539. +
  540. static ElfW(Addr) __attribute_used__ internal_function
  541. _dl_start (void *arg)
  542. {
  543. @@ -546,6 +563,9 @@ _dl_start (void *arg)
  544. therefore need not test whether we have to allocate the array
  545. for the relocation results (as done in dl-reloc.c). */
  546. + /* For Graphene, check if the glibc version is correct. */
  547. + check_glibc_version();
  548. +
  549. /* Now life is sane; we can call functions and access global data.
  550. Set up to use the operating system facilities, and find out from
  551. the operating system's program loader where to find the program
  552. @@ -1233,9 +1253,20 @@ of this helper program; chances are you did not intend to run this program.\n\
  553. main_map->l_map_end = allocend;
  554. if ((ph->p_flags & PF_X) && allocend > main_map->l_text_end)
  555. main_map->l_text_end = allocend;
  556. +
  557. +#if 0
  558. + ElfW(Addr) mapend = (allocend + GLRO(dl_pagesize) - 1)
  559. + & ~(GLRO(dl_pagesize) - 1);
  560. + int prot = ((ph->p_flags & PF_R) ? PROT_READ : 0)|
  561. + ((ph->p_flags & PF_W) ? PROT_WRITE : 0)|
  562. + ((ph->p_flags & PF_X) ? PROT_EXEC : 0);
  563. + __mmap ((void *) mapstart, mapend - mapstart,
  564. + prot,
  565. + MAP_ANON|MAP_PRIVATE|MAP_FIXED|0x20000000,
  566. + -1, 0);
  567. +#endif
  568. }
  569. break;
  570. -
  571. case PT_TLS:
  572. if (ph->p_memsz > 0)
  573. {
  574. @@ -1381,13 +1412,31 @@ of this helper program; chances are you did not intend to run this program.\n\
  575. /* PT_GNU_RELRO is usually the last phdr. */
  576. size_t cnt = rtld_ehdr->e_phnum;
  577. while (cnt-- > 0)
  578. + {
  579. if (rtld_phdr[cnt].p_type == PT_GNU_RELRO)
  580. {
  581. GL(dl_rtld_map).l_relro_addr = rtld_phdr[cnt].p_vaddr;
  582. GL(dl_rtld_map).l_relro_size = rtld_phdr[cnt].p_memsz;
  583. - break;
  584. }
  585. +#if 0
  586. + if (rtld_phdr[cnt].p_type == PT_LOAD)
  587. + {
  588. + ElfW(Addr) mapstart = rtld_phdr[cnt].p_vaddr & ~(GLRO(dl_pagesize) - 1);
  589. + ElfW(Addr) mapend = (rtld_phdr[cnt].p_vaddr + rtld_phdr[cnt].p_memsz
  590. + + GLRO(dl_pagesize) - 1)
  591. + & ~(GLRO(dl_pagesize) - 1);
  592. + int prot = ((rtld_phdr[cnt].p_flags & PF_R) ? PROT_READ : 0)|
  593. + ((rtld_phdr[cnt].p_flags & PF_W) ? PROT_WRITE : 0)|
  594. + ((rtld_phdr[cnt].p_flags & PF_X) ? PROT_EXEC : 0);
  595. + __mmap ((void *) mapstart, mapend - mapstart,
  596. + prot,
  597. + MAP_ANON|MAP_PRIVATE|MAP_FIXED|0x20000000,
  598. + -1, 0);
  599. + }
  600. +#endif
  601. + }
  602. +
  603. /* Add the dynamic linker to the TLS list if it also uses TLS. */
  604. if (GL(dl_rtld_map).l_tls_blocksize != 0)
  605. /* Assign a module ID. Do this before loading any audit modules. */
  606. @@ -1588,7 +1637,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
  607. /* We start adding objects. */
  608. r->r_state = RT_ADD;
  609. - _dl_debug_state ();
  610. + __libc_dl_debug_state ();
  611. LIBC_PROBE (init_start, 2, LM_ID_BASE, r);
  612. /* Auditing checkpoint: we are ready to signal that the initial map
  613. @@ -1605,140 +1654,11 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
  614. }
  615. }
  616. - /* We have two ways to specify objects to preload: via environment
  617. - variable and via the file /etc/ld.so.preload. The latter can also
  618. - be used when security is enabled. */
  619. - assert (*first_preload == NULL);
  620. - struct link_map **preloads = NULL;
  621. - unsigned int npreloads = 0;
  622. -
  623. - if (__builtin_expect (preloadlist != NULL, 0))
  624. - {
  625. - /* The LD_PRELOAD environment variable gives list of libraries
  626. - separated by white space or colons that are loaded before the
  627. - executable's dependencies and prepended to the global scope
  628. - list. If the binary is running setuid all elements
  629. - containing a '/' are ignored since it is insecure. */
  630. - char *list = strdupa (preloadlist);
  631. - char *p;
  632. -
  633. - HP_TIMING_NOW (start);
  634. -
  635. - /* Prevent optimizing strsep. Speed is not important here. */
  636. - while ((p = (strsep) (&list, " :")) != NULL)
  637. - if (p[0] != '\0'
  638. - && (__builtin_expect (! INTUSE(__libc_enable_secure), 1)
  639. - || strchr (p, '/') == NULL))
  640. - npreloads += do_preload (p, main_map, "LD_PRELOAD");
  641. -
  642. - HP_TIMING_NOW (stop);
  643. - HP_TIMING_DIFF (diff, start, stop);
  644. - HP_TIMING_ACCUM_NT (load_time, diff);
  645. - }
  646. -
  647. - /* There usually is no ld.so.preload file, it should only be used
  648. - for emergencies and testing. So the open call etc should usually
  649. - fail. Using access() on a non-existing file is faster than using
  650. - open(). So we do this first. If it succeeds we do almost twice
  651. - the work but this does not matter, since it is not for production
  652. - use. */
  653. - static const char preload_file[] = "/etc/ld.so.preload";
  654. - if (__builtin_expect (__access (preload_file, R_OK) == 0, 0))
  655. - {
  656. - /* Read the contents of the file. */
  657. - file = _dl_sysdep_read_whole_file (preload_file, &file_size,
  658. - PROT_READ | PROT_WRITE);
  659. - if (__builtin_expect (file != MAP_FAILED, 0))
  660. - {
  661. - /* Parse the file. It contains names of libraries to be loaded,
  662. - separated by white spaces or `:'. It may also contain
  663. - comments introduced by `#'. */
  664. - char *problem;
  665. - char *runp;
  666. - size_t rest;
  667. -
  668. - /* Eliminate comments. */
  669. - runp = file;
  670. - rest = file_size;
  671. - while (rest > 0)
  672. - {
  673. - char *comment = memchr (runp, '#', rest);
  674. - if (comment == NULL)
  675. - break;
  676. -
  677. - rest -= comment - runp;
  678. - do
  679. - *comment = ' ';
  680. - while (--rest > 0 && *++comment != '\n');
  681. - }
  682. -
  683. - /* We have one problematic case: if we have a name at the end of
  684. - the file without a trailing terminating characters, we cannot
  685. - place the \0. Handle the case separately. */
  686. - if (file[file_size - 1] != ' ' && file[file_size - 1] != '\t'
  687. - && file[file_size - 1] != '\n' && file[file_size - 1] != ':')
  688. - {
  689. - problem = &file[file_size];
  690. - while (problem > file && problem[-1] != ' '
  691. - && problem[-1] != '\t'
  692. - && problem[-1] != '\n' && problem[-1] != ':')
  693. - --problem;
  694. -
  695. - if (problem > file)
  696. - problem[-1] = '\0';
  697. - }
  698. - else
  699. - {
  700. - problem = NULL;
  701. - file[file_size - 1] = '\0';
  702. - }
  703. -
  704. - HP_TIMING_NOW (start);
  705. -
  706. - if (file != problem)
  707. - {
  708. - char *p;
  709. - runp = file;
  710. - while ((p = strsep (&runp, ": \t\n")) != NULL)
  711. - if (p[0] != '\0')
  712. - npreloads += do_preload (p, main_map, preload_file);
  713. - }
  714. -
  715. - if (problem != NULL)
  716. - {
  717. - char *p = strndupa (problem, file_size - (problem - file));
  718. -
  719. - npreloads += do_preload (p, main_map, preload_file);
  720. - }
  721. -
  722. - HP_TIMING_NOW (stop);
  723. - HP_TIMING_DIFF (diff, start, stop);
  724. - HP_TIMING_ACCUM_NT (load_time, diff);
  725. -
  726. - /* We don't need the file anymore. */
  727. - __munmap (file, file_size);
  728. - }
  729. - }
  730. -
  731. - if (__builtin_expect (*first_preload != NULL, 0))
  732. - {
  733. - /* Set up PRELOADS with a vector of the preloaded libraries. */
  734. - struct link_map *l = *first_preload;
  735. - preloads = __alloca (npreloads * sizeof preloads[0]);
  736. - i = 0;
  737. - do
  738. - {
  739. - preloads[i++] = l;
  740. - l = l->l_next;
  741. - } while (l);
  742. - assert (i == npreloads);
  743. - }
  744. -
  745. /* Load all the libraries specified by DT_NEEDED entries. If LD_PRELOAD
  746. specified some libraries to load, these are inserted before the actual
  747. dependencies in the executable's searchlist for symbol resolution. */
  748. HP_TIMING_NOW (start);
  749. - _dl_map_object_deps (main_map, preloads, npreloads, mode == trace, 0);
  750. + _dl_map_object_deps (main_map, NULL, 0, mode == trace, 0);
  751. HP_TIMING_NOW (stop);
  752. HP_TIMING_DIFF (diff, start, stop);
  753. HP_TIMING_ACCUM_NT (load_time, diff);
  754. @@ -2301,7 +2221,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
  755. the address since by now the variable might be in another object. */
  756. r = _dl_debug_initialize (0, LM_ID_BASE);
  757. r->r_state = RT_CONSISTENT;
  758. - _dl_debug_state ();
  759. + __libc_dl_debug_state ();
  760. LIBC_PROBE (init_complete, 2, LM_ID_BASE, r);
  761. #if defined USE_LDCONFIG && !defined MAP_COPY
  762. diff --git a/elf/unload.c b/elf/unload.c
  763. index 4566f22..73046de 100644
  764. --- a/elf/unload.c
  765. +++ b/elf/unload.c
  766. @@ -9,7 +9,7 @@
  767. #include <stdio.h>
  768. #include <stdlib.h>
  769. -#define MAPS ((struct link_map *) _r_debug.r_map)
  770. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  771. #define OUT \
  772. for (map = MAPS; map != NULL; map = map->l_next) \
  773. diff --git a/elf/unload2.c b/elf/unload2.c
  774. index eef2bfd..a21d2ac 100644
  775. --- a/elf/unload2.c
  776. +++ b/elf/unload2.c
  777. @@ -6,7 +6,7 @@
  778. #include <stdio.h>
  779. #include <stdlib.h>
  780. -#define MAPS ((struct link_map *) _r_debug.r_map)
  781. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  782. #define OUT \
  783. for (map = MAPS; map != NULL; map = map->l_next) \
  784. diff --git a/malloc/arena.c b/malloc/arena.c
  785. index 5088a25..33a3879 100644
  786. --- a/malloc/arena.c
  787. +++ b/malloc/arena.c
  788. @@ -21,6 +21,27 @@
  789. /* Compile-time constants. */
  790. +#ifndef HEAP_MAX_SIZE
  791. +# ifdef DEFAULT_MMAP_THRESHOLD_MAX
  792. +# define DEFAULT_HEAP_MAX_SIZE (2 * DEFAULT_MMAP_THRESHOLD_MAX)
  793. +# else
  794. +# define DEFAULT_HEAP_MAX_SIZE (1024 * 1024) /* must be a power of two */
  795. +# endif
  796. +# include <sysdep.h>
  797. +static long int heap_max_size = 0;
  798. +# define HEAP_MAX_SIZE \
  799. + ({ \
  800. + if (!heap_max_size) { \
  801. + long int size = glibc_option("heap_size"); \
  802. + if (size > 0) \
  803. + heap_max_size = size; \
  804. + else \
  805. + heap_max_size = DEFAULT_HEAP_MAX_SIZE; \
  806. + } \
  807. + heap_max_size; \
  808. + })
  809. +#endif
  810. +
  811. #define HEAP_MIN_SIZE (32 * 1024)
  812. #ifndef HEAP_MAX_SIZE
  813. # ifdef DEFAULT_MMAP_THRESHOLD_MAX
  814. @@ -545,17 +566,6 @@ new_heap (size_t size, size_t top_pad)
  815. mapping (on Linux, this is the case for all non-writable mappings
  816. anyway). */
  817. p2 = MAP_FAILED;
  818. - if (aligned_heap_area)
  819. - {
  820. - p2 = (char *) MMAP (aligned_heap_area, HEAP_MAX_SIZE, PROT_NONE,
  821. - MAP_NORESERVE);
  822. - aligned_heap_area = NULL;
  823. - if (p2 != MAP_FAILED && ((unsigned long) p2 & (HEAP_MAX_SIZE - 1)))
  824. - {
  825. - __munmap (p2, HEAP_MAX_SIZE);
  826. - p2 = MAP_FAILED;
  827. - }
  828. - }
  829. if (p2 == MAP_FAILED)
  830. {
  831. p1 = (char *) MMAP (0, HEAP_MAX_SIZE << 1, PROT_NONE, MAP_NORESERVE);
  832. @@ -566,8 +576,6 @@ new_heap (size_t size, size_t top_pad)
  833. ul = p2 - p1;
  834. if (ul)
  835. __munmap (p1, ul);
  836. - else
  837. - aligned_heap_area = p2 + HEAP_MAX_SIZE;
  838. __munmap (p2 + HEAP_MAX_SIZE, HEAP_MAX_SIZE - ul);
  839. }
  840. else
  841. diff --git a/nptl/Makefile b/nptl/Makefile
  842. index 57cc8c6..81f1bf4 100644
  843. --- a/nptl/Makefile
  844. +++ b/nptl/Makefile
  845. @@ -20,7 +20,7 @@
  846. #
  847. subdir := nptl
  848. -headers := pthread.h semaphore.h bits/semaphore.h
  849. +headers := pthread.h semaphore.h bits/semaphore.h syscalldb.h
  850. extra-libs := libpthread
  851. extra-libs-others := $(extra-libs)
  852. diff --git a/nptl/Versions b/nptl/Versions
  853. index bb11277..354149a 100644
  854. --- a/nptl/Versions
  855. +++ b/nptl/Versions
  856. @@ -31,6 +31,9 @@ libc {
  857. # Internal libc interface to libpthread
  858. __libc_dl_error_tsd;
  859. }
  860. + SHIM {
  861. + syscalldb; glibc_option;
  862. + }
  863. }
  864. libpthread {
  865. @@ -262,4 +265,8 @@ libpthread {
  866. __pthread_clock_gettime; __pthread_clock_settime;
  867. __pthread_unwind; __pthread_get_minstack;
  868. }
  869. +
  870. + SHIM {
  871. + syscalldb; glibc_option;
  872. + }
  873. }
  874. diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
  875. index 9d7f52f..72d50ae 100644
  876. --- a/nptl/pthread_create.c
  877. +++ b/nptl/pthread_create.c
  878. @@ -405,8 +405,11 @@ start_thread (void *arg)
  879. # error "to do"
  880. #endif
  881. assert (freesize < pd->stackblock_size);
  882. + /* XXX: may not be necessary */
  883. +#if 0
  884. if (freesize > PTHREAD_STACK_MIN)
  885. __madvise (pd->stackblock, freesize - PTHREAD_STACK_MIN, MADV_DONTNEED);
  886. +#endif
  887. /* If the thread is detached free the TCB. */
  888. if (IS_DETACHED (pd))
  889. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S b/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S
  890. index 89fda5e..594dd72 100644
  891. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S
  892. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S
  893. @@ -111,7 +111,8 @@ ENTRY(__pthread_disable_asynccancel)
  894. xorq %r10, %r10
  895. addq $CANCELHANDLING, %rdi
  896. LOAD_PRIVATE_FUTEX_WAIT (%esi)
  897. - syscall
  898. + SYSCALL
  899. +
  900. movl %fs:CANCELHANDLING, %eax
  901. jmp 3b
  902. END(__pthread_disable_asynccancel)
  903. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/fork.c b/nptl/sysdeps/unix/sysv/linux/x86_64/fork.c
  904. index a036b92..40a1eaf 100644
  905. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/fork.c
  906. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/fork.c
  907. @@ -21,10 +21,20 @@
  908. #include <sysdep.h>
  909. #include <tls.h>
  910. -
  911. -#define ARCH_FORK() \
  912. +/* In Graphene, we prefer to call fork system call directly than clone */
  913. +#if USE_clone_FOR_fork
  914. +# define ARCH_FORK() \
  915. INLINE_SYSCALL (clone, 4, \
  916. CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD, 0, \
  917. NULL, &THREAD_SELF->tid)
  918. +#else
  919. +# define ARCH_FORK() \
  920. + ({ unsigned long ret = INLINE_SYSCALL (fork, 0); \
  921. + if (!ret) { \
  922. + pid_t pid = INLINE_SYSCALL (getpid, 0); \
  923. + THREAD_SETMEM (THREAD_SELF, pid, pid); \
  924. + THREAD_SETMEM (THREAD_SELF, tid, pid); \
  925. + } ret; })
  926. +#endif
  927. #include "../fork.c"
  928. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
  929. index f2dca07..0ce7c67 100644
  930. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
  931. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
  932. @@ -90,7 +90,7 @@ __lll_lock_wait_private:
  933. 1: LIBC_PROBE (lll_lock_wait_private, 1, %rdi)
  934. movl $SYS_futex, %eax
  935. - syscall
  936. + SYSCALLDB
  937. 2: movl %edx, %eax
  938. xchgl %eax, (%rdi) /* NB: lock is implied */
  939. @@ -130,7 +130,7 @@ __lll_lock_wait:
  940. 1: LIBC_PROBE (lll_lock_wait, 2, %rdi, %rsi)
  941. movl $SYS_futex, %eax
  942. - syscall
  943. + SYSCALLDB
  944. 2: movl %edx, %eax
  945. xchgl %eax, (%rdi) /* NB: lock is implied */
  946. @@ -185,7 +185,7 @@ __lll_timedlock_wait:
  947. 1: movl $SYS_futex, %eax
  948. movl $2, %edx
  949. - syscall
  950. + SYSCALLDB
  951. 2: xchgl %edx, (%rdi) /* NB: lock is implied */
  952. @@ -279,7 +279,7 @@ __lll_timedlock_wait:
  953. LOAD_FUTEX_WAIT (%esi)
  954. movq %r12, %rdi
  955. movl $SYS_futex, %eax
  956. - syscall
  957. + SYSCALLDB
  958. /* NB: %edx == 2 */
  959. xchgl %edx, (%r12)
  960. @@ -336,7 +336,7 @@ __lll_unlock_wake_private:
  961. LOAD_PRIVATE_FUTEX_WAKE (%esi)
  962. movl $1, %edx /* Wake one thread. */
  963. movl $SYS_futex, %eax
  964. - syscall
  965. + SYSCALLDB
  966. popq %rdx
  967. cfi_adjust_cfa_offset(-8)
  968. @@ -366,7 +366,7 @@ __lll_unlock_wake:
  969. LOAD_FUTEX_WAKE (%esi)
  970. movl $1, %edx /* Wake one thread. */
  971. movl $SYS_futex, %eax
  972. - syscall
  973. + SYSCALLDB
  974. popq %rdx
  975. cfi_adjust_cfa_offset(-8)
  976. @@ -435,7 +435,7 @@ __lll_timedwait_tid:
  977. #endif
  978. movq %r12, %rdi
  979. movl $SYS_futex, %eax
  980. - syscall
  981. + SYSCALLDB
  982. cmpl $0, (%rdi)
  983. jne 1f
  984. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
  985. index 0a26739..8aae14a 100644
  986. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
  987. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
  988. @@ -214,7 +214,7 @@ LLL_STUB_UNWIND_INFO_END
  989. register const struct timespec *__to __asm ("r10") = timeout; \
  990. int __status; \
  991. register __typeof (val) _val __asm ("edx") = (val); \
  992. - __asm __volatile ("syscall" \
  993. + __asm __volatile (SYSCALLDB \
  994. : "=a" (__status) \
  995. : "0" (SYS_futex), "D" (futex), \
  996. "S" (__lll_private_flag (FUTEX_WAIT, private)), \
  997. @@ -229,7 +229,7 @@ LLL_STUB_UNWIND_INFO_END
  998. int __status; \
  999. register __typeof (nr) _nr __asm ("edx") = (nr); \
  1000. LIBC_PROBE (lll_futex_wake, 3, futex, nr, private); \
  1001. - __asm __volatile ("syscall" \
  1002. + __asm __volatile (SYSCALLDB \
  1003. : "=a" (__status) \
  1004. : "0" (SYS_futex), "D" (futex), \
  1005. "S" (__lll_private_flag (FUTEX_WAKE, private)), \
  1006. @@ -540,7 +540,7 @@ extern int __lll_timedlock_elision (int *futex, short *adapt_count,
  1007. { \
  1008. int ignore; \
  1009. __asm __volatile (LOCK_INSTR "orl %3, (%2)\n\t" \
  1010. - "syscall" \
  1011. + SYSCALLDB \
  1012. : "=m" (futex), "=a" (ignore) \
  1013. : "D" (&(futex)), "i" (FUTEX_OWNER_DIED), \
  1014. "S" (__lll_private_flag (FUTEX_WAKE, private)), \
  1015. @@ -555,7 +555,7 @@ extern int __lll_timedlock_elision (int *futex, short *adapt_count,
  1016. register int __nr_move __asm ("r10") = nr_move; \
  1017. register void *__mutex __asm ("r8") = mutex; \
  1018. register int __val __asm ("r9") = val; \
  1019. - __asm __volatile ("syscall" \
  1020. + __asm __volatile (SYSCALLDB \
  1021. : "=a" (__res) \
  1022. : "0" (__NR_futex), "D" ((void *) ftx), \
  1023. "S" (__lll_private_flag (FUTEX_CMP_REQUEUE, \
  1024. @@ -581,7 +581,7 @@ extern int __lll_timedlock_elision (int *futex, short *adapt_count,
  1025. if (_tid != 0) \
  1026. __asm __volatile ("xorq %%r10, %%r10\n\t" \
  1027. "1:\tmovq %2, %%rax\n\t" \
  1028. - "syscall\n\t" \
  1029. + SYSCALLDB \
  1030. "cmpl $0, (%%rdi)\n\t" \
  1031. "jne 1b" \
  1032. : "=&a" (__ignore) \
  1033. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
  1034. index 990b6f9..b01214d 100644
  1035. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
  1036. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
  1037. @@ -80,7 +80,7 @@ __lll_robust_lock_wait:
  1038. jnz 2f
  1039. 1: movl $SYS_futex, %eax
  1040. - syscall
  1041. + SYSCALLDB
  1042. movl (%rdi), %eax
  1043. @@ -145,7 +145,7 @@ __lll_robust_timedlock_wait:
  1044. jnz 6f
  1045. 5: movl $SYS_futex, %eax
  1046. - syscall
  1047. + SYSCALLDB
  1048. movl %eax, %ecx
  1049. movl (%rdi), %eax
  1050. @@ -257,7 +257,7 @@ __lll_robust_timedlock_wait:
  1051. LOAD_FUTEX_WAIT (%esi)
  1052. movq %r12, %rdi
  1053. movl $SYS_futex, %eax
  1054. - syscall
  1055. + SYSCALLDB
  1056. movq %rax, %rcx
  1057. movl (%r12), %eax
  1058. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S
  1059. index eec17f2..a350340 100644
  1060. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S
  1061. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S
  1062. @@ -62,7 +62,7 @@ pthread_barrier_wait:
  1063. #endif
  1064. xorq %r10, %r10
  1065. 8: movl $SYS_futex, %eax
  1066. - syscall
  1067. + SYSCALLDB
  1068. /* Don't return on spurious wakeups. The syscall does not change
  1069. any register except %eax so there is no need to reload any of
  1070. @@ -109,7 +109,7 @@ pthread_barrier_wait:
  1071. movl $FUTEX_WAKE, %esi
  1072. orl PRIVATE(%rdi), %esi
  1073. movl $SYS_futex, %eax
  1074. - syscall
  1075. + SYSCALLDB
  1076. /* Increment LEFT. If this brings the count back to the
  1077. initial count unlock the object. */
  1078. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
  1079. index 985e0f1..d559456 100644
  1080. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
  1081. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
  1082. @@ -90,7 +90,7 @@ __pthread_cond_broadcast:
  1083. movl $SYS_futex, %eax
  1084. movl $1, %edx
  1085. movl $0x7fffffff, %r10d
  1086. - syscall
  1087. + SYSCALLDB
  1088. /* For any kind of error, which mainly is EAGAIN, we try again
  1089. with WAKE. The general test also covers running on old
  1090. @@ -106,7 +106,7 @@ __pthread_cond_broadcast:
  1091. movl $SYS_futex, %eax
  1092. movl $1, %edx
  1093. movl $0x7fffffff, %r10d
  1094. - syscall
  1095. + SYSCALLDB
  1096. /* For any kind of error, which mainly is EAGAIN, we try again
  1097. with WAKE. The general test also covers running on old
  1098. @@ -172,7 +172,7 @@ __pthread_cond_broadcast:
  1099. orl $FUTEX_WAKE, %esi
  1100. #endif
  1101. movl $SYS_futex, %eax
  1102. - syscall
  1103. + SYSCALLDB
  1104. jmp 10b
  1105. .size __pthread_cond_broadcast, .-__pthread_cond_broadcast
  1106. versioned_symbol (libpthread, __pthread_cond_broadcast, pthread_cond_broadcast,
  1107. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
  1108. index 53d65b6..16df581 100644
  1109. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
  1110. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
  1111. @@ -82,7 +82,7 @@ __pthread_cond_signal:
  1112. addq $cond_lock, %r8
  1113. #endif
  1114. movl $FUTEX_OP_CLEAR_WAKE_IF_GT_ONE, %r9d
  1115. - syscall
  1116. + SYSCALLDB
  1117. #if cond_lock != 0
  1118. subq $cond_lock, %r8
  1119. #endif
  1120. @@ -99,7 +99,7 @@ __pthread_cond_signal:
  1121. movq %rcx, %r8
  1122. xorq %r10, %r10
  1123. movl (%rdi), %r9d // XXX Can this be right?
  1124. - syscall
  1125. + SYSCALLDB
  1126. leaq -cond_futex(%rdi), %r8
  1127. @@ -118,7 +118,7 @@ __pthread_cond_signal:
  1128. movl $SYS_futex, %eax
  1129. /* %rdx should be 1 already from $FUTEX_WAKE_OP syscall.
  1130. movl $1, %edx */
  1131. - syscall
  1132. + SYSCALLDB
  1133. /* Unlock. */
  1134. 4: LOCK
  1135. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
  1136. index 0dc2340..8aff242 100644
  1137. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
  1138. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
  1139. @@ -188,7 +188,7 @@ __pthread_cond_timedwait:
  1140. movq %r12, %rdx
  1141. addq $cond_futex, %rdi
  1142. movl $SYS_futex, %eax
  1143. - syscall
  1144. + SYSCALLDB
  1145. cmpl $0, %eax
  1146. sete %r15b
  1147. @@ -234,7 +234,7 @@ __pthread_cond_timedwait:
  1148. movq %r12, %rdx
  1149. addq $cond_futex, %rdi
  1150. movl $SYS_futex, %eax
  1151. - syscall
  1152. + SYSCALLDB
  1153. 62: movq %rax, %r14
  1154. movl (%rsp), %edi
  1155. @@ -321,7 +321,7 @@ __pthread_cond_timedwait:
  1156. orl $FUTEX_WAKE, %esi
  1157. #endif
  1158. movl $SYS_futex, %eax
  1159. - syscall
  1160. + SYSCALLDB
  1161. subq $cond_nwaiters, %rdi
  1162. 55: LOCK
  1163. @@ -485,15 +485,8 @@ __pthread_cond_timedwait:
  1164. /* Only clocks 0 and 1 are allowed so far. Both are handled in the
  1165. kernel. */
  1166. leaq 32(%rsp), %rsi
  1167. -# ifdef SHARED
  1168. - mov __vdso_clock_gettime@GOTPCREL(%rip), %RAX_LP
  1169. - mov (%rax), %RAX_LP
  1170. - PTR_DEMANGLE (%RAX_LP)
  1171. - call *%rax
  1172. -# else
  1173. movl $__NR_clock_gettime, %eax
  1174. - syscall
  1175. -# endif
  1176. + SYSCALLDB
  1177. /* Compute relative timeout. */
  1178. movq (%r13), %rcx
  1179. @@ -560,7 +553,7 @@ __pthread_cond_timedwait:
  1180. # endif
  1181. addq $cond_futex, %rdi
  1182. movl $SYS_futex, %eax
  1183. - syscall
  1184. + SYSCALLDB
  1185. movq %rax, %r14
  1186. movl (%rsp), %edi
  1187. @@ -732,7 +725,7 @@ __condvar_cleanup2:
  1188. orl $FUTEX_WAKE, %esi
  1189. #endif
  1190. movl $SYS_futex, %eax
  1191. - syscall
  1192. + SYSCALLDB
  1193. subq $cond_nwaiters, %rdi
  1194. movl $1, %r12d
  1195. @@ -769,7 +762,7 @@ __condvar_cleanup2:
  1196. orl $FUTEX_WAKE, %esi
  1197. #endif
  1198. movl $SYS_futex, %eax
  1199. - syscall
  1200. + SYSCALLDB
  1201. /* Lock the mutex only if we don't own it already. This only happens
  1202. in case of PI mutexes, if we got cancelled after a successful
  1203. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
  1204. index 0e61d0a..b4bcc15 100644
  1205. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
  1206. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
  1207. @@ -138,7 +138,7 @@ __pthread_cond_wait:
  1208. movl $(FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %esi
  1209. movl $SYS_futex, %eax
  1210. - syscall
  1211. + SYSCALLDB
  1212. cmpl $0, %eax
  1213. sete %r8b
  1214. @@ -180,7 +180,7 @@ __pthread_cond_wait:
  1215. #endif
  1216. 60: xorb %r8b, %r8b
  1217. movl $SYS_futex, %eax
  1218. - syscall
  1219. + SYSCALLDB
  1220. 62: movl (%rsp), %edi
  1221. callq __pthread_disable_asynccancel
  1222. @@ -239,7 +239,7 @@ __pthread_cond_wait:
  1223. orl $FUTEX_WAKE, %esi
  1224. #endif
  1225. movl $SYS_futex, %eax
  1226. - syscall
  1227. + SYSCALLDB
  1228. subq $cond_nwaiters, %rdi
  1229. 17: LOCK
  1230. @@ -455,7 +455,7 @@ __condvar_cleanup1:
  1231. orl $FUTEX_WAKE, %esi
  1232. #endif
  1233. movl $SYS_futex, %eax
  1234. - syscall
  1235. + SYSCALLDB
  1236. subq $cond_nwaiters, %rdi
  1237. movl $1, %ecx
  1238. @@ -493,7 +493,7 @@ __condvar_cleanup1:
  1239. orl $FUTEX_WAKE, %esi
  1240. #endif
  1241. movl $SYS_futex, %eax
  1242. - syscall
  1243. + SYSCALLDB
  1244. /* Lock the mutex only if we don't own it already. This only happens
  1245. in case of PI mutexes, if we got cancelled after a successful
  1246. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
  1247. index 2cbe2fa..489998a 100644
  1248. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
  1249. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
  1250. @@ -90,7 +90,7 @@ __pthread_once:
  1251. # endif
  1252. #endif
  1253. movl $SYS_futex, %eax
  1254. - syscall
  1255. + SYSCALLDB
  1256. jmp 6b
  1257. /* Preserve the pointer to the control variable. */
  1258. @@ -123,7 +123,7 @@ __pthread_once:
  1259. orl %fs:PRIVATE_FUTEX, %esi
  1260. #endif
  1261. movl $SYS_futex, %eax
  1262. - syscall
  1263. + SYSCALLDB
  1264. 4: addq $8, %rsp
  1265. cfi_adjust_cfa_offset(-8)
  1266. @@ -152,7 +152,7 @@ clear_once_control:
  1267. orl %fs:PRIVATE_FUTEX, %esi
  1268. #endif
  1269. movl $SYS_futex, %eax
  1270. - syscall
  1271. + SYSCALLDB
  1272. movq %r8, %rdi
  1273. .LcallUR:
  1274. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
  1275. index 3bbb4c7..53d5ca6 100644
  1276. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
  1277. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
  1278. @@ -82,7 +82,7 @@ __pthread_rwlock_rdlock:
  1279. #endif
  1280. addq $READERS_WAKEUP, %rdi
  1281. movl $SYS_futex, %eax
  1282. - syscall
  1283. + SYSCALLDB
  1284. subq $READERS_WAKEUP, %rdi
  1285. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
  1286. index 40bcc04..348170e 100644
  1287. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
  1288. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
  1289. @@ -109,7 +109,7 @@ pthread_rwlock_timedrdlock:
  1290. #endif
  1291. 21: leaq READERS_WAKEUP(%r12), %rdi
  1292. movl $SYS_futex, %eax
  1293. - syscall
  1294. + SYSCALLDB
  1295. movq %rax, %rdx
  1296. #ifndef __ASSUME_FUTEX_CLOCK_REALTIME
  1297. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
  1298. index f57ef52..e9ac77f 100644
  1299. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
  1300. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
  1301. @@ -106,7 +106,7 @@ pthread_rwlock_timedwrlock:
  1302. #endif
  1303. 21: leaq WRITERS_WAKEUP(%r12), %rdi
  1304. movl $SYS_futex, %eax
  1305. - syscall
  1306. + SYSCALLDB
  1307. movq %rax, %rdx
  1308. #ifndef __ASSUME_FUTEX_CLOCK_REALTIME
  1309. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
  1310. index d779f7b..849c74f 100644
  1311. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
  1312. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
  1313. @@ -79,7 +79,7 @@ __pthread_rwlock_unlock:
  1314. #endif
  1315. movl $SYS_futex, %eax
  1316. movq %r10, %rdi
  1317. - syscall
  1318. + SYSCALLDB
  1319. xorl %eax, %eax
  1320. retq
  1321. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
  1322. index e444def..fd94930 100644
  1323. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
  1324. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
  1325. @@ -80,7 +80,7 @@ __pthread_rwlock_wrlock:
  1326. #endif
  1327. addq $WRITERS_WAKEUP, %rdi
  1328. movl $SYS_futex, %eax
  1329. - syscall
  1330. + SYSCALLDB
  1331. subq $WRITERS_WAKEUP, %rdi
  1332. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
  1333. index 1c11600..bd166cf 100644
  1334. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
  1335. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
  1336. @@ -52,7 +52,7 @@ sem_post:
  1337. movl $FUTEX_WAKE, %esi
  1338. orl PRIVATE(%rdi), %esi
  1339. movl $1, %edx
  1340. - syscall
  1341. + SYSCALLDB
  1342. testq %rax, %rax
  1343. js 1f
  1344. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
  1345. index 880610e..e520049 100644
  1346. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
  1347. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
  1348. @@ -97,7 +97,7 @@ sem_timedwait:
  1349. orl PRIVATE(%rdi), %esi
  1350. movl $SYS_futex, %eax
  1351. xorl %edx, %edx
  1352. - syscall
  1353. + SYSCALLDB
  1354. movq %rax, %r9
  1355. #if VALUE != 0
  1356. leaq -VALUE(%rdi), %rdi
  1357. @@ -233,7 +233,7 @@ sem_timedwait:
  1358. # endif
  1359. movl $SYS_futex, %eax
  1360. xorl %edx, %edx
  1361. - syscall
  1362. + SYSCALLDB
  1363. movq %rax, %r14
  1364. movl 16(%rsp), %edi
  1365. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
  1366. index 8f4d068..fe6dfbf 100644
  1367. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
  1368. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
  1369. @@ -81,7 +81,7 @@ sem_wait:
  1370. orl PRIVATE(%rdi), %esi
  1371. #endif
  1372. xorl %edx, %edx
  1373. - syscall
  1374. + SYSCALLDB
  1375. movq %rax, %rcx
  1376. xchgq %r8, %rdi
  1377. diff --git a/nptl/sysdeps/x86_64/pthreaddef.h b/nptl/sysdeps/x86_64/pthreaddef.h
  1378. index 18a15a1..f050241 100644
  1379. --- a/nptl/sysdeps/x86_64/pthreaddef.h
  1380. +++ b/nptl/sysdeps/x86_64/pthreaddef.h
  1381. @@ -48,4 +48,4 @@
  1382. /* While there is no such syscall. */
  1383. #define __exit_thread_inline(val) \
  1384. - asm volatile ("syscall" :: "a" (__NR_exit), "D" (val))
  1385. + asm volatile (SYSCALLDB :: "a" (__NR_exit), "D" (val))
  1386. diff --git a/nptl/sysdeps/x86_64/tls.h b/nptl/sysdeps/x86_64/tls.h
  1387. index cbb5e9e..9b87e25 100644
  1388. --- a/nptl/sysdeps/x86_64/tls.h
  1389. +++ b/nptl/sysdeps/x86_64/tls.h
  1390. @@ -28,6 +28,8 @@
  1391. # include <sysdep.h>
  1392. # include <libc-internal.h>
  1393. # include <kernel-features.h>
  1394. +# include <shim_tls.h>
  1395. +# include <syscalldb.h>
  1396. /* Replacement type for __m128 since this file is included by ld.so,
  1397. which is compiled with -mno-sse. It must not change the alignment
  1398. @@ -67,6 +69,10 @@ typedef struct
  1399. # else
  1400. int __glibc_reserved1;
  1401. # endif
  1402. +
  1403. + shim_tcb_t shim_tcb; /* For graphene, we allocate a shim_tcb
  1404. + in the real tcb. */
  1405. +
  1406. int rtld_must_xmm_save;
  1407. /* Reservation of some values for the TM ABI. */
  1408. void *__private_tm[4];
  1409. @@ -137,7 +143,6 @@ typedef struct
  1410. # define GET_DTV(descr) \
  1411. (((tcbhead_t *) (descr))->dtv)
  1412. -
  1413. /* Code to initially initialize the thread pointer. This might need
  1414. special attention since 'errno' is not yet available and if the
  1415. operation can cause a failure 'errno' must not be touched.
  1416. @@ -154,7 +159,7 @@ typedef struct
  1417. _head->self = _thrdescr; \
  1418. \
  1419. /* It is a simple syscall to set the %fs value for the thread. */ \
  1420. - asm volatile ("syscall" \
  1421. + asm volatile (SYSCALLDB \
  1422. : "=a" (_result) \
  1423. : "0" ((unsigned long int) __NR_arch_prctl), \
  1424. "D" ((unsigned long int) ARCH_SET_FS), \
  1425. diff --git a/scripts/mkinstalldirs b/scripts/mkinstalldirs
  1426. index 55d537f..57bf12b 100755
  1427. --- a/scripts/mkinstalldirs
  1428. +++ b/scripts/mkinstalldirs
  1429. @@ -126,9 +126,9 @@ do
  1430. esac
  1431. if test ! -d "$pathcomp"; then
  1432. - echo "mkdir $pathcomp"
  1433. + echo "mkdir -p $pathcomp"
  1434. - mkdir "$pathcomp" || lasterr=$?
  1435. + mkdir -p "$pathcomp" || lasterr=$?
  1436. if test ! -d "$pathcomp"; then
  1437. errstatus=$lasterr
  1438. diff --git a/shlib-versions b/shlib-versions
  1439. index 78b0ad7..5c3dcf2 100644
  1440. --- a/shlib-versions
  1441. +++ b/shlib-versions
  1442. @@ -108,3 +108,5 @@ sparc64.*-.*-.* libBrokenLocale=1 GLIBC_2.2
  1443. # This defines the libgcc soname version this glibc is to load for
  1444. # asynchronous cancellation to work correctly.
  1445. .*-.*-.* libgcc_s=1
  1446. +
  1447. +.*-.*-.* liblibos=1
  1448. diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
  1449. index ffeb093..7a9fbcb 100644
  1450. --- a/sysdeps/generic/ldsodefs.h
  1451. +++ b/sysdeps/generic/ldsodefs.h
  1452. @@ -881,8 +881,7 @@ extern void _dl_sort_fini (struct link_map **maps, size_t nmaps, char *used,
  1453. any shared object mappings. The `r_state' member of `struct r_debug'
  1454. says what change is taking place. This function's address is
  1455. the value of the `r_brk' member. */
  1456. -extern void _dl_debug_state (void);
  1457. -rtld_hidden_proto (_dl_debug_state)
  1458. +extern void __libc_dl_debug_state (void) __attribute__((weak));
  1459. /* Initialize `struct r_debug' if it has not already been done. The
  1460. argument is the run-time load address of the dynamic linker, to be put
  1461. diff --git a/sysdeps/unix/sysv/linux/_exit.c b/sysdeps/unix/sysv/linux/_exit.c
  1462. index 2468228..a9f1cd6 100644
  1463. --- a/sysdeps/unix/sysv/linux/_exit.c
  1464. +++ b/sysdeps/unix/sysv/linux/_exit.c
  1465. @@ -29,9 +29,9 @@ _exit (status)
  1466. while (1)
  1467. {
  1468. #ifdef __NR_exit_group
  1469. - INLINE_SYSCALL (exit_group, 1, status);
  1470. + INLINE_SYSCALL_ASM (exit_group, 1, status);
  1471. #endif
  1472. - INLINE_SYSCALL (exit, 1, status);
  1473. + INLINE_SYSCALL_ASM (exit, 1, status);
  1474. #ifdef ABORT_INSTRUCTION
  1475. ABORT_INSTRUCTION;
  1476. diff --git a/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S b/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
  1477. index 49f0384..6b1a975 100644
  1478. --- a/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
  1479. +++ b/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
  1480. @@ -84,7 +84,8 @@ ENTRY(____longjmp_chk)
  1481. xorl %edi, %edi
  1482. lea -sizeSS(%rsp), %RSI_LP
  1483. movl $__NR_sigaltstack, %eax
  1484. - syscall
  1485. + SYSCALLDB
  1486. +
  1487. /* Without working sigaltstack we cannot perform the test. */
  1488. testl %eax, %eax
  1489. jne .Lok2
  1490. diff --git a/sysdeps/unix/sysv/linux/x86_64/clock_gettime.c b/sysdeps/unix/sysv/linux/x86_64/clock_gettime.c
  1491. index f712110..f6bad14 100644
  1492. --- a/sysdeps/unix/sysv/linux/x86_64/clock_gettime.c
  1493. +++ b/sysdeps/unix/sysv/linux/x86_64/clock_gettime.c
  1494. @@ -1,5 +1,6 @@
  1495. #include "bits/libc-vdso.h"
  1496. +#if 0 /* in Graphene, disallow VDSO calls */
  1497. #ifdef SHARED
  1498. # define SYSCALL_GETTIME(id, tp) \
  1499. ({ long int (*f) (clockid_t, struct timespec *) = __vdso_clock_gettime; \
  1500. @@ -16,5 +17,6 @@
  1501. PTR_DEMANGLE (f); \
  1502. f (id, tp); })
  1503. #endif
  1504. +#endif
  1505. #include "../clock_gettime.c"
  1506. diff --git a/sysdeps/unix/sysv/linux/x86_64/clone.S b/sysdeps/unix/sysv/linux/x86_64/clone.S
  1507. index 0508730..e1b35ec 100644
  1508. --- a/sysdeps/unix/sysv/linux/x86_64/clone.S
  1509. +++ b/sysdeps/unix/sysv/linux/x86_64/clone.S
  1510. @@ -59,11 +59,15 @@ ENTRY (__clone)
  1511. jz SYSCALL_ERROR_LABEL
  1512. /* Insert the argument onto the new stack. */
  1513. - subq $16,%rsi
  1514. - movq %rcx,8(%rsi)
  1515. + subq $24,%rsi
  1516. + movq %rcx,16(%rsi)
  1517. /* Save the function pointer. It will be popped off in the
  1518. child in the ebx frobbing below. */
  1519. + movq %rdi,8(%rsi)
  1520. +
  1521. + /* Push an additional pointer as return address into the stack */
  1522. + leaq L(clone_return)(%rip),%rdi
  1523. movq %rdi,0(%rsi)
  1524. /* Do the system call. */
  1525. @@ -76,8 +80,9 @@ ENTRY (__clone)
  1526. /* End FDE now, because in the child the unwind info will be
  1527. wrong. */
  1528. cfi_endproc;
  1529. - syscall
  1530. + SYSCALLDB
  1531. +L(clone_return):
  1532. testq %rax,%rax
  1533. jl SYSCALL_ERROR_LABEL
  1534. jz L(thread_start)
  1535. @@ -99,13 +104,14 @@ L(thread_start):
  1536. movl $-1, %eax
  1537. jne 2f
  1538. movl $SYS_ify(getpid), %eax
  1539. - syscall
  1540. + SYSCALLDB
  1541. 2: movl %eax, %fs:PID
  1542. movl %eax, %fs:TID
  1543. 1:
  1544. #endif
  1545. /* Set up arguments for the function call. */
  1546. + addq $8,%rsp /* Skip the return address */
  1547. popq %rax /* Function to call. */
  1548. popq %rdi /* Argument. */
  1549. call *%rax
  1550. diff --git a/sysdeps/unix/sysv/linux/x86_64/getcontext.S b/sysdeps/unix/sysv/linux/x86_64/getcontext.S
  1551. index 140db03..6967f10 100644
  1552. --- a/sysdeps/unix/sysv/linux/x86_64/getcontext.S
  1553. +++ b/sysdeps/unix/sysv/linux/x86_64/getcontext.S
  1554. @@ -75,7 +75,7 @@ ENTRY(__getcontext)
  1555. #endif
  1556. movl $_NSIG8,%r10d
  1557. movl $__NR_rt_sigprocmask, %eax
  1558. - syscall
  1559. + SYSCALLDB
  1560. cmpq $-4095, %rax /* Check %rax for error. */
  1561. jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
  1562. diff --git a/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c b/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c
  1563. index 440ca7f..571125d 100644
  1564. --- a/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c
  1565. +++ b/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c
  1566. @@ -17,6 +17,7 @@
  1567. #include <sys/time.h>
  1568. +#if 0 /* In graphene, do not use vsyscall or VDSO call */
  1569. #ifdef SHARED
  1570. # include <dl-vdso.h>
  1571. @@ -42,7 +43,8 @@ asm (".type __gettimeofday, %gnu_indirect_function");
  1572. asm (".globl __GI___gettimeofday\n"
  1573. "__GI___gettimeofday = __gettimeofday");
  1574. -#else
  1575. +#endif
  1576. +#endif
  1577. # include <sysdep.h>
  1578. # include <errno.h>
  1579. @@ -54,6 +56,5 @@ __gettimeofday (struct timeval *tv, struct timezone *tz)
  1580. }
  1581. libc_hidden_def (__gettimeofday)
  1582. -#endif
  1583. weak_alias (__gettimeofday, gettimeofday)
  1584. libc_hidden_weak (gettimeofday)
  1585. diff --git a/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S b/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
  1586. index 0fd47f2..7a82975 100644
  1587. --- a/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
  1588. +++ b/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
  1589. @@ -30,6 +30,7 @@ ENTRY (sched_getcpu)
  1590. sub $0x8, %rsp
  1591. cfi_adjust_cfa_offset(8)
  1592. +#if 0 /* for Graphene, never do VDSO calls */
  1593. movq %rsp, %rdi
  1594. xorl %esi, %esi
  1595. movl $VGETCPU_CACHE_OFFSET, %edx
  1596. @@ -39,16 +40,19 @@ ENTRY (sched_getcpu)
  1597. movq __vdso_getcpu(%rip), %rax
  1598. PTR_DEMANGLE (%rax)
  1599. callq *%rax
  1600. -#else
  1601. -# ifdef __NR_getcpu
  1602. +#endif
  1603. +#endif
  1604. +
  1605. +#ifdef __NR_getcpu
  1606. movl $__NR_getcpu, %eax
  1607. - syscall
  1608. -# ifndef __ASSUME_GETCPU_SYSCALL
  1609. + SYSCALLDB
  1610. +#endif
  1611. +
  1612. +#if 0 /* for Graphene, never do vsyscall */
  1613. +# ifndef __ASSUME_GETCPU_SYSCALL
  1614. cmpq $-ENOSYS, %rax
  1615. jne 1f
  1616. -# endif
  1617. -# endif
  1618. -# ifndef __ASSUME_GETCPU_SYSCALL
  1619. +
  1620. movq $VSYSCALL_ADDR_vgetcpu, %rax
  1621. callq *%rax
  1622. 1:
  1623. diff --git a/sysdeps/unix/sysv/linux/x86_64/setcontext.S b/sysdeps/unix/sysv/linux/x86_64/setcontext.S
  1624. index b726fa0..bb3ae34 100644
  1625. --- a/sysdeps/unix/sysv/linux/x86_64/setcontext.S
  1626. +++ b/sysdeps/unix/sysv/linux/x86_64/setcontext.S
  1627. @@ -43,7 +43,7 @@ ENTRY(__setcontext)
  1628. movl $SIG_SETMASK, %edi
  1629. movl $_NSIG8,%r10d
  1630. movl $__NR_rt_sigprocmask, %eax
  1631. - syscall
  1632. + SYSCALLDB
  1633. popq %rdi /* Reload %rdi, adjust stack. */
  1634. cfi_adjust_cfa_offset(-8)
  1635. cmpq $-4095, %rax /* Check %rax for error. */
  1636. diff --git a/sysdeps/unix/sysv/linux/x86_64/sigaction.c b/sysdeps/unix/sysv/linux/x86_64/sigaction.c
  1637. index ab23985..38a6b69 100644
  1638. --- a/sysdeps/unix/sysv/linux/x86_64/sigaction.c
  1639. +++ b/sysdeps/unix/sysv/linux/x86_64/sigaction.c
  1640. @@ -129,7 +129,7 @@ asm \
  1641. " .type __" #name ",@function\n" \
  1642. "__" #name ":\n" \
  1643. " movq $" #syscall ", %rax\n" \
  1644. - " syscall\n" \
  1645. + SYSCALLDB_ASM \
  1646. ".LEND_" #name ":\n" \
  1647. ".section .eh_frame,\"a\",@progbits\n" \
  1648. ".LSTARTFRAME_" #name ":\n" \
  1649. diff --git a/sysdeps/unix/sysv/linux/x86_64/swapcontext.S b/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
  1650. index b3854fa..6369bfe 100644
  1651. --- a/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
  1652. +++ b/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
  1653. @@ -75,7 +75,7 @@ ENTRY(__swapcontext)
  1654. movl $SIG_SETMASK, %edi
  1655. movl $_NSIG8,%r10d
  1656. movl $__NR_rt_sigprocmask, %eax
  1657. - syscall
  1658. + SYSCALLDB
  1659. cmpq $-4095, %rax /* Check %rax for error. */
  1660. jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
  1661. diff --git a/sysdeps/unix/sysv/linux/x86_64/syscall.S b/sysdeps/unix/sysv/linux/x86_64/syscall.S
  1662. index 92c2f5b..33f820f 100644
  1663. --- a/sysdeps/unix/sysv/linux/x86_64/syscall.S
  1664. +++ b/sysdeps/unix/sysv/linux/x86_64/syscall.S
  1665. @@ -34,7 +34,7 @@ ENTRY (syscall)
  1666. movq %r8, %r10
  1667. movq %r9, %r8
  1668. movq 8(%rsp),%r9 /* arg6 is on the stack. */
  1669. - syscall /* Do the system call. */
  1670. + SYSCALLDB /* Do the system call. */
  1671. cmpq $-4095, %rax /* Check %rax for error. */
  1672. jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
  1673. ret /* Return to caller. */
  1674. diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  1675. index 4a9a9d9..dc452ed 100644
  1676. --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  1677. +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  1678. @@ -21,6 +21,7 @@
  1679. /* There is some commonality. */
  1680. #include <sysdeps/unix/x86_64/sysdep.h>
  1681. #include <tls.h>
  1682. +#include "syscalldb.h"
  1683. #ifdef IS_IN_rtld
  1684. # include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
  1685. @@ -176,7 +177,7 @@
  1686. # define DO_CALL(syscall_name, args) \
  1687. DOARGS_##args \
  1688. movl $SYS_ify (syscall_name), %eax; \
  1689. - syscall;
  1690. + SYSCALLDB
  1691. # define DOARGS_0 /* nothing */
  1692. # define DOARGS_1 /* nothing */
  1693. @@ -190,9 +191,20 @@
  1694. /* Define a macro which expands inline into the wrapper code for a system
  1695. call. */
  1696. # undef INLINE_SYSCALL
  1697. -# define INLINE_SYSCALL(name, nr, args...) \
  1698. +# define INLINE_SYSCALL(name, nr_args...) \
  1699. ({ \
  1700. - unsigned long int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
  1701. + unsigned long int resultvar = INTERNAL_SYSCALL (name, , ##nr_args); \
  1702. + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
  1703. + { \
  1704. + __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
  1705. + resultvar = (unsigned long int) -1; \
  1706. + } \
  1707. + (long int) resultvar; })
  1708. +
  1709. +# undef INLINE_SYSCALL_ASM
  1710. +# define INLINE_SYSCALL_ASM(name, nr_args...) \
  1711. + ({ \
  1712. + unsigned long int resultvar = INTERNAL_SYSCALL_ASM (name, , ##nr_args); \
  1713. if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
  1714. { \
  1715. __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
  1716. @@ -204,9 +216,9 @@
  1717. into the wrapper code for a system call. It should be used when size
  1718. of any argument > size of long int. */
  1719. # undef INLINE_SYSCALL_TYPES
  1720. -# define INLINE_SYSCALL_TYPES(name, nr, args...) \
  1721. +# define INLINE_SYSCALL_TYPES(name, nr_args...) \
  1722. ({ \
  1723. - unsigned long int resultvar = INTERNAL_SYSCALL_TYPES (name, , nr, args); \
  1724. + unsigned long int resultvar = INTERNAL_SYSCALL_TYPES (name, , ##nr_args); \
  1725. if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
  1726. { \
  1727. __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
  1728. @@ -223,13 +235,19 @@
  1729. LOAD_ARGS_##nr (args) \
  1730. LOAD_REGS_##nr \
  1731. asm volatile ( \
  1732. - "syscall\n\t" \
  1733. + SYSCALLDB \
  1734. : "=a" (resultvar) \
  1735. : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx"); \
  1736. (long int) resultvar; })
  1737. +# define INTERNAL_SYSCALL_NCS_ASM INTERNAL_SYSCALL_NCS
  1738. +
  1739. # undef INTERNAL_SYSCALL
  1740. -# define INTERNAL_SYSCALL(name, err, nr, args...) \
  1741. - INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
  1742. +# define INTERNAL_SYSCALL(name, err, nr_args...) \
  1743. + INTERNAL_SYSCALL_NCS (__NR_##name, err, ##nr_args)
  1744. +
  1745. +# undef INTERNAL_SYSCALL_ASM
  1746. +# define INTERNAL_SYSCALL_ASM(name, err, nr_args...) \
  1747. + INTERNAL_SYSCALL_NCS_ASM (__NR_##name, err, ##nr_args)
  1748. # define INTERNAL_SYSCALL_NCS_TYPES(name, err, nr, args...) \
  1749. ({ \
  1750. @@ -237,7 +255,7 @@
  1751. LOAD_ARGS_TYPES_##nr (args) \
  1752. LOAD_REGS_TYPES_##nr (args) \
  1753. asm volatile ( \
  1754. - "syscall\n\t" \
  1755. + SYSCALLDB \
  1756. : "=a" (resultvar) \
  1757. : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx"); \
  1758. (long int) resultvar; })
  1759. @@ -252,6 +270,7 @@
  1760. # undef INTERNAL_SYSCALL_ERRNO
  1761. # define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
  1762. +# if 0 /* for Graphene, never do vsyscall */
  1763. # ifdef SHARED
  1764. # define INLINE_VSYSCALL(name, nr, args...) \
  1765. ({ \
  1766. @@ -300,12 +319,13 @@
  1767. v_ret; \
  1768. })
  1769. -# else
  1770. -# define INLINE_VSYSCALL(name, nr, args...) \
  1771. - INLINE_SYSCALL (name, nr, ##args)
  1772. -# define INTERNAL_VSYSCALL(name, err, nr, args...) \
  1773. - INTERNAL_SYSCALL (name, err, nr, ##args)
  1774. # endif
  1775. +# endif
  1776. +
  1777. +# define INLINE_VSYSCALL(name, nr_args...) \
  1778. + INLINE_SYSCALL (name, ##nr_args)
  1779. +# define INTERNAL_VSYSCALL(name, err, nr_args...) \
  1780. + INTERNAL_SYSCALL (name, err, ##nr_args)
  1781. # define LOAD_ARGS_0()
  1782. # define LOAD_REGS_0
  1783. diff --git a/sysdeps/unix/sysv/linux/x86_64/time.c b/sysdeps/unix/sysv/linux/x86_64/time.c
  1784. deleted file mode 100644
  1785. index 79f1fab..0000000
  1786. --- a/sysdeps/unix/sysv/linux/x86_64/time.c
  1787. +++ /dev/null
  1788. @@ -1,60 +0,0 @@
  1789. -/* Copyright (C) 2001-2014 Free Software Foundation, Inc.
  1790. - This file is part of the GNU C Library.
  1791. -
  1792. - The GNU C Library is free software; you can redistribute it and/or
  1793. - modify it under the terms of the GNU Lesser General Public
  1794. - License as published by the Free Software Foundation; either
  1795. - version 2.1 of the License, or (at your option) any later version.
  1796. -
  1797. - The GNU C Library is distributed in the hope that it will be useful,
  1798. - but WITHOUT ANY WARRANTY; without even the implied warranty of
  1799. - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  1800. - Lesser General Public License for more details.
  1801. -
  1802. - You should have received a copy of the GNU Lesser General Public
  1803. - License along with the GNU C Library; if not, see
  1804. - <http://www.gnu.org/licenses/>. */
  1805. -
  1806. -#ifdef SHARED
  1807. -/* Redefine time so that the compiler won't complain about the type
  1808. - mismatch with the IFUNC selector in strong_alias, below. */
  1809. -#undef time
  1810. -#define time __redirect_time
  1811. -#include <time.h>
  1812. -
  1813. -#include <dl-vdso.h>
  1814. -
  1815. -#define VSYSCALL_ADDR_vtime 0xffffffffff600400
  1816. -
  1817. -/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
  1818. - ifunc symbol properly. */
  1819. -extern __typeof (__redirect_time) __libc_time;
  1820. -void *time_ifunc (void) __asm__ ("__libc_time");
  1821. -
  1822. -void *
  1823. -time_ifunc (void)
  1824. -{
  1825. - PREPARE_VERSION (linux26, "LINUX_2.6", 61765110);
  1826. -
  1827. - /* If the vDSO is not available we fall back on the old vsyscall. */
  1828. - return _dl_vdso_vsym ("__vdso_time", &linux26) ?: (void *) VSYSCALL_ADDR_vtime;
  1829. -}
  1830. -__asm (".type __libc_time, %gnu_indirect_function");
  1831. -
  1832. -#undef time
  1833. -strong_alias (__libc_time, time)
  1834. -libc_hidden_ver (__libc_time, time)
  1835. -
  1836. -#else
  1837. -
  1838. -# include <time.h>
  1839. -# include <sysdep.h>
  1840. -
  1841. -time_t
  1842. -time (time_t *t)
  1843. -{
  1844. - INTERNAL_SYSCALL_DECL (err);
  1845. - return INTERNAL_SYSCALL (time, err, 1, t);
  1846. -}
  1847. -
  1848. -#endif
  1849. diff --git a/sysdeps/unix/sysv/linux/x86_64/vfork.S b/sysdeps/unix/sysv/linux/x86_64/vfork.S
  1850. index d3b450a..75a63e1 100644
  1851. --- a/sysdeps/unix/sysv/linux/x86_64/vfork.S
  1852. +++ b/sysdeps/unix/sysv/linux/x86_64/vfork.S
  1853. @@ -38,7 +38,7 @@ ENTRY (__vfork)
  1854. /* Stuff the syscall number in RAX and enter into the kernel. */
  1855. movl $SYS_ify (vfork), %eax
  1856. - syscall
  1857. + SYSCALLDB
  1858. /* Push back the return PC. */
  1859. pushq %rdi
  1860. diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
  1861. index 504c95f..dcfc259 100644
  1862. --- a/sysdeps/x86_64/dl-machine.h
  1863. +++ b/sysdeps/x86_64/dl-machine.h
  1864. @@ -529,7 +529,8 @@ elf_machine_lazy_rel (struct link_map *map,
  1865. value = ((ElfW(Addr) (*) (void)) value) ();
  1866. *reloc_addr = value;
  1867. }
  1868. - else
  1869. + /* for graphene, get around R_X86_64_NONE */
  1870. + else if (__builtin_expect (r_type != R_X86_64_NONE, 1))
  1871. _dl_reloc_bad_type (map, r_type, 1);
  1872. }
  1873. diff --git a/sysdeps/x86_64/hp-timing.h b/sysdeps/x86_64/hp-timing.h
  1874. index d88206c..886c500 100644
  1875. --- a/sysdeps/x86_64/hp-timing.h
  1876. +++ b/sysdeps/x86_64/hp-timing.h
  1877. @@ -18,23 +18,6 @@
  1878. #ifndef _HP_TIMING_H
  1879. -/* We can use some of the i686 implementation without changes. */
  1880. -# include <sysdeps/i386/i686/hp-timing.h>
  1881. -
  1882. -/* The "=A" constraint used in 32-bit mode does not work in 64-bit mode. */
  1883. -# undef HP_TIMING_NOW
  1884. -# define HP_TIMING_NOW(Var) \
  1885. - ({ unsigned int _hi, _lo; \
  1886. - asm volatile ("rdtsc" : "=a" (_lo), "=d" (_hi)); \
  1887. - (Var) = ((unsigned long long int) _hi << 32) | _lo; })
  1888. -
  1889. -/* The funny business for 32-bit mode is not required here. */
  1890. -# undef HP_TIMING_ACCUM
  1891. -# define HP_TIMING_ACCUM(Sum, Diff) \
  1892. - do { \
  1893. - hp_timing_t __diff = (Diff) - GLRO(dl_hp_timing_overhead); \
  1894. - __asm__ __volatile__ ("lock; addq %1, %0" \
  1895. - : "=m" (Sum) : "r" (__diff), "m" (Sum)); \
  1896. - } while (0)
  1897. +# include <sysdeps/generic/hp-timing.h>
  1898. #endif /* hp-timing.h */