glibc-2.17.patch 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911
  1. diff --git a/Makeconfig b/Makeconfig
  2. index 70a3d9d..2c543c3 100644
  3. --- a/Makeconfig
  4. +++ b/Makeconfig
  5. @@ -718,7 +718,8 @@ endif # $(+cflags) == ""
  6. +sysdep-includes = $(addprefix -I,$(+sysdep_dirs))
  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. @@ -987,7 +988,7 @@ all-subdirs = csu assert ctype locale intl catgets math setjmp signal \
  15. stdlib stdio-common libio malloc string wcsmbs time dirent \
  16. grp pwd posix io termios resource misc socket sysvipc gmon \
  17. gnulib iconv iconvdata wctype manual shadow gshadow po argp \
  18. - crypt nss localedata timezone rt conform debug \
  19. + crypt nss localedata timezone rt conform debug libos \
  20. $(add-on-subdirs) dlfcn elf
  21. ifndef avoid-generated
  22. diff --git a/Makefile b/Makefile
  23. index 6c1e392..3df0ac6 100644
  24. --- a/Makefile
  25. +++ b/Makefile
  26. @@ -197,6 +197,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 3c9e0ae..034ab2b 100644
  35. --- a/Versions.def
  36. +++ b/Versions.def
  37. @@ -39,6 +39,7 @@ libc {
  38. GCC_3.0
  39. %endif
  40. GLIBC_PRIVATE
  41. + SHIM
  42. }
  43. libcrypt {
  44. GLIBC_2.0
  45. @@ -48,6 +49,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. @@ -100,6 +102,7 @@ libpthread {
  54. GLIBC_2.11
  55. GLIBC_2.12
  56. GLIBC_PRIVATE
  57. + SHIM
  58. }
  59. libresolv {
  60. GLIBC_2.0
  61. @@ -127,6 +130,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. @@ -140,3 +144,6 @@ libanl {
  70. libcidn {
  71. GLIBC_PRIVATE
  72. }
  73. +liblibos {
  74. + GLIBC_2.12
  75. +}
  76. diff --git a/configure b/configure
  77. index 8799b7d..22e4c2c 100755
  78. --- a/configure
  79. +++ b/configure
  80. @@ -636,7 +636,8 @@ SED
  81. MAKEINFO
  82. MSGFMT
  83. MAKE
  84. -LD
  85. +LD_GOLD
  86. +LD_BFD
  87. AS
  88. MIG
  89. OBJCOPY
  90. @@ -4792,17 +4793,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. @@ -4811,7 +4817,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. @@ -4821,26 +4827,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. @@ -4852,9 +4858,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. @@ -6670,6 +6747,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. @@ -6688,6 +6775,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/configure.in b/configure.in
  269. index d369382..38ff3cd 100644
  270. --- a/configure.in
  271. +++ b/configure.in
  272. @@ -924,9 +924,25 @@ AC_SUBST(MIG)dnl Needed by sysdeps/mach/configure.in
  273. AC_CHECK_PROG_VER(AS, $AS, --version,
  274. [GNU assembler.* \([0-9]*\.[0-9.]*\)],
  275. [2.1[0-9][0-9]*|2.[2-9][0-9]*|[3-9].*|[1-9][0-9]*], AS=: critic_missing="$critic_missing as")
  276. -AC_CHECK_PROG_VER(LD, $LD, --version,
  277. +LD_BFD=
  278. +LD_GOLD=
  279. +ld_is_gold="`$LD --version | sed -n 's/^GNU \(gold\).*$/\1/p'`"
  280. +if test -z "$ld_is_gold"; then
  281. + LD_BFD=$LD
  282. + AC_CHECK_PROG_VER(LD_BFD, $LD_BFD, --version,
  283. [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
  284. - [2.1[0-9][0-9]*|2.[2-9][0-9]*|[3-9].*|[1-9][0-9]*], LD=: critic_missing="$critic_missing ld")
  285. + [2.1[0-9][0-9]*|2.[2-9][0-9]*|[3-9].*|[1-9][0-9]*],LD_BFD=:)
  286. +else
  287. +# Accept gold 1.11 or higher.
  288. + LD_GOLD=$LD
  289. + AC_CHECK_PROG_VER(LD_GOLD, $LD_GOLD, --version,
  290. + [GNU gold.* \([0-9][0-9]*\.[0-9.]*\)],
  291. + [1.1[1-9]*|1.[2-9][0-9]*|1.1[0-9][0-9]*|[2-9].*|[1-9][0-9]*],LD_GOLD=:)
  292. +fi
  293. +# Neither ld nor gold are new enough.
  294. +if test -z "$LD_BFD" && test -z "$LD_GOLD"; then
  295. + critic_missing="$critic_missing ld"
  296. +fi
  297. # These programs are version sensitive.
  298. AC_CHECK_TOOL_PREFIX
  299. @@ -1635,6 +1651,16 @@ $ac_try"
  300. use_default_link=$libc_cv_use_default_link
  301. fi
  302. +# The gold linker has no builtin default linker script,
  303. +# and the fallback of editing the builtin linker
  304. +# script is not available. Therefore if use_default_link
  305. +# is `no' then we can't use gold. This check is independent
  306. +# of gold's version and is used to sanity check that the
  307. +# linker continues to produce a useful shared link.
  308. +if test "$ld_is_gold" && test "$use_default_link" = "no"; then
  309. + AC_MSG_ERROR([$LD did not generate a useful shared link. Try using GNU ld.bfd?])
  310. +fi
  311. +
  312. AC_CACHE_CHECK(linker output format, libc_cv_output_format, [dnl
  313. if libc_cv_output_format=`
  314. ${CC-cc} -nostartfiles -nostdlib -Wl,--print-output-format 2>&AS_MESSAGE_LOG_FD`
  315. @@ -1646,6 +1672,17 @@ fi
  316. test -n "$libc_cv_output_format" || libc_cv_output_format=unknown])
  317. AC_SUBST(libc_cv_output_format)
  318. +# The gold linker has no builtin default linker script,
  319. +# and the fallback of parsing the builtin linker
  320. +# script to determine the target is not available.
  321. +# Therefore if libc_cv_output_format is `unknown' then
  322. +# we can't use gold. This check is independent of gold's
  323. +# version and is used to sanity check that the linker
  324. +# continues to support --print-output-format.
  325. +if test "$ld_is_gold" && test "$libc_cv_output_format" = "unknown"; then
  326. + AC_MSG_ERROR([$LD did not support --print-output-format. Try using GNU ld.bfd?])
  327. +fi
  328. +
  329. AC_CACHE_CHECK(for -fno-toplevel-reorder -fno-section-anchors, libc_cv_fno_toplevel_reorder, [dnl
  330. cat > conftest.c <<EOF
  331. int foo;
  332. diff --git a/dlfcn/Versions b/dlfcn/Versions
  333. index 97902f0..c1874c1 100644
  334. --- a/dlfcn/Versions
  335. +++ b/dlfcn/Versions
  336. @@ -14,4 +14,7 @@ libdl {
  337. GLIBC_PRIVATE {
  338. _dlfcn_hook;
  339. }
  340. + SHIM {
  341. + syscalldb;
  342. + }
  343. }
  344. diff --git a/elf/Makefile b/elf/Makefile
  345. index 6c7bc97..b51a799 100644
  346. --- a/elf/Makefile
  347. +++ b/elf/Makefile
  348. @@ -21,7 +21,7 @@ subdir := elf
  349. include ../Makeconfig
  350. -headers = elf.h bits/elfclass.h link.h bits/link.h
  351. +headers = elf.h bits/elfclass.h link.h bits/link.h syscalldb.h
  352. routines = $(dl-routines) dl-support dl-iteratephdr \
  353. dl-addr enbl-secure dl-profstub \
  354. dl-origin dl-libc dl-sym dl-tsd dl-sysdep
  355. @@ -31,7 +31,8 @@ routines = $(dl-routines) dl-support dl-iteratephdr \
  356. dl-routines = $(addprefix dl-,load lookup object reloc deps hwcaps \
  357. runtime error init fini debug misc \
  358. version profile conflict tls origin scope \
  359. - execstack caller open close trampoline)
  360. + execstack caller open close trampoline) \
  361. + syscalldb syscallas
  362. ifeq (yes,$(use-ldconfig))
  363. dl-routines += dl-cache
  364. endif
  365. diff --git a/elf/Versions b/elf/Versions
  366. index 87e27c5..a0e345b 100644
  367. --- a/elf/Versions
  368. +++ b/elf/Versions
  369. @@ -24,14 +24,15 @@ libc {
  370. _dl_open_hook;
  371. __libc_dlopen_mode; __libc_dlsym; __libc_dlclose;
  372. }
  373. + SHIM {
  374. + syscalldb;
  375. + }
  376. }
  377. ld {
  378. GLIBC_2.0 {
  379. # Function from libc.so which must be shared with libc.
  380. calloc; free; malloc; realloc; __libc_memalign;
  381. -
  382. - _r_debug;
  383. }
  384. GLIBC_2.1 {
  385. # functions used in other libraries
  386. @@ -59,8 +60,11 @@ ld {
  387. _dl_tls_setup; _dl_rtld_di_serinfo;
  388. _dl_make_stack_executable;
  389. # Only here for gdb while a better method is developed.
  390. - _dl_debug_state;
  391. + __libc_r_debug; __libc_dl_debug_state;
  392. # Pointer protection.
  393. __pointer_chk_guard;
  394. }
  395. + SHIM {
  396. + syscalldb; glibc_vers_2_17; register_library;
  397. + }
  398. }
  399. diff --git a/elf/circleload1.c b/elf/circleload1.c
  400. index 990ff84..ccf92d3 100644
  401. --- a/elf/circleload1.c
  402. +++ b/elf/circleload1.c
  403. @@ -5,7 +5,7 @@
  404. #include <stdlib.h>
  405. #include <string.h>
  406. -#define MAPS ((struct link_map *) _r_debug.r_map)
  407. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  408. static int
  409. check_loaded_objects (const char **loaded)
  410. diff --git a/elf/dl-close.c b/elf/dl-close.c
  411. index cda0e71..580e1e2 100644
  412. --- a/elf/dl-close.c
  413. +++ b/elf/dl-close.c
  414. @@ -468,7 +468,7 @@ _dl_close_worker (struct link_map *map)
  415. /* Notify the debugger we are about to remove some loaded objects. */
  416. struct r_debug *r = _dl_debug_initialize (0, nsid);
  417. r->r_state = RT_DELETE;
  418. - _dl_debug_state ();
  419. + __libc_dl_debug_state ();
  420. LIBC_PROBE (unmap_start, 2, nsid, r);
  421. if (unload_global)
  422. @@ -742,7 +742,7 @@ _dl_close_worker (struct link_map *map)
  423. /* Notify the debugger those objects are finalized and gone. */
  424. r->r_state = RT_CONSISTENT;
  425. - _dl_debug_state ();
  426. + __libc_dl_debug_state ();
  427. LIBC_PROBE (unmap_complete, 2, nsid, r);
  428. /* Recheck if we need to retry, release the lock. */
  429. diff --git a/elf/dl-debug.c b/elf/dl-debug.c
  430. index 4106e42..b95bd27 100644
  431. --- a/elf/dl-debug.c
  432. +++ b/elf/dl-debug.c
  433. @@ -35,7 +35,7 @@ extern const int verify_link_map_members[(VERIFY_MEMBER (l_addr)
  434. normally finds it via the DT_DEBUG entry in the dynamic section, but in
  435. a statically-linked program there is no dynamic section for the debugger
  436. to examine and it looks for this particular symbol name. */
  437. -struct r_debug _r_debug;
  438. +struct r_debug __libc_r_debug __attribute__((weak));
  439. /* Initialize _r_debug if it has not already been done. The argument is
  440. @@ -49,7 +49,7 @@ _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns)
  441. struct r_debug *r;
  442. if (ns == LM_ID_BASE)
  443. - r = &_r_debug;
  444. + r = &__libc_r_debug;
  445. else
  446. r = &GL(dl_ns)[ns]._ns_debug;
  447. @@ -57,9 +57,9 @@ _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns)
  448. {
  449. /* Tell the debugger where to find the map of loaded objects. */
  450. r->r_version = 1 /* R_DEBUG_VERSION XXX */;
  451. - r->r_ldbase = ldbase ?: _r_debug.r_ldbase;
  452. + r->r_ldbase = ldbase ?: __libc_r_debug.r_ldbase;
  453. r->r_map = (void *) GL(dl_ns)[ns]._ns_loaded;
  454. - r->r_brk = (ElfW(Addr)) &_dl_debug_state;
  455. + r->r_brk = (ElfW(Addr)) &__libc_dl_debug_state;
  456. }
  457. return r;
  458. @@ -71,7 +71,7 @@ _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns)
  459. examining the r_brk member of struct r_debug, but GDB 4.15 in fact looks
  460. for this particular symbol name in the PT_INTERP file. */
  461. void
  462. -_dl_debug_state (void)
  463. +__libc_dl_debug_state (void)
  464. {
  465. }
  466. -rtld_hidden_def (_dl_debug_state)
  467. +__attribute__((weak));
  468. diff --git a/elf/dl-load.c b/elf/dl-load.c
  469. index 70fe78f..4ec655a 100644
  470. --- a/elf/dl-load.c
  471. +++ b/elf/dl-load.c
  472. @@ -39,6 +39,8 @@
  473. #include <dl-dst.h>
  474. +#include <glibc-version.h>
  475. +
  476. /* On some systems, no flag bits are given to specify file mapping. */
  477. #ifndef MAP_FILE
  478. # define MAP_FILE 0
  479. @@ -896,7 +898,7 @@ lose (int code, int fd, const char *name, char *realname, struct link_map *l,
  480. if (r != NULL)
  481. {
  482. r->r_state = RT_CONSISTENT;
  483. - _dl_debug_state ();
  484. + __libc_dl_debug_state ();
  485. LIBC_PROBE (map_failed, 2, nsid, r);
  486. }
  487. @@ -1042,7 +1044,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
  488. call _dl_debug_initialize in a static program in case dynamic
  489. linking has not been used before. */
  490. r->r_state = RT_ADD;
  491. - _dl_debug_state ();
  492. + __libc_dl_debug_state ();
  493. LIBC_PROBE (map_start, 2, nsid, r);
  494. make_consistent = true;
  495. }
  496. @@ -1585,6 +1587,9 @@ cannot enable executable stack as shared object requires");
  497. DL_AFTER_LOAD (l);
  498. #endif
  499. + /* register the library to SHIM */
  500. + register_library(l->l_name, l->l_addr);
  501. +
  502. /* Now that the object is fully initialized add it to the object list. */
  503. _dl_add_to_namespace_list (l, nsid);
  504. diff --git a/elf/dl-open.c b/elf/dl-open.c
  505. index 9c39a34..a21f51e 100644
  506. --- a/elf/dl-open.c
  507. +++ b/elf/dl-open.c
  508. @@ -294,7 +294,7 @@ dl_open_worker (void *a)
  509. /* Notify the debugger all new objects are now ready to go. */
  510. struct r_debug *r = _dl_debug_initialize (0, args->nsid);
  511. r->r_state = RT_CONSISTENT;
  512. - _dl_debug_state ();
  513. + __libc_dl_debug_state ();
  514. LIBC_PROBE (map_complete, 3, args->nsid, r, new);
  515. /* Print scope information. */
  516. diff --git a/elf/link.h b/elf/link.h
  517. index 11136cc..db5c4e3 100644
  518. --- a/elf/link.h
  519. +++ b/elf/link.h
  520. @@ -64,7 +64,7 @@ struct r_debug
  521. };
  522. /* This is the instance of that structure used by the dynamic linker. */
  523. -extern struct r_debug _r_debug;
  524. +extern struct r_debug __libc_r_debug;
  525. /* This symbol refers to the "dynamic structure" in the `.dynamic' section
  526. of whatever module refers to `_DYNAMIC'. So, to find its own
  527. diff --git a/elf/loadtest.c b/elf/loadtest.c
  528. index 727469b..568ddef 100644
  529. --- a/elf/loadtest.c
  530. +++ b/elf/loadtest.c
  531. @@ -70,7 +70,7 @@ static const struct
  532. #include <include/link.h>
  533. -#define MAPS ((struct link_map *) _r_debug.r_map)
  534. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  535. #define OUT \
  536. for (map = MAPS; map != NULL; map = map->l_next) \
  537. diff --git a/elf/neededtest.c b/elf/neededtest.c
  538. index 3cea499..e098d48 100644
  539. --- a/elf/neededtest.c
  540. +++ b/elf/neededtest.c
  541. @@ -5,7 +5,7 @@
  542. #include <stdlib.h>
  543. #include <string.h>
  544. -#define MAPS ((struct link_map *) _r_debug.r_map)
  545. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  546. static int
  547. check_loaded_objects (const char **loaded)
  548. diff --git a/elf/neededtest2.c b/elf/neededtest2.c
  549. index 17c75f2..5a73a95 100644
  550. --- a/elf/neededtest2.c
  551. +++ b/elf/neededtest2.c
  552. @@ -5,7 +5,7 @@
  553. #include <stdlib.h>
  554. #include <string.h>
  555. -#define MAPS ((struct link_map *) _r_debug.r_map)
  556. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  557. static int
  558. check_loaded_objects (const char **loaded)
  559. diff --git a/elf/neededtest3.c b/elf/neededtest3.c
  560. index 41970cf..5126615 100644
  561. --- a/elf/neededtest3.c
  562. +++ b/elf/neededtest3.c
  563. @@ -5,7 +5,7 @@
  564. #include <stdlib.h>
  565. #include <string.h>
  566. -#define MAPS ((struct link_map *) _r_debug.r_map)
  567. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  568. static int
  569. check_loaded_objects (const char **loaded)
  570. diff --git a/elf/neededtest4.c b/elf/neededtest4.c
  571. index 0ae0b7f..f883910 100644
  572. --- a/elf/neededtest4.c
  573. +++ b/elf/neededtest4.c
  574. @@ -5,7 +5,7 @@
  575. #include <stdlib.h>
  576. #include <string.h>
  577. -#define MAPS ((struct link_map *) _r_debug.r_map)
  578. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  579. static int
  580. check_loaded_objects (const char **loaded)
  581. diff --git a/elf/rtld.c b/elf/rtld.c
  582. index b0126e5..2fb4fe9 100644
  583. --- a/elf/rtld.c
  584. +++ b/elf/rtld.c
  585. @@ -356,6 +356,23 @@ _dl_start_final (void *arg, struct dl_start_final_info *info)
  586. return start_addr;
  587. }
  588. +/* For graphene, check if glibc version match to the compatible SHIM
  589. + library. If not, tell the user to update glibc. */
  590. +#include "glibc-version.h"
  591. +
  592. +volatile const int glibc_vers_2_17 __attribute__((weak)) = GLIBC_VERSION_2_17;
  593. +
  594. +static void __attribute__((noinline,optimize("-O0")))
  595. +check_glibc_version (void)
  596. +{
  597. + if (glibc_vers_2_17 != GLIBC_VERSION_2_17)
  598. + {
  599. + _dl_fatal_printf ("Warning from Graphene: "
  600. + "Glibc version is incorrect. Please rebuild Glibc.\n");
  601. + _exit (1);
  602. + }
  603. +}
  604. +
  605. static ElfW(Addr) __attribute_used__ internal_function
  606. _dl_start (void *arg)
  607. {
  608. @@ -546,6 +563,9 @@ _dl_start (void *arg)
  609. therefore need not test whether we have to allocate the array
  610. for the relocation results (as done in dl-reloc.c). */
  611. + /* For Graphene, check if the glibc version is correct. */
  612. + check_glibc_version();
  613. +
  614. /* Now life is sane; we can call functions and access global data.
  615. Set up to use the operating system facilities, and find out from
  616. the operating system's program loader where to find the program
  617. @@ -1230,9 +1250,20 @@ of this helper program; chances are you did not intend to run this program.\n\
  618. main_map->l_map_end = allocend;
  619. if ((ph->p_flags & PF_X) && allocend > main_map->l_text_end)
  620. main_map->l_text_end = allocend;
  621. +
  622. +#if 0
  623. + ElfW(Addr) mapend = (allocend + GLRO(dl_pagesize) - 1)
  624. + & ~(GLRO(dl_pagesize) - 1);
  625. + int prot = ((ph->p_flags & PF_R) ? PROT_READ : 0)|
  626. + ((ph->p_flags & PF_W) ? PROT_WRITE : 0)|
  627. + ((ph->p_flags & PF_X) ? PROT_EXEC : 0);
  628. + __mmap ((void *) mapstart, mapend - mapstart,
  629. + prot,
  630. + MAP_ANON|MAP_PRIVATE|MAP_FIXED|0x20000000,
  631. + -1, 0);
  632. +#endif
  633. }
  634. break;
  635. -
  636. case PT_TLS:
  637. if (ph->p_memsz > 0)
  638. {
  639. @@ -1378,13 +1409,31 @@ of this helper program; chances are you did not intend to run this program.\n\
  640. /* PT_GNU_RELRO is usually the last phdr. */
  641. size_t cnt = rtld_ehdr->e_phnum;
  642. while (cnt-- > 0)
  643. + {
  644. if (rtld_phdr[cnt].p_type == PT_GNU_RELRO)
  645. {
  646. GL(dl_rtld_map).l_relro_addr = rtld_phdr[cnt].p_vaddr;
  647. GL(dl_rtld_map).l_relro_size = rtld_phdr[cnt].p_memsz;
  648. - break;
  649. }
  650. +#if 0
  651. + if (rtld_phdr[cnt].p_type == PT_LOAD)
  652. + {
  653. + ElfW(Addr) mapstart = rtld_phdr[cnt].p_vaddr & ~(GLRO(dl_pagesize) - 1);
  654. + ElfW(Addr) mapend = (rtld_phdr[cnt].p_vaddr + rtld_phdr[cnt].p_memsz
  655. + + GLRO(dl_pagesize) - 1)
  656. + & ~(GLRO(dl_pagesize) - 1);
  657. + int prot = ((rtld_phdr[cnt].p_flags & PF_R) ? PROT_READ : 0)|
  658. + ((rtld_phdr[cnt].p_flags & PF_W) ? PROT_WRITE : 0)|
  659. + ((rtld_phdr[cnt].p_flags & PF_X) ? PROT_EXEC : 0);
  660. + __mmap ((void *) mapstart, mapend - mapstart,
  661. + prot,
  662. + MAP_ANON|MAP_PRIVATE|MAP_FIXED|0x20000000,
  663. + -1, 0);
  664. + }
  665. +#endif
  666. + }
  667. +
  668. /* Add the dynamic linker to the TLS list if it also uses TLS. */
  669. if (GL(dl_rtld_map).l_tls_blocksize != 0)
  670. /* Assign a module ID. Do this before loading any audit modules. */
  671. @@ -1585,7 +1634,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
  672. /* We start adding objects. */
  673. r->r_state = RT_ADD;
  674. - _dl_debug_state ();
  675. + __libc_dl_debug_state ();
  676. LIBC_PROBE (init_start, 2, LM_ID_BASE, r);
  677. /* Auditing checkpoint: we are ready to signal that the initial map
  678. @@ -2305,7 +2354,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
  679. the address since by now the variable might be in another object. */
  680. r = _dl_debug_initialize (0, LM_ID_BASE);
  681. r->r_state = RT_CONSISTENT;
  682. - _dl_debug_state ();
  683. + __libc_dl_debug_state ();
  684. LIBC_PROBE (init_complete, 2, LM_ID_BASE, r);
  685. #if defined USE_LDCONFIG && !defined MAP_COPY
  686. diff --git a/elf/unload.c b/elf/unload.c
  687. index 4566f22..73046de 100644
  688. --- a/elf/unload.c
  689. +++ b/elf/unload.c
  690. @@ -9,7 +9,7 @@
  691. #include <stdio.h>
  692. #include <stdlib.h>
  693. -#define MAPS ((struct link_map *) _r_debug.r_map)
  694. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  695. #define OUT \
  696. for (map = MAPS; map != NULL; map = map->l_next) \
  697. diff --git a/elf/unload2.c b/elf/unload2.c
  698. index eef2bfd..a21d2ac 100644
  699. --- a/elf/unload2.c
  700. +++ b/elf/unload2.c
  701. @@ -6,7 +6,7 @@
  702. #include <stdio.h>
  703. #include <stdlib.h>
  704. -#define MAPS ((struct link_map *) _r_debug.r_map)
  705. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  706. #define OUT \
  707. for (map = MAPS; map != NULL; map = map->l_next) \
  708. diff --git a/nptl/Makefile b/nptl/Makefile
  709. index e33432e..8ec263f 100644
  710. --- a/nptl/Makefile
  711. +++ b/nptl/Makefile
  712. @@ -20,7 +20,7 @@
  713. #
  714. subdir := nptl
  715. -headers := pthread.h semaphore.h bits/semaphore.h
  716. +headers := pthread.h semaphore.h bits/semaphore.h syscalldb.h
  717. extra-libs := libpthread
  718. extra-libs-others := $(extra-libs)
  719. diff --git a/nptl/Versions b/nptl/Versions
  720. index 6a10375..4a1eb35 100644
  721. --- a/nptl/Versions
  722. +++ b/nptl/Versions
  723. @@ -31,6 +31,9 @@ libc {
  724. # Internal libc interface to libpthread
  725. __libc_dl_error_tsd;
  726. }
  727. + SHIM {
  728. + syscalldb;
  729. + }
  730. }
  731. libpthread {
  732. @@ -257,4 +260,8 @@ libpthread {
  733. __pthread_clock_gettime; __pthread_clock_settime;
  734. __pthread_unwind; __pthread_get_minstack;
  735. }
  736. +
  737. + SHIM {
  738. + syscalldb;
  739. + }
  740. }
  741. diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
  742. index 197dfa7..6cf8fa6 100644
  743. --- a/nptl/pthread_create.c
  744. +++ b/nptl/pthread_create.c
  745. @@ -398,8 +398,11 @@ start_thread (void *arg)
  746. # error "to do"
  747. #endif
  748. assert (freesize < pd->stackblock_size);
  749. + /* XXX: may not be necessary */
  750. +#if 0
  751. if (freesize > PTHREAD_STACK_MIN)
  752. __madvise (pd->stackblock, freesize - PTHREAD_STACK_MIN, MADV_DONTNEED);
  753. +#endif
  754. /* If the thread is detached free the TCB. */
  755. if (IS_DETACHED (pd))
  756. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S b/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S
  757. index 31bb08b..4729064 100644
  758. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S
  759. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S
  760. @@ -111,7 +111,8 @@ ENTRY(__pthread_disable_asynccancel)
  761. xorq %r10, %r10
  762. addq $CANCELHANDLING, %rdi
  763. LOAD_PRIVATE_FUTEX_WAIT (%esi)
  764. - syscall
  765. + SYSCALL
  766. +
  767. movl %fs:CANCELHANDLING, %eax
  768. jmp 3b
  769. END(__pthread_disable_asynccancel)
  770. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/fork.c b/nptl/sysdeps/unix/sysv/linux/x86_64/fork.c
  771. index dedbabd..5bd873e 100644
  772. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/fork.c
  773. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/fork.c
  774. @@ -21,10 +21,20 @@
  775. #include <sysdep.h>
  776. #include <tls.h>
  777. -
  778. -#define ARCH_FORK() \
  779. +/* In Graphene, we prefer to call fork system call directly than clone */
  780. +#if USE_clone_FOR_fork
  781. +# define ARCH_FORK() \
  782. INLINE_SYSCALL (clone, 4, \
  783. CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD, 0, \
  784. NULL, &THREAD_SELF->tid)
  785. +#else
  786. +# define ARCH_FORK() \
  787. + ({ unsigned long ret = INLINE_SYSCALL (fork, 0); \
  788. + if (!ret) { \
  789. + pid_t pid = INLINE_SYSCALL (getpid, 0); \
  790. + THREAD_SETMEM (THREAD_SELF, pid, pid); \
  791. + THREAD_SETMEM (THREAD_SELF, tid, pid); \
  792. + } ret; })
  793. +#endif
  794. #include "../fork.c"
  795. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
  796. index dc95421..a772f66 100644
  797. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
  798. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
  799. @@ -90,7 +90,7 @@ __lll_lock_wait_private:
  800. 1: LIBC_PROBE (lll_lock_wait_private, 1, %rdi)
  801. movl $SYS_futex, %eax
  802. - syscall
  803. + SYSCALL
  804. 2: movl %edx, %eax
  805. xchgl %eax, (%rdi) /* NB: lock is implied */
  806. @@ -130,7 +130,7 @@ __lll_lock_wait:
  807. 1: LIBC_PROBE (lll_lock_wait, 2, %rdi, %rsi)
  808. movl $SYS_futex, %eax
  809. - syscall
  810. + SYSCALL
  811. 2: movl %edx, %eax
  812. xchgl %eax, (%rdi) /* NB: lock is implied */
  813. @@ -185,7 +185,7 @@ __lll_timedlock_wait:
  814. 1: movl $SYS_futex, %eax
  815. movl $2, %edx
  816. - syscall
  817. + SYSCALL
  818. 2: xchgl %edx, (%rdi) /* NB: lock is implied */
  819. @@ -279,7 +279,7 @@ __lll_timedlock_wait:
  820. LOAD_FUTEX_WAIT (%esi)
  821. movq %r12, %rdi
  822. movl $SYS_futex, %eax
  823. - syscall
  824. + SYSCALL
  825. /* NB: %edx == 2 */
  826. xchgl %edx, (%r12)
  827. @@ -336,7 +336,7 @@ __lll_unlock_wake_private:
  828. LOAD_PRIVATE_FUTEX_WAKE (%esi)
  829. movl $1, %edx /* Wake one thread. */
  830. movl $SYS_futex, %eax
  831. - syscall
  832. + SYSCALL
  833. popq %rdx
  834. cfi_adjust_cfa_offset(-8)
  835. @@ -366,7 +366,7 @@ __lll_unlock_wake:
  836. LOAD_FUTEX_WAKE (%esi)
  837. movl $1, %edx /* Wake one thread. */
  838. movl $SYS_futex, %eax
  839. - syscall
  840. + SYSCALL
  841. popq %rdx
  842. cfi_adjust_cfa_offset(-8)
  843. @@ -435,7 +435,7 @@ __lll_timedwait_tid:
  844. #endif
  845. movq %r12, %rdi
  846. movl $SYS_futex, %eax
  847. - syscall
  848. + SYSCALL
  849. cmpl $0, (%rdi)
  850. jne 1f
  851. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
  852. index 5a80ddd..f7319ca 100644
  853. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
  854. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
  855. @@ -214,7 +214,7 @@ LLL_STUB_UNWIND_INFO_END
  856. register const struct timespec *__to __asm ("r10") = timeout; \
  857. int __status; \
  858. register __typeof (val) _val __asm ("edx") = (val); \
  859. - __asm __volatile ("syscall" \
  860. + __asm __volatile (SYSCALLDB \
  861. : "=a" (__status) \
  862. : "0" (SYS_futex), "D" (futex), \
  863. "S" (__lll_private_flag (FUTEX_WAIT, private)), \
  864. @@ -229,7 +229,7 @@ LLL_STUB_UNWIND_INFO_END
  865. int __ignore; \
  866. register __typeof (nr) _nr __asm ("edx") = (nr); \
  867. LIBC_PROBE (lll_futex_wake, 3, futex, nr, private); \
  868. - __asm __volatile ("syscall" \
  869. + __asm __volatile (SYSCALLDB \
  870. : "=a" (__ignore) \
  871. : "0" (SYS_futex), "D" (futex), \
  872. "S" (__lll_private_flag (FUTEX_WAKE, private)), \
  873. @@ -532,7 +532,7 @@ LLL_STUB_UNWIND_INFO_END
  874. { \
  875. int ignore; \
  876. __asm __volatile (LOCK_INSTR "orl %3, (%2)\n\t" \
  877. - "syscall" \
  878. + SYSCALLDB \
  879. : "=m" (futex), "=a" (ignore) \
  880. : "D" (&(futex)), "i" (FUTEX_OWNER_DIED), \
  881. "S" (__lll_private_flag (FUTEX_WAKE, private)), \
  882. @@ -547,7 +547,7 @@ LLL_STUB_UNWIND_INFO_END
  883. register int __nr_move __asm ("r10") = nr_move; \
  884. register void *__mutex __asm ("r8") = mutex; \
  885. register int __val __asm ("r9") = val; \
  886. - __asm __volatile ("syscall" \
  887. + __asm __volatile (SYSCALLDB \
  888. : "=a" (__res) \
  889. : "0" (__NR_futex), "D" ((void *) ftx), \
  890. "S" (__lll_private_flag (FUTEX_CMP_REQUEUE, \
  891. @@ -573,7 +573,7 @@ LLL_STUB_UNWIND_INFO_END
  892. if (_tid != 0) \
  893. __asm __volatile ("xorq %%r10, %%r10\n\t" \
  894. "1:\tmovq %2, %%rax\n\t" \
  895. - "syscall\n\t" \
  896. + SYSCALLDB \
  897. "cmpl $0, (%%rdi)\n\t" \
  898. "jne 1b" \
  899. : "=&a" (__ignore) \
  900. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
  901. index 0b4ef71..36c5572 100644
  902. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
  903. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
  904. @@ -80,7 +80,7 @@ __lll_robust_lock_wait:
  905. jnz 2f
  906. 1: movl $SYS_futex, %eax
  907. - syscall
  908. + SYSCALL
  909. movl (%rdi), %eax
  910. @@ -145,7 +145,7 @@ __lll_robust_timedlock_wait:
  911. jnz 6f
  912. 5: movl $SYS_futex, %eax
  913. - syscall
  914. + SYSCALL
  915. movl %eax, %ecx
  916. movl (%rdi), %eax
  917. @@ -257,7 +257,7 @@ __lll_robust_timedlock_wait:
  918. LOAD_FUTEX_WAIT (%esi)
  919. movq %r12, %rdi
  920. movl $SYS_futex, %eax
  921. - syscall
  922. + SYSCALL
  923. movq %rax, %rcx
  924. movl (%r12), %eax
  925. 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
  926. index 61c2f54..e70362c 100644
  927. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S
  928. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S
  929. @@ -62,7 +62,7 @@ pthread_barrier_wait:
  930. #endif
  931. xorq %r10, %r10
  932. 8: movl $SYS_futex, %eax
  933. - syscall
  934. + SYSCALL
  935. /* Don't return on spurious wakeups. The syscall does not change
  936. any register except %eax so there is no need to reload any of
  937. @@ -109,7 +109,7 @@ pthread_barrier_wait:
  938. movl $FUTEX_WAKE, %esi
  939. orl PRIVATE(%rdi), %esi
  940. movl $SYS_futex, %eax
  941. - syscall
  942. + SYSCALL
  943. /* Increment LEFT. If this brings the count back to the
  944. initial count unlock the object. */
  945. 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
  946. index 67ff5fc..a95f808 100644
  947. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
  948. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
  949. @@ -90,7 +90,7 @@ __pthread_cond_broadcast:
  950. movl $SYS_futex, %eax
  951. movl $1, %edx
  952. movl $0x7fffffff, %r10d
  953. - syscall
  954. + SYSCALL
  955. /* For any kind of error, which mainly is EAGAIN, we try again
  956. with WAKE. The general test also covers running on old
  957. @@ -106,7 +106,7 @@ __pthread_cond_broadcast:
  958. movl $SYS_futex, %eax
  959. movl $1, %edx
  960. movl $0x7fffffff, %r10d
  961. - syscall
  962. + SYSCALL
  963. /* For any kind of error, which mainly is EAGAIN, we try again
  964. with WAKE. The general test also covers running on old
  965. @@ -172,7 +172,7 @@ __pthread_cond_broadcast:
  966. orl $FUTEX_WAKE, %esi
  967. #endif
  968. movl $SYS_futex, %eax
  969. - syscall
  970. + SYSCALL
  971. jmp 10b
  972. .size __pthread_cond_broadcast, .-__pthread_cond_broadcast
  973. versioned_symbol (libpthread, __pthread_cond_broadcast, pthread_cond_broadcast,
  974. 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
  975. index 3bff19b..80f4b47 100644
  976. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
  977. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
  978. @@ -82,7 +82,7 @@ __pthread_cond_signal:
  979. addq $cond_lock, %r8
  980. #endif
  981. movl $FUTEX_OP_CLEAR_WAKE_IF_GT_ONE, %r9d
  982. - syscall
  983. + SYSCALL
  984. #if cond_lock != 0
  985. subq $cond_lock, %r8
  986. #endif
  987. @@ -99,7 +99,7 @@ __pthread_cond_signal:
  988. movq %rcx, %r8
  989. xorq %r10, %r10
  990. movl (%rdi), %r9d // XXX Can this be right?
  991. - syscall
  992. + SYSCALL
  993. leaq -cond_futex(%rdi), %r8
  994. @@ -118,7 +118,7 @@ __pthread_cond_signal:
  995. movl $SYS_futex, %eax
  996. /* %rdx should be 1 already from $FUTEX_WAKE_OP syscall.
  997. movl $1, %edx */
  998. - syscall
  999. + SYSCALL
  1000. /* Unlock. */
  1001. 4: LOCK
  1002. 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
  1003. index 15e451a..14b768a 100644
  1004. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
  1005. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
  1006. @@ -188,7 +188,7 @@ __pthread_cond_timedwait:
  1007. movq %r12, %rdx
  1008. addq $cond_futex, %rdi
  1009. movl $SYS_futex, %eax
  1010. - syscall
  1011. + SYSCALL
  1012. cmpl $0, %eax
  1013. sete %r15b
  1014. @@ -234,7 +234,7 @@ __pthread_cond_timedwait:
  1015. movq %r12, %rdx
  1016. addq $cond_futex, %rdi
  1017. movl $SYS_futex, %eax
  1018. - syscall
  1019. + SYSCALL
  1020. 62: movq %rax, %r14
  1021. movl (%rsp), %edi
  1022. @@ -321,7 +321,7 @@ __pthread_cond_timedwait:
  1023. orl $FUTEX_WAKE, %esi
  1024. #endif
  1025. movl $SYS_futex, %eax
  1026. - syscall
  1027. + SYSCALL
  1028. subq $cond_nwaiters, %rdi
  1029. 55: LOCK
  1030. @@ -485,15 +485,8 @@ __pthread_cond_timedwait:
  1031. /* Only clocks 0 and 1 are allowed so far. Both are handled in the
  1032. kernel. */
  1033. leaq 32(%rsp), %rsi
  1034. -# ifdef SHARED
  1035. - mov __vdso_clock_gettime@GOTPCREL(%rip), %RAX_LP
  1036. - mov (%rax), %RAX_LP
  1037. - PTR_DEMANGLE (%RAX_LP)
  1038. - call *%rax
  1039. -# else
  1040. movl $__NR_clock_gettime, %eax
  1041. - syscall
  1042. -# endif
  1043. + SYSCALL
  1044. /* Compute relative timeout. */
  1045. movq (%r13), %rcx
  1046. @@ -560,7 +553,7 @@ __pthread_cond_timedwait:
  1047. # endif
  1048. addq $cond_futex, %rdi
  1049. movl $SYS_futex, %eax
  1050. - syscall
  1051. + SYSCALL
  1052. movq %rax, %r14
  1053. movl (%rsp), %edi
  1054. @@ -732,7 +725,7 @@ __condvar_cleanup2:
  1055. orl $FUTEX_WAKE, %esi
  1056. #endif
  1057. movl $SYS_futex, %eax
  1058. - syscall
  1059. + SYSCALL
  1060. subq $cond_nwaiters, %rdi
  1061. movl $1, %r12d
  1062. @@ -769,7 +762,7 @@ __condvar_cleanup2:
  1063. orl $FUTEX_WAKE, %esi
  1064. #endif
  1065. movl $SYS_futex, %eax
  1066. - syscall
  1067. + SYSCALL
  1068. /* Lock the mutex only if we don't own it already. This only happens
  1069. in case of PI mutexes, if we got cancelled after a successful
  1070. 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
  1071. index 2c6b515..296659c 100644
  1072. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
  1073. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
  1074. @@ -138,7 +138,7 @@ __pthread_cond_wait:
  1075. movl $(FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %esi
  1076. movl $SYS_futex, %eax
  1077. - syscall
  1078. + SYSCALL
  1079. cmpl $0, %eax
  1080. sete %r8b
  1081. @@ -180,7 +180,7 @@ __pthread_cond_wait:
  1082. #endif
  1083. 60: xorb %r8b, %r8b
  1084. movl $SYS_futex, %eax
  1085. - syscall
  1086. + SYSCALL
  1087. 62: movl (%rsp), %edi
  1088. callq __pthread_disable_asynccancel
  1089. @@ -239,7 +239,7 @@ __pthread_cond_wait:
  1090. orl $FUTEX_WAKE, %esi
  1091. #endif
  1092. movl $SYS_futex, %eax
  1093. - syscall
  1094. + SYSCALL
  1095. subq $cond_nwaiters, %rdi
  1096. 17: LOCK
  1097. @@ -455,7 +455,7 @@ __condvar_cleanup1:
  1098. orl $FUTEX_WAKE, %esi
  1099. #endif
  1100. movl $SYS_futex, %eax
  1101. - syscall
  1102. + SYSCALL
  1103. subq $cond_nwaiters, %rdi
  1104. movl $1, %ecx
  1105. @@ -493,7 +493,7 @@ __condvar_cleanup1:
  1106. orl $FUTEX_WAKE, %esi
  1107. #endif
  1108. movl $SYS_futex, %eax
  1109. - syscall
  1110. + SYSCALL
  1111. /* Lock the mutex only if we don't own it already. This only happens
  1112. in case of PI mutexes, if we got cancelled after a successful
  1113. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
  1114. index 7f5c081..38ecb12 100644
  1115. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
  1116. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
  1117. @@ -90,7 +90,7 @@ __pthread_once:
  1118. # endif
  1119. #endif
  1120. movl $SYS_futex, %eax
  1121. - syscall
  1122. + SYSCALL
  1123. jmp 6b
  1124. /* Preserve the pointer to the control variable. */
  1125. @@ -123,7 +123,7 @@ __pthread_once:
  1126. orl %fs:PRIVATE_FUTEX, %esi
  1127. #endif
  1128. movl $SYS_futex, %eax
  1129. - syscall
  1130. + SYSCALL
  1131. 4: addq $8, %rsp
  1132. cfi_adjust_cfa_offset(-8)
  1133. @@ -152,7 +152,7 @@ clear_once_control:
  1134. orl %fs:PRIVATE_FUTEX, %esi
  1135. #endif
  1136. movl $SYS_futex, %eax
  1137. - syscall
  1138. + SYSCALL
  1139. movq %r8, %rdi
  1140. .LcallUR:
  1141. 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
  1142. index 264ba58..c54f316 100644
  1143. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
  1144. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
  1145. @@ -82,7 +82,7 @@ __pthread_rwlock_rdlock:
  1146. #endif
  1147. addq $READERS_WAKEUP, %rdi
  1148. movl $SYS_futex, %eax
  1149. - syscall
  1150. + SYSCALL
  1151. subq $READERS_WAKEUP, %rdi
  1152. 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
  1153. index f60530e..fb7894a 100644
  1154. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
  1155. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
  1156. @@ -109,7 +109,7 @@ pthread_rwlock_timedrdlock:
  1157. #endif
  1158. 21: leaq READERS_WAKEUP(%r12), %rdi
  1159. movl $SYS_futex, %eax
  1160. - syscall
  1161. + SYSCALL
  1162. movq %rax, %rdx
  1163. #ifndef __ASSUME_FUTEX_CLOCK_REALTIME
  1164. 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
  1165. index 7870733..f9eee96 100644
  1166. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
  1167. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
  1168. @@ -107,7 +107,7 @@ pthread_rwlock_timedwrlock:
  1169. #endif
  1170. 21: leaq WRITERS_WAKEUP(%r12), %rdi
  1171. movl $SYS_futex, %eax
  1172. - syscall
  1173. + SYSCALL
  1174. movq %rax, %rdx
  1175. #ifndef __ASSUME_FUTEX_CLOCK_REALTIME
  1176. 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
  1177. index e971529..bdd1f4d 100644
  1178. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
  1179. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
  1180. @@ -79,7 +79,7 @@ __pthread_rwlock_unlock:
  1181. #endif
  1182. movl $SYS_futex, %eax
  1183. movq %r10, %rdi
  1184. - syscall
  1185. + SYSCALL
  1186. xorl %eax, %eax
  1187. retq
  1188. 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
  1189. index ff5392c..1afe769 100644
  1190. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
  1191. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
  1192. @@ -80,7 +80,7 @@ __pthread_rwlock_wrlock:
  1193. #endif
  1194. addq $WRITERS_WAKEUP, %rdi
  1195. movl $SYS_futex, %eax
  1196. - syscall
  1197. + SYSCALL
  1198. subq $WRITERS_WAKEUP, %rdi
  1199. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
  1200. index 65e715d..7152395 100644
  1201. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
  1202. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
  1203. @@ -52,7 +52,7 @@ sem_post:
  1204. movl $FUTEX_WAKE, %esi
  1205. orl PRIVATE(%rdi), %esi
  1206. movl $1, %edx
  1207. - syscall
  1208. + SYSCALL
  1209. testq %rax, %rax
  1210. js 1f
  1211. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
  1212. index acb79db..f9db4d1 100644
  1213. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
  1214. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
  1215. @@ -97,7 +97,7 @@ sem_timedwait:
  1216. orl PRIVATE(%rdi), %esi
  1217. movl $SYS_futex, %eax
  1218. xorl %edx, %edx
  1219. - syscall
  1220. + SYSCALL
  1221. movq %rax, %r9
  1222. #if VALUE != 0
  1223. leaq -VALUE(%rdi), %rdi
  1224. @@ -233,7 +233,7 @@ sem_timedwait:
  1225. # endif
  1226. movl $SYS_futex, %eax
  1227. xorl %edx, %edx
  1228. - syscall
  1229. + SYSCALL
  1230. movq %rax, %r14
  1231. movl 16(%rsp), %edi
  1232. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
  1233. index 7f91148..ac4b8e8 100644
  1234. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
  1235. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
  1236. @@ -81,7 +81,7 @@ sem_wait:
  1237. orl PRIVATE(%rdi), %esi
  1238. #endif
  1239. xorl %edx, %edx
  1240. - syscall
  1241. + SYSCALL
  1242. movq %rax, %rcx
  1243. xchgq %r8, %rdi
  1244. diff --git a/nptl/sysdeps/x86_64/pthreaddef.h b/nptl/sysdeps/x86_64/pthreaddef.h
  1245. index 50587b8..374b553 100644
  1246. --- a/nptl/sysdeps/x86_64/pthreaddef.h
  1247. +++ b/nptl/sysdeps/x86_64/pthreaddef.h
  1248. @@ -48,4 +48,5 @@
  1249. /* While there is no such syscall. */
  1250. #define __exit_thread_inline(val) \
  1251. - asm volatile ("syscall" :: "a" (__NR_exit), "D" (val))
  1252. + asm volatile ("pushq %%rbx\n\tmovq syscalldb@GOTPCREL(%%rip), %%rbx\n\t" \
  1253. + "call %%rbx\n\t" :: "a" (__NR_exit), "D" (val) : "bx" )
  1254. diff --git a/nptl/sysdeps/x86_64/tls.h b/nptl/sysdeps/x86_64/tls.h
  1255. index f3b7649..433b8c9 100644
  1256. --- a/nptl/sysdeps/x86_64/tls.h
  1257. +++ b/nptl/sysdeps/x86_64/tls.h
  1258. @@ -28,6 +28,7 @@
  1259. # include <sysdep.h>
  1260. # include <libc-internal.h>
  1261. # include <kernel-features.h>
  1262. +# include <shim_tls.h>
  1263. /* Replacement type for __m128 since this file is included by ld.so,
  1264. which is compiled with -mno-sse. It must not change the alignment
  1265. @@ -67,6 +68,10 @@ typedef struct
  1266. # else
  1267. int __unused1;
  1268. # endif
  1269. +
  1270. + shim_tcb_t shim_tcb; /* For graphene, we allocate a shim_tcb
  1271. + in the real tcb. */
  1272. +
  1273. int rtld_must_xmm_save;
  1274. /* Reservation of some values for the TM ABI. */
  1275. void *__private_tm[5];
  1276. @@ -135,6 +140,12 @@ typedef struct
  1277. # define GET_DTV(descr) \
  1278. (((tcbhead_t *) (descr))->dtv)
  1279. +/* For Graphene */
  1280. +#define SYSCALLDB \
  1281. + "pushq %%rbx\n\t" \
  1282. + "movq syscalldb@GOTPCREL(%%rip), %%rbx\n\t" \
  1283. + "callq *%%rbx\n\t" \
  1284. + "popq %%rbx\n\t"
  1285. /* Code to initially initialize the thread pointer. This might need
  1286. special attention since 'errno' is not yet available and if the
  1287. @@ -152,7 +163,7 @@ typedef struct
  1288. _head->self = _thrdescr; \
  1289. \
  1290. /* It is a simple syscall to set the %fs value for the thread. */ \
  1291. - asm volatile ("syscall" \
  1292. + asm volatile (SYSCALLDB \
  1293. : "=a" (_result) \
  1294. : "0" ((unsigned long int) __NR_arch_prctl), \
  1295. "D" ((unsigned long int) ARCH_SET_FS), \
  1296. diff --git a/scripts/mkinstalldirs b/scripts/mkinstalldirs
  1297. index f945dbf..3c0e48c 100755
  1298. --- a/scripts/mkinstalldirs
  1299. +++ b/scripts/mkinstalldirs
  1300. @@ -20,9 +20,9 @@ do
  1301. esac
  1302. if test ! -d "$pathcomp"; then
  1303. - echo "mkdir $pathcomp" 1>&2
  1304. + echo "mkdir -p $pathcomp" 1>&2
  1305. - mkdir "$pathcomp" || lasterr=$?
  1306. + mkdir -p "$pathcomp" || lasterr=$?
  1307. if test ! -d "$pathcomp"; then
  1308. errstatus=$lasterr
  1309. diff --git a/shlib-versions b/shlib-versions
  1310. index 9344590..4edb370 100644
  1311. --- a/shlib-versions
  1312. +++ b/shlib-versions
  1313. @@ -107,3 +107,5 @@ sparc64.*-.*-.* libBrokenLocale=1 GLIBC_2.2
  1314. # This defines the libgcc soname version this glibc is to load for
  1315. # asynchronous cancellation to work correctly.
  1316. .*-.*-.* libgcc_s=1
  1317. +
  1318. +.*-.*-.* liblibos=1
  1319. diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
  1320. index c667e34..9803b8a 100644
  1321. --- a/sysdeps/generic/ldsodefs.h
  1322. +++ b/sysdeps/generic/ldsodefs.h
  1323. @@ -854,8 +854,7 @@ extern void _dl_sort_fini (struct link_map **maps, size_t nmaps, char *used,
  1324. any shared object mappings. The `r_state' member of `struct r_debug'
  1325. says what change is taking place. This function's address is
  1326. the value of the `r_brk' member. */
  1327. -extern void _dl_debug_state (void);
  1328. -rtld_hidden_proto (_dl_debug_state)
  1329. +extern void __libc_dl_debug_state (void) __attribute__((weak));
  1330. /* Initialize `struct r_debug' if it has not already been done. The
  1331. argument is the run-time load address of the dynamic linker, to be put
  1332. diff --git a/sysdeps/unix/sysv/linux/_exit.c b/sysdeps/unix/sysv/linux/_exit.c
  1333. index 18c4fce..a21fb32 100644
  1334. --- a/sysdeps/unix/sysv/linux/_exit.c
  1335. +++ b/sysdeps/unix/sysv/linux/_exit.c
  1336. @@ -29,9 +29,9 @@ _exit (status)
  1337. while (1)
  1338. {
  1339. #ifdef __NR_exit_group
  1340. - INLINE_SYSCALL (exit_group, 1, status);
  1341. + INLINE_SYSCALL_ASM (exit_group, 1, status);
  1342. #endif
  1343. - INLINE_SYSCALL (exit, 1, status);
  1344. + INLINE_SYSCALL_ASM (exit, 1, status);
  1345. #ifdef ABORT_INSTRUCTION
  1346. ABORT_INSTRUCTION;
  1347. diff --git a/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S b/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
  1348. index d9bdb67..9719699 100644
  1349. --- a/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
  1350. +++ b/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
  1351. @@ -84,7 +84,8 @@ ENTRY(____longjmp_chk)
  1352. xorl %edi, %edi
  1353. lea -sizeSS(%rsp), %RSI_LP
  1354. movl $__NR_sigaltstack, %eax
  1355. - syscall
  1356. + SYSCALL
  1357. +
  1358. /* Without working sigaltstack we cannot perform the test. */
  1359. testl %eax, %eax
  1360. jne .Lok2
  1361. diff --git a/sysdeps/unix/sysv/linux/x86_64/clock_gettime.c b/sysdeps/unix/sysv/linux/x86_64/clock_gettime.c
  1362. index f712110..f6bad14 100644
  1363. --- a/sysdeps/unix/sysv/linux/x86_64/clock_gettime.c
  1364. +++ b/sysdeps/unix/sysv/linux/x86_64/clock_gettime.c
  1365. @@ -1,5 +1,6 @@
  1366. #include "bits/libc-vdso.h"
  1367. +#if 0 /* in Graphene, disallow VDSO calls */
  1368. #ifdef SHARED
  1369. # define SYSCALL_GETTIME(id, tp) \
  1370. ({ long int (*f) (clockid_t, struct timespec *) = __vdso_clock_gettime; \
  1371. @@ -16,5 +17,6 @@
  1372. PTR_DEMANGLE (f); \
  1373. f (id, tp); })
  1374. #endif
  1375. +#endif
  1376. #include "../clock_gettime.c"
  1377. diff --git a/sysdeps/unix/sysv/linux/x86_64/clone.S b/sysdeps/unix/sysv/linux/x86_64/clone.S
  1378. index 53f9fbd..80d28b5 100644
  1379. --- a/sysdeps/unix/sysv/linux/x86_64/clone.S
  1380. +++ b/sysdeps/unix/sysv/linux/x86_64/clone.S
  1381. @@ -61,11 +61,15 @@ ENTRY (BP_SYM (__clone))
  1382. jz SYSCALL_ERROR_LABEL
  1383. /* Insert the argument onto the new stack. */
  1384. - subq $16,%rsi
  1385. - movq %rcx,8(%rsi)
  1386. + subq $24,%rsi
  1387. + movq %rcx,16(%rsi)
  1388. /* Save the function pointer. It will be popped off in the
  1389. child in the ebx frobbing below. */
  1390. + movq %rdi,8(%rsi)
  1391. +
  1392. + /* Push an additional pointer as return address into the stack */
  1393. + leaq L(clone_return)(%rip),%rdi
  1394. movq %rdi,0(%rsi)
  1395. /* Do the system call. */
  1396. @@ -78,8 +82,9 @@ ENTRY (BP_SYM (__clone))
  1397. /* End FDE now, because in the child the unwind info will be
  1398. wrong. */
  1399. cfi_endproc;
  1400. - syscall
  1401. + SYSCALL
  1402. +L(clone_return):
  1403. testq %rax,%rax
  1404. jl SYSCALL_ERROR_LABEL
  1405. jz L(thread_start)
  1406. @@ -101,13 +106,14 @@ L(thread_start):
  1407. movl $-1, %eax
  1408. jne 2f
  1409. movl $SYS_ify(getpid), %eax
  1410. - syscall
  1411. + SYSCALL
  1412. 2: movl %eax, %fs:PID
  1413. movl %eax, %fs:TID
  1414. 1:
  1415. #endif
  1416. /* Set up arguments for the function call. */
  1417. + addq $8,%rsp /* Skip the return address */
  1418. popq %rax /* Function to call. */
  1419. popq %rdi /* Argument. */
  1420. call *%rax
  1421. diff --git a/sysdeps/unix/sysv/linux/x86_64/getcontext.S b/sysdeps/unix/sysv/linux/x86_64/getcontext.S
  1422. index 5f2b64c..df57736 100644
  1423. --- a/sysdeps/unix/sysv/linux/x86_64/getcontext.S
  1424. +++ b/sysdeps/unix/sysv/linux/x86_64/getcontext.S
  1425. @@ -75,7 +75,7 @@ ENTRY(__getcontext)
  1426. #endif
  1427. movl $_NSIG8,%r10d
  1428. movl $__NR_rt_sigprocmask, %eax
  1429. - syscall
  1430. + SYSCALL
  1431. cmpq $-4095, %rax /* Check %rax for error. */
  1432. jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
  1433. diff --git a/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c b/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c
  1434. index d52f938..d75b502 100644
  1435. --- a/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c
  1436. +++ b/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c
  1437. @@ -17,6 +17,7 @@
  1438. #include <sys/time.h>
  1439. +#if 0 /* In graphene, do not use vsyscall or VDSO call */
  1440. #ifdef SHARED
  1441. # include <dl-vdso.h>
  1442. @@ -42,7 +43,8 @@ asm (".type __gettimeofday, %gnu_indirect_function");
  1443. asm (".globl __GI___gettimeofday\n"
  1444. "__GI___gettimeofday = __gettimeofday");
  1445. -#else
  1446. +#endif
  1447. +#endif
  1448. # include <sysdep.h>
  1449. # include <errno.h>
  1450. @@ -54,6 +56,5 @@ __gettimeofday (struct timeval *tv, struct timezone *tz)
  1451. }
  1452. libc_hidden_def (__gettimeofday)
  1453. -#endif
  1454. weak_alias (__gettimeofday, gettimeofday)
  1455. libc_hidden_weak (gettimeofday)
  1456. diff --git a/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S b/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
  1457. index 3b319d7..98d8612 100644
  1458. --- a/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
  1459. +++ b/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
  1460. @@ -30,6 +30,7 @@ ENTRY (sched_getcpu)
  1461. sub $0x8, %rsp
  1462. cfi_adjust_cfa_offset(8)
  1463. +#if 0 /* for Graphene, never do VDSO calls */
  1464. movq %rsp, %rdi
  1465. xorl %esi, %esi
  1466. movl $VGETCPU_CACHE_OFFSET, %edx
  1467. @@ -39,16 +40,19 @@ ENTRY (sched_getcpu)
  1468. movq __vdso_getcpu(%rip), %rax
  1469. PTR_DEMANGLE (%rax)
  1470. callq *%rax
  1471. -#else
  1472. -# ifdef __NR_getcpu
  1473. +#endif
  1474. +#endif
  1475. +
  1476. +#ifdef __NR_getcpu
  1477. movl $__NR_getcpu, %eax
  1478. - syscall
  1479. -# ifndef __ASSUME_GETCPU_SYSCALL
  1480. + SYSCALL
  1481. +#endif
  1482. +
  1483. +#if 0 /* for Graphene, never do vsyscall */
  1484. +# ifndef __ASSUME_GETCPU_SYSCALL
  1485. cmpq $-ENOSYS, %rax
  1486. jne 1f
  1487. -# endif
  1488. -# endif
  1489. -# ifndef __ASSUME_GETCPU_SYSCALL
  1490. +
  1491. movq $VSYSCALL_ADDR_vgetcpu, %rax
  1492. callq *%rax
  1493. 1:
  1494. diff --git a/sysdeps/unix/sysv/linux/x86_64/setcontext.S b/sysdeps/unix/sysv/linux/x86_64/setcontext.S
  1495. index adcb243..0d662e3 100644
  1496. --- a/sysdeps/unix/sysv/linux/x86_64/setcontext.S
  1497. +++ b/sysdeps/unix/sysv/linux/x86_64/setcontext.S
  1498. @@ -43,7 +43,7 @@ ENTRY(__setcontext)
  1499. movl $SIG_SETMASK, %edi
  1500. movl $_NSIG8,%r10d
  1501. movl $__NR_rt_sigprocmask, %eax
  1502. - syscall
  1503. + SYSCALL
  1504. popq %rdi /* Reload %rdi, adjust stack. */
  1505. cfi_adjust_cfa_offset(-8)
  1506. cmpq $-4095, %rax /* Check %rax for error. */
  1507. diff --git a/sysdeps/unix/sysv/linux/x86_64/sigaction.c b/sysdeps/unix/sysv/linux/x86_64/sigaction.c
  1508. index 5a3ad18..9ac8b6e 100644
  1509. --- a/sysdeps/unix/sysv/linux/x86_64/sigaction.c
  1510. +++ b/sysdeps/unix/sysv/linux/x86_64/sigaction.c
  1511. @@ -129,7 +129,8 @@ asm \
  1512. " .type __" #name ",@function\n" \
  1513. "__" #name ":\n" \
  1514. " movq $" #syscall ", %rax\n" \
  1515. - " syscall\n" \
  1516. + " movq syscalldb@GOTPCREL(%rip), %rbx\n" \
  1517. + " call *%rbx\n" \
  1518. ".LEND_" #name ":\n" \
  1519. ".section .eh_frame,\"a\",@progbits\n" \
  1520. ".LSTARTFRAME_" #name ":\n" \
  1521. diff --git a/sysdeps/unix/sysv/linux/x86_64/swapcontext.S b/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
  1522. index 0d04a01..e8483db 100644
  1523. --- a/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
  1524. +++ b/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
  1525. @@ -75,7 +75,7 @@ ENTRY(__swapcontext)
  1526. movl $SIG_SETMASK, %edi
  1527. movl $_NSIG8,%r10d
  1528. movl $__NR_rt_sigprocmask, %eax
  1529. - syscall
  1530. + SYSCALL
  1531. cmpq $-4095, %rax /* Check %rax for error. */
  1532. jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
  1533. diff --git a/sysdeps/unix/sysv/linux/x86_64/syscall.S b/sysdeps/unix/sysv/linux/x86_64/syscall.S
  1534. index 87dfd8c..c144b42 100644
  1535. --- a/sysdeps/unix/sysv/linux/x86_64/syscall.S
  1536. +++ b/sysdeps/unix/sysv/linux/x86_64/syscall.S
  1537. @@ -34,7 +34,7 @@ ENTRY (syscall)
  1538. movq %r8, %r10
  1539. movq %r9, %r8
  1540. movq 8(%rsp),%r9 /* arg6 is on the stack. */
  1541. - syscall /* Do the system call. */
  1542. + SYSCALL /* Do the system call. */
  1543. cmpq $-4095, %rax /* Check %rax for error. */
  1544. jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
  1545. ret /* Return to caller. */
  1546. diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  1547. index 5323104..d466181 100644
  1548. --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  1549. +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  1550. @@ -23,6 +23,7 @@
  1551. #include <bp-sym.h>
  1552. #include <bp-asm.h>
  1553. #include <tls.h>
  1554. +#include "syscalldb.h"
  1555. #ifdef IS_IN_rtld
  1556. # include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
  1557. @@ -174,11 +175,18 @@
  1558. Syscalls of more than 6 arguments are not supported. */
  1559. +# undef SYSCALL
  1560. +# define SYSCALL \
  1561. + pushq %rbx; \
  1562. + movq syscalldb@GOTPCREL(%rip), %rbx; \
  1563. + call *%rbx; \
  1564. + popq %rbx;
  1565. +
  1566. # undef DO_CALL
  1567. # define DO_CALL(syscall_name, args) \
  1568. DOARGS_##args \
  1569. movl $SYS_ify (syscall_name), %eax; \
  1570. - syscall;
  1571. + SYSCALL
  1572. # define DOARGS_0 /* nothing */
  1573. # define DOARGS_1 /* nothing */
  1574. @@ -192,9 +200,20 @@
  1575. /* Define a macro which expands inline into the wrapper code for a system
  1576. call. */
  1577. # undef INLINE_SYSCALL
  1578. -# define INLINE_SYSCALL(name, nr, args...) \
  1579. +# define INLINE_SYSCALL(name, nr_args...) \
  1580. + ({ \
  1581. + unsigned long int resultvar = INTERNAL_SYSCALL (name, , ##nr_args); \
  1582. + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
  1583. + { \
  1584. + __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
  1585. + resultvar = (unsigned long int) -1; \
  1586. + } \
  1587. + (long int) resultvar; })
  1588. +
  1589. +# undef INLINE_SYSCALL_ASM
  1590. +# define INLINE_SYSCALL_ASM(name, nr_args...) \
  1591. ({ \
  1592. - unsigned long int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
  1593. + unsigned long int resultvar = INTERNAL_SYSCALL_ASM (name, , ##nr_args); \
  1594. if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
  1595. { \
  1596. __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
  1597. @@ -206,9 +225,9 @@
  1598. into the wrapper code for a system call. It should be used when size
  1599. of any argument > size of long int. */
  1600. # undef INLINE_SYSCALL_TYPES
  1601. -# define INLINE_SYSCALL_TYPES(name, nr, args...) \
  1602. +# define INLINE_SYSCALL_TYPES(name, nr_args...) \
  1603. ({ \
  1604. - unsigned long int resultvar = INTERNAL_SYSCALL_TYPES (name, , nr, args); \
  1605. + unsigned long int resultvar = INTERNAL_SYSCALL_TYPES (name, , ##nr_args); \
  1606. if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
  1607. { \
  1608. __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
  1609. @@ -225,13 +244,20 @@
  1610. LOAD_ARGS_##nr (args) \
  1611. LOAD_REGS_##nr \
  1612. asm volatile ( \
  1613. - "syscall\n\t" \
  1614. + "movq syscalldb@GOTPCREL(%%rip), %%rbx\n\t" \
  1615. + "call *%%rbx\n\t" \
  1616. : "=a" (resultvar) \
  1617. - : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx"); \
  1618. + : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx", "bx"); \
  1619. (long int) resultvar; })
  1620. +# define INTERNAL_SYSCALL_NCS_ASM INTERNAL_SYSCALL_NCS
  1621. +
  1622. # undef INTERNAL_SYSCALL
  1623. -# define INTERNAL_SYSCALL(name, err, nr, args...) \
  1624. - INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
  1625. +# define INTERNAL_SYSCALL(name, err, nr_args...) \
  1626. + INTERNAL_SYSCALL_NCS (__NR_##name, err, ##nr_args)
  1627. +
  1628. +# undef INTERNAL_SYSCALL_ASM
  1629. +# define INTERNAL_SYSCALL_ASM(name, err, nr_args...) \
  1630. + INTERNAL_SYSCALL_NCS_ASM (__NR_##name, err, ##nr_args)
  1631. # define INTERNAL_SYSCALL_NCS_TYPES(name, err, nr, args...) \
  1632. ({ \
  1633. @@ -239,9 +265,10 @@
  1634. LOAD_ARGS_TYPES_##nr (args) \
  1635. LOAD_REGS_TYPES_##nr (args) \
  1636. asm volatile ( \
  1637. - "syscall\n\t" \
  1638. + "movq syscalldb@GOTPCREL(%%rip), %%rbx\n\t" \
  1639. + "call *%%rbx\n\t" \
  1640. : "=a" (resultvar) \
  1641. - : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx"); \
  1642. + : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx", "bx"); \
  1643. (long int) resultvar; })
  1644. # undef INTERNAL_SYSCALL_TYPES
  1645. # define INTERNAL_SYSCALL_TYPES(name, err, nr, args...) \
  1646. @@ -254,6 +281,7 @@
  1647. # undef INTERNAL_SYSCALL_ERRNO
  1648. # define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
  1649. +# if 0 /* for Graphene, never do vsyscall */
  1650. # ifdef SHARED
  1651. # define INLINE_VSYSCALL(name, nr, args...) \
  1652. ({ \
  1653. @@ -302,12 +330,13 @@
  1654. v_ret; \
  1655. })
  1656. -# else
  1657. -# define INLINE_VSYSCALL(name, nr, args...) \
  1658. - INLINE_SYSCALL (name, nr, ##args)
  1659. -# define INTERNAL_VSYSCALL(name, err, nr, args...) \
  1660. - INTERNAL_SYSCALL (name, err, nr, ##args)
  1661. # endif
  1662. +# endif
  1663. +
  1664. +# define INLINE_VSYSCALL(name, nr_args...) \
  1665. + INLINE_SYSCALL (name, ##nr_args)
  1666. +# define INTERNAL_VSYSCALL(name, err, nr_args...) \
  1667. + INTERNAL_SYSCALL (name, err, ##nr_args)
  1668. # define LOAD_ARGS_0()
  1669. # define LOAD_REGS_0
  1670. diff --git a/sysdeps/unix/sysv/linux/x86_64/time.c b/sysdeps/unix/sysv/linux/x86_64/time.c
  1671. deleted file mode 100644
  1672. index 65703ca..0000000
  1673. --- a/sysdeps/unix/sysv/linux/x86_64/time.c
  1674. +++ /dev/null
  1675. @@ -1,60 +0,0 @@
  1676. -/* Copyright (C) 2001,02,2003,2011 Free Software Foundation, Inc.
  1677. - This file is part of the GNU C Library.
  1678. -
  1679. - The GNU C Library is free software; you can redistribute it and/or
  1680. - modify it under the terms of the GNU Lesser General Public
  1681. - License as published by the Free Software Foundation; either
  1682. - version 2.1 of the License, or (at your option) any later version.
  1683. -
  1684. - The GNU C Library is distributed in the hope that it will be useful,
  1685. - but WITHOUT ANY WARRANTY; without even the implied warranty of
  1686. - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  1687. - Lesser General Public License for more details.
  1688. -
  1689. - You should have received a copy of the GNU Lesser General Public
  1690. - License along with the GNU C Library; if not, see
  1691. - <http://www.gnu.org/licenses/>. */
  1692. -
  1693. -#ifdef SHARED
  1694. -/* Redefine time so that the compiler won't complain about the type
  1695. - mismatch with the IFUNC selector in strong_alias, below. */
  1696. -#undef time
  1697. -#define time __redirect_time
  1698. -#include <time.h>
  1699. -
  1700. -#include <dl-vdso.h>
  1701. -
  1702. -#define VSYSCALL_ADDR_vtime 0xffffffffff600400
  1703. -
  1704. -/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
  1705. - ifunc symbol properly. */
  1706. -extern __typeof (__redirect_time) __libc_time;
  1707. -void *time_ifunc (void) __asm__ ("__libc_time");
  1708. -
  1709. -void *
  1710. -time_ifunc (void)
  1711. -{
  1712. - PREPARE_VERSION (linux26, "LINUX_2.6", 61765110);
  1713. -
  1714. - /* If the vDSO is not available we fall back on the old vsyscall. */
  1715. - return _dl_vdso_vsym ("__vdso_time", &linux26) ?: (void *) VSYSCALL_ADDR_vtime;
  1716. -}
  1717. -__asm (".type __libc_time, %gnu_indirect_function");
  1718. -
  1719. -#undef time
  1720. -strong_alias (__libc_time, time)
  1721. -libc_hidden_ver (__libc_time, time)
  1722. -
  1723. -#else
  1724. -
  1725. -# include <time.h>
  1726. -# include <sysdep.h>
  1727. -
  1728. -time_t
  1729. -time (time_t *t)
  1730. -{
  1731. - INTERNAL_SYSCALL_DECL (err);
  1732. - return INTERNAL_SYSCALL (time, err, 1, t);
  1733. -}
  1734. -
  1735. -#endif
  1736. diff --git a/sysdeps/unix/sysv/linux/x86_64/vfork.S b/sysdeps/unix/sysv/linux/x86_64/vfork.S
  1737. index c28087d..ea4ff9f 100644
  1738. --- a/sysdeps/unix/sysv/linux/x86_64/vfork.S
  1739. +++ b/sysdeps/unix/sysv/linux/x86_64/vfork.S
  1740. @@ -38,7 +38,7 @@ ENTRY (__vfork)
  1741. /* Stuff the syscall number in RAX and enter into the kernel. */
  1742. movl $SYS_ify (vfork), %eax
  1743. - syscall
  1744. + SYSCALL
  1745. /* Push back the return PC. */
  1746. pushq %rdi
  1747. diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
  1748. index d2654aa..9bd840f 100644
  1749. --- a/sysdeps/x86_64/dl-machine.h
  1750. +++ b/sysdeps/x86_64/dl-machine.h
  1751. @@ -511,7 +511,8 @@ elf_machine_lazy_rel (struct link_map *map,
  1752. value = ((ElfW(Addr) (*) (void)) value) ();
  1753. *reloc_addr = value;
  1754. }
  1755. - else
  1756. + /* for graphene, get around R_X86_64_NONE */
  1757. + else if (__builtin_expect (r_type != R_X86_64_NONE, 1))
  1758. _dl_reloc_bad_type (map, r_type, 1);
  1759. }