glibc-2.19.patch 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922
  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..1cdf63a 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_vers_2_17; 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..431120a 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_vers_2_17 __attribute__((weak)) = GLIBC_VERSION_2_17;
  528. +
  529. +static void __attribute__((noinline,optimize("-O0")))
  530. +check_glibc_version (void)
  531. +{
  532. + if (glibc_vers_2_17 != GLIBC_VERSION_2_17)
  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. @@ -2301,7 +2350,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
  614. the address since by now the variable might be in another object. */
  615. r = _dl_debug_initialize (0, LM_ID_BASE);
  616. r->r_state = RT_CONSISTENT;
  617. - _dl_debug_state ();
  618. + __libc_dl_debug_state ();
  619. LIBC_PROBE (init_complete, 2, LM_ID_BASE, r);
  620. #if defined USE_LDCONFIG && !defined MAP_COPY
  621. diff --git a/elf/unload.c b/elf/unload.c
  622. index 4566f22..73046de 100644
  623. --- a/elf/unload.c
  624. +++ b/elf/unload.c
  625. @@ -9,7 +9,7 @@
  626. #include <stdio.h>
  627. #include <stdlib.h>
  628. -#define MAPS ((struct link_map *) _r_debug.r_map)
  629. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  630. #define OUT \
  631. for (map = MAPS; map != NULL; map = map->l_next) \
  632. diff --git a/elf/unload2.c b/elf/unload2.c
  633. index eef2bfd..a21d2ac 100644
  634. --- a/elf/unload2.c
  635. +++ b/elf/unload2.c
  636. @@ -6,7 +6,7 @@
  637. #include <stdio.h>
  638. #include <stdlib.h>
  639. -#define MAPS ((struct link_map *) _r_debug.r_map)
  640. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  641. #define OUT \
  642. for (map = MAPS; map != NULL; map = map->l_next) \
  643. diff --git a/malloc/arena.c b/malloc/arena.c
  644. index 5088a25..b3b0e1c 100644
  645. --- a/malloc/arena.c
  646. +++ b/malloc/arena.c
  647. @@ -21,6 +21,27 @@
  648. /* Compile-time constants. */
  649. +#ifndef HEAP_MAX_SIZE
  650. +# ifdef DEFAULT_MMAP_THRESHOLD_MAX
  651. +# define DEFAULT_HEAP_MAX_SIZE (2 * DEFAULT_MMAP_THRESHOLD_MAX)
  652. +# else
  653. +# define DEFAULT_HEAP_MAX_SIZE (1024 * 1024) /* must be a power of two */
  654. +# endif
  655. +# include <sysdep.h>
  656. +static long int heap_max_size = 0;
  657. +# define HEAP_MAX_SIZE \
  658. + ({ \
  659. + if (!heap_max_size) { \
  660. + long int size = glibc_option("heap_size"); \
  661. + if (size > 0) \
  662. + heap_max_size = size; \
  663. + else \
  664. + heap_max_size = DEFAULT_HEAP_MAX_SIZE; \
  665. + } \
  666. + heap_max_size; \
  667. + })
  668. +#endif
  669. +
  670. #define HEAP_MIN_SIZE (32 * 1024)
  671. #ifndef HEAP_MAX_SIZE
  672. # ifdef DEFAULT_MMAP_THRESHOLD_MAX
  673. @@ -545,33 +566,7 @@ new_heap (size_t size, size_t top_pad)
  674. mapping (on Linux, this is the case for all non-writable mappings
  675. anyway). */
  676. p2 = MAP_FAILED;
  677. - if (aligned_heap_area)
  678. - {
  679. - p2 = (char *) MMAP (aligned_heap_area, HEAP_MAX_SIZE, PROT_NONE,
  680. - MAP_NORESERVE);
  681. - aligned_heap_area = NULL;
  682. - if (p2 != MAP_FAILED && ((unsigned long) p2 & (HEAP_MAX_SIZE - 1)))
  683. - {
  684. - __munmap (p2, HEAP_MAX_SIZE);
  685. - p2 = MAP_FAILED;
  686. - }
  687. - }
  688. - if (p2 == MAP_FAILED)
  689. - {
  690. - p1 = (char *) MMAP (0, HEAP_MAX_SIZE << 1, PROT_NONE, MAP_NORESERVE);
  691. - if (p1 != MAP_FAILED)
  692. - {
  693. - p2 = (char *) (((unsigned long) p1 + (HEAP_MAX_SIZE - 1))
  694. - & ~(HEAP_MAX_SIZE - 1));
  695. - ul = p2 - p1;
  696. - if (ul)
  697. - __munmap (p1, ul);
  698. - else
  699. - aligned_heap_area = p2 + HEAP_MAX_SIZE;
  700. - __munmap (p2 + HEAP_MAX_SIZE, HEAP_MAX_SIZE - ul);
  701. - }
  702. - else
  703. - {
  704. +
  705. /* Try to take the chance that an allocation of only HEAP_MAX_SIZE
  706. is already aligned. */
  707. p2 = (char *) MMAP (0, HEAP_MAX_SIZE, PROT_NONE, MAP_NORESERVE);
  708. @@ -583,8 +578,7 @@ new_heap (size_t size, size_t top_pad)
  709. __munmap (p2, HEAP_MAX_SIZE);
  710. return 0;
  711. }
  712. - }
  713. - }
  714. +
  715. if (__mprotect (p2, size, PROT_READ | PROT_WRITE) != 0)
  716. {
  717. __munmap (p2, HEAP_MAX_SIZE);
  718. diff --git a/nptl/Makefile b/nptl/Makefile
  719. index 57cc8c6..81f1bf4 100644
  720. --- a/nptl/Makefile
  721. +++ b/nptl/Makefile
  722. @@ -20,7 +20,7 @@
  723. #
  724. subdir := nptl
  725. -headers := pthread.h semaphore.h bits/semaphore.h
  726. +headers := pthread.h semaphore.h bits/semaphore.h syscalldb.h
  727. extra-libs := libpthread
  728. extra-libs-others := $(extra-libs)
  729. diff --git a/nptl/Versions b/nptl/Versions
  730. index bb11277..354149a 100644
  731. --- a/nptl/Versions
  732. +++ b/nptl/Versions
  733. @@ -31,6 +31,9 @@ libc {
  734. # Internal libc interface to libpthread
  735. __libc_dl_error_tsd;
  736. }
  737. + SHIM {
  738. + syscalldb; glibc_option;
  739. + }
  740. }
  741. libpthread {
  742. @@ -262,4 +265,8 @@ libpthread {
  743. __pthread_clock_gettime; __pthread_clock_settime;
  744. __pthread_unwind; __pthread_get_minstack;
  745. }
  746. +
  747. + SHIM {
  748. + syscalldb; glibc_option;
  749. + }
  750. }
  751. diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
  752. index 9d7f52f..72d50ae 100644
  753. --- a/nptl/pthread_create.c
  754. +++ b/nptl/pthread_create.c
  755. @@ -405,8 +405,11 @@ start_thread (void *arg)
  756. # error "to do"
  757. #endif
  758. assert (freesize < pd->stackblock_size);
  759. + /* XXX: may not be necessary */
  760. +#if 0
  761. if (freesize > PTHREAD_STACK_MIN)
  762. __madvise (pd->stackblock, freesize - PTHREAD_STACK_MIN, MADV_DONTNEED);
  763. +#endif
  764. /* If the thread is detached free the TCB. */
  765. if (IS_DETACHED (pd))
  766. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S b/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S
  767. index 89fda5e..594dd72 100644
  768. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S
  769. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S
  770. @@ -111,7 +111,8 @@ ENTRY(__pthread_disable_asynccancel)
  771. xorq %r10, %r10
  772. addq $CANCELHANDLING, %rdi
  773. LOAD_PRIVATE_FUTEX_WAIT (%esi)
  774. - syscall
  775. + SYSCALL
  776. +
  777. movl %fs:CANCELHANDLING, %eax
  778. jmp 3b
  779. END(__pthread_disable_asynccancel)
  780. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/fork.c b/nptl/sysdeps/unix/sysv/linux/x86_64/fork.c
  781. index a036b92..40a1eaf 100644
  782. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/fork.c
  783. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/fork.c
  784. @@ -21,10 +21,20 @@
  785. #include <sysdep.h>
  786. #include <tls.h>
  787. -
  788. -#define ARCH_FORK() \
  789. +/* In Graphene, we prefer to call fork system call directly than clone */
  790. +#if USE_clone_FOR_fork
  791. +# define ARCH_FORK() \
  792. INLINE_SYSCALL (clone, 4, \
  793. CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD, 0, \
  794. NULL, &THREAD_SELF->tid)
  795. +#else
  796. +# define ARCH_FORK() \
  797. + ({ unsigned long ret = INLINE_SYSCALL (fork, 0); \
  798. + if (!ret) { \
  799. + pid_t pid = INLINE_SYSCALL (getpid, 0); \
  800. + THREAD_SETMEM (THREAD_SELF, pid, pid); \
  801. + THREAD_SETMEM (THREAD_SELF, tid, pid); \
  802. + } ret; })
  803. +#endif
  804. #include "../fork.c"
  805. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
  806. index f2dca07..e5b3f2f 100644
  807. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
  808. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
  809. @@ -90,7 +90,7 @@ __lll_lock_wait_private:
  810. 1: LIBC_PROBE (lll_lock_wait_private, 1, %rdi)
  811. movl $SYS_futex, %eax
  812. - syscall
  813. + SYSCALL
  814. 2: movl %edx, %eax
  815. xchgl %eax, (%rdi) /* NB: lock is implied */
  816. @@ -130,7 +130,7 @@ __lll_lock_wait:
  817. 1: LIBC_PROBE (lll_lock_wait, 2, %rdi, %rsi)
  818. movl $SYS_futex, %eax
  819. - syscall
  820. + SYSCALL
  821. 2: movl %edx, %eax
  822. xchgl %eax, (%rdi) /* NB: lock is implied */
  823. @@ -185,7 +185,7 @@ __lll_timedlock_wait:
  824. 1: movl $SYS_futex, %eax
  825. movl $2, %edx
  826. - syscall
  827. + SYSCALL
  828. 2: xchgl %edx, (%rdi) /* NB: lock is implied */
  829. @@ -279,7 +279,7 @@ __lll_timedlock_wait:
  830. LOAD_FUTEX_WAIT (%esi)
  831. movq %r12, %rdi
  832. movl $SYS_futex, %eax
  833. - syscall
  834. + SYSCALL
  835. /* NB: %edx == 2 */
  836. xchgl %edx, (%r12)
  837. @@ -336,7 +336,7 @@ __lll_unlock_wake_private:
  838. LOAD_PRIVATE_FUTEX_WAKE (%esi)
  839. movl $1, %edx /* Wake one thread. */
  840. movl $SYS_futex, %eax
  841. - syscall
  842. + SYSCALL
  843. popq %rdx
  844. cfi_adjust_cfa_offset(-8)
  845. @@ -366,7 +366,7 @@ __lll_unlock_wake:
  846. LOAD_FUTEX_WAKE (%esi)
  847. movl $1, %edx /* Wake one thread. */
  848. movl $SYS_futex, %eax
  849. - syscall
  850. + SYSCALL
  851. popq %rdx
  852. cfi_adjust_cfa_offset(-8)
  853. @@ -435,7 +435,7 @@ __lll_timedwait_tid:
  854. #endif
  855. movq %r12, %rdi
  856. movl $SYS_futex, %eax
  857. - syscall
  858. + SYSCALL
  859. cmpl $0, (%rdi)
  860. jne 1f
  861. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
  862. index 0a26739..8aae14a 100644
  863. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
  864. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
  865. @@ -214,7 +214,7 @@ LLL_STUB_UNWIND_INFO_END
  866. register const struct timespec *__to __asm ("r10") = timeout; \
  867. int __status; \
  868. register __typeof (val) _val __asm ("edx") = (val); \
  869. - __asm __volatile ("syscall" \
  870. + __asm __volatile (SYSCALLDB \
  871. : "=a" (__status) \
  872. : "0" (SYS_futex), "D" (futex), \
  873. "S" (__lll_private_flag (FUTEX_WAIT, private)), \
  874. @@ -229,7 +229,7 @@ LLL_STUB_UNWIND_INFO_END
  875. int __status; \
  876. register __typeof (nr) _nr __asm ("edx") = (nr); \
  877. LIBC_PROBE (lll_futex_wake, 3, futex, nr, private); \
  878. - __asm __volatile ("syscall" \
  879. + __asm __volatile (SYSCALLDB \
  880. : "=a" (__status) \
  881. : "0" (SYS_futex), "D" (futex), \
  882. "S" (__lll_private_flag (FUTEX_WAKE, private)), \
  883. @@ -540,7 +540,7 @@ extern int __lll_timedlock_elision (int *futex, short *adapt_count,
  884. { \
  885. int ignore; \
  886. __asm __volatile (LOCK_INSTR "orl %3, (%2)\n\t" \
  887. - "syscall" \
  888. + SYSCALLDB \
  889. : "=m" (futex), "=a" (ignore) \
  890. : "D" (&(futex)), "i" (FUTEX_OWNER_DIED), \
  891. "S" (__lll_private_flag (FUTEX_WAKE, private)), \
  892. @@ -555,7 +555,7 @@ extern int __lll_timedlock_elision (int *futex, short *adapt_count,
  893. register int __nr_move __asm ("r10") = nr_move; \
  894. register void *__mutex __asm ("r8") = mutex; \
  895. register int __val __asm ("r9") = val; \
  896. - __asm __volatile ("syscall" \
  897. + __asm __volatile (SYSCALLDB \
  898. : "=a" (__res) \
  899. : "0" (__NR_futex), "D" ((void *) ftx), \
  900. "S" (__lll_private_flag (FUTEX_CMP_REQUEUE, \
  901. @@ -581,7 +581,7 @@ extern int __lll_timedlock_elision (int *futex, short *adapt_count,
  902. if (_tid != 0) \
  903. __asm __volatile ("xorq %%r10, %%r10\n\t" \
  904. "1:\tmovq %2, %%rax\n\t" \
  905. - "syscall\n\t" \
  906. + SYSCALLDB \
  907. "cmpl $0, (%%rdi)\n\t" \
  908. "jne 1b" \
  909. : "=&a" (__ignore) \
  910. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
  911. index 990b6f9..89dbe32 100644
  912. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
  913. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
  914. @@ -80,7 +80,7 @@ __lll_robust_lock_wait:
  915. jnz 2f
  916. 1: movl $SYS_futex, %eax
  917. - syscall
  918. + SYSCALL
  919. movl (%rdi), %eax
  920. @@ -145,7 +145,7 @@ __lll_robust_timedlock_wait:
  921. jnz 6f
  922. 5: movl $SYS_futex, %eax
  923. - syscall
  924. + SYSCALL
  925. movl %eax, %ecx
  926. movl (%rdi), %eax
  927. @@ -257,7 +257,7 @@ __lll_robust_timedlock_wait:
  928. LOAD_FUTEX_WAIT (%esi)
  929. movq %r12, %rdi
  930. movl $SYS_futex, %eax
  931. - syscall
  932. + SYSCALL
  933. movq %rax, %rcx
  934. movl (%r12), %eax
  935. 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
  936. index eec17f2..4472960 100644
  937. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S
  938. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S
  939. @@ -62,7 +62,7 @@ pthread_barrier_wait:
  940. #endif
  941. xorq %r10, %r10
  942. 8: movl $SYS_futex, %eax
  943. - syscall
  944. + SYSCALL
  945. /* Don't return on spurious wakeups. The syscall does not change
  946. any register except %eax so there is no need to reload any of
  947. @@ -109,7 +109,7 @@ pthread_barrier_wait:
  948. movl $FUTEX_WAKE, %esi
  949. orl PRIVATE(%rdi), %esi
  950. movl $SYS_futex, %eax
  951. - syscall
  952. + SYSCALL
  953. /* Increment LEFT. If this brings the count back to the
  954. initial count unlock the object. */
  955. 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
  956. index 985e0f1..f180ab1 100644
  957. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
  958. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
  959. @@ -90,7 +90,7 @@ __pthread_cond_broadcast:
  960. movl $SYS_futex, %eax
  961. movl $1, %edx
  962. movl $0x7fffffff, %r10d
  963. - syscall
  964. + SYSCALL
  965. /* For any kind of error, which mainly is EAGAIN, we try again
  966. with WAKE. The general test also covers running on old
  967. @@ -106,7 +106,7 @@ __pthread_cond_broadcast:
  968. movl $SYS_futex, %eax
  969. movl $1, %edx
  970. movl $0x7fffffff, %r10d
  971. - syscall
  972. + SYSCALL
  973. /* For any kind of error, which mainly is EAGAIN, we try again
  974. with WAKE. The general test also covers running on old
  975. @@ -172,7 +172,7 @@ __pthread_cond_broadcast:
  976. orl $FUTEX_WAKE, %esi
  977. #endif
  978. movl $SYS_futex, %eax
  979. - syscall
  980. + SYSCALL
  981. jmp 10b
  982. .size __pthread_cond_broadcast, .-__pthread_cond_broadcast
  983. versioned_symbol (libpthread, __pthread_cond_broadcast, pthread_cond_broadcast,
  984. 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
  985. index 53d65b6..8724325 100644
  986. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
  987. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
  988. @@ -82,7 +82,7 @@ __pthread_cond_signal:
  989. addq $cond_lock, %r8
  990. #endif
  991. movl $FUTEX_OP_CLEAR_WAKE_IF_GT_ONE, %r9d
  992. - syscall
  993. + SYSCALL
  994. #if cond_lock != 0
  995. subq $cond_lock, %r8
  996. #endif
  997. @@ -99,7 +99,7 @@ __pthread_cond_signal:
  998. movq %rcx, %r8
  999. xorq %r10, %r10
  1000. movl (%rdi), %r9d // XXX Can this be right?
  1001. - syscall
  1002. + SYSCALL
  1003. leaq -cond_futex(%rdi), %r8
  1004. @@ -118,7 +118,7 @@ __pthread_cond_signal:
  1005. movl $SYS_futex, %eax
  1006. /* %rdx should be 1 already from $FUTEX_WAKE_OP syscall.
  1007. movl $1, %edx */
  1008. - syscall
  1009. + SYSCALL
  1010. /* Unlock. */
  1011. 4: LOCK
  1012. 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
  1013. index 0dc2340..cac13bf 100644
  1014. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
  1015. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
  1016. @@ -188,7 +188,7 @@ __pthread_cond_timedwait:
  1017. movq %r12, %rdx
  1018. addq $cond_futex, %rdi
  1019. movl $SYS_futex, %eax
  1020. - syscall
  1021. + SYSCALL
  1022. cmpl $0, %eax
  1023. sete %r15b
  1024. @@ -234,7 +234,7 @@ __pthread_cond_timedwait:
  1025. movq %r12, %rdx
  1026. addq $cond_futex, %rdi
  1027. movl $SYS_futex, %eax
  1028. - syscall
  1029. + SYSCALL
  1030. 62: movq %rax, %r14
  1031. movl (%rsp), %edi
  1032. @@ -321,7 +321,7 @@ __pthread_cond_timedwait:
  1033. orl $FUTEX_WAKE, %esi
  1034. #endif
  1035. movl $SYS_futex, %eax
  1036. - syscall
  1037. + SYSCALL
  1038. subq $cond_nwaiters, %rdi
  1039. 55: LOCK
  1040. @@ -485,15 +485,8 @@ __pthread_cond_timedwait:
  1041. /* Only clocks 0 and 1 are allowed so far. Both are handled in the
  1042. kernel. */
  1043. leaq 32(%rsp), %rsi
  1044. -# ifdef SHARED
  1045. - mov __vdso_clock_gettime@GOTPCREL(%rip), %RAX_LP
  1046. - mov (%rax), %RAX_LP
  1047. - PTR_DEMANGLE (%RAX_LP)
  1048. - call *%rax
  1049. -# else
  1050. movl $__NR_clock_gettime, %eax
  1051. - syscall
  1052. -# endif
  1053. + SYSCALL
  1054. /* Compute relative timeout. */
  1055. movq (%r13), %rcx
  1056. @@ -560,7 +553,7 @@ __pthread_cond_timedwait:
  1057. # endif
  1058. addq $cond_futex, %rdi
  1059. movl $SYS_futex, %eax
  1060. - syscall
  1061. + SYSCALL
  1062. movq %rax, %r14
  1063. movl (%rsp), %edi
  1064. @@ -732,7 +725,7 @@ __condvar_cleanup2:
  1065. orl $FUTEX_WAKE, %esi
  1066. #endif
  1067. movl $SYS_futex, %eax
  1068. - syscall
  1069. + SYSCALL
  1070. subq $cond_nwaiters, %rdi
  1071. movl $1, %r12d
  1072. @@ -769,7 +762,7 @@ __condvar_cleanup2:
  1073. orl $FUTEX_WAKE, %esi
  1074. #endif
  1075. movl $SYS_futex, %eax
  1076. - syscall
  1077. + SYSCALL
  1078. /* Lock the mutex only if we don't own it already. This only happens
  1079. in case of PI mutexes, if we got cancelled after a successful
  1080. 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
  1081. index 0e61d0a..60e104b 100644
  1082. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
  1083. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
  1084. @@ -138,7 +138,7 @@ __pthread_cond_wait:
  1085. movl $(FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %esi
  1086. movl $SYS_futex, %eax
  1087. - syscall
  1088. + SYSCALL
  1089. cmpl $0, %eax
  1090. sete %r8b
  1091. @@ -180,7 +180,7 @@ __pthread_cond_wait:
  1092. #endif
  1093. 60: xorb %r8b, %r8b
  1094. movl $SYS_futex, %eax
  1095. - syscall
  1096. + SYSCALL
  1097. 62: movl (%rsp), %edi
  1098. callq __pthread_disable_asynccancel
  1099. @@ -239,7 +239,7 @@ __pthread_cond_wait:
  1100. orl $FUTEX_WAKE, %esi
  1101. #endif
  1102. movl $SYS_futex, %eax
  1103. - syscall
  1104. + SYSCALL
  1105. subq $cond_nwaiters, %rdi
  1106. 17: LOCK
  1107. @@ -455,7 +455,7 @@ __condvar_cleanup1:
  1108. orl $FUTEX_WAKE, %esi
  1109. #endif
  1110. movl $SYS_futex, %eax
  1111. - syscall
  1112. + SYSCALL
  1113. subq $cond_nwaiters, %rdi
  1114. movl $1, %ecx
  1115. @@ -493,7 +493,7 @@ __condvar_cleanup1:
  1116. orl $FUTEX_WAKE, %esi
  1117. #endif
  1118. movl $SYS_futex, %eax
  1119. - syscall
  1120. + SYSCALL
  1121. /* Lock the mutex only if we don't own it already. This only happens
  1122. in case of PI mutexes, if we got cancelled after a successful
  1123. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
  1124. index 2cbe2fa..d4e229a 100644
  1125. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
  1126. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
  1127. @@ -90,7 +90,7 @@ __pthread_once:
  1128. # endif
  1129. #endif
  1130. movl $SYS_futex, %eax
  1131. - syscall
  1132. + SYSCALL
  1133. jmp 6b
  1134. /* Preserve the pointer to the control variable. */
  1135. @@ -123,7 +123,7 @@ __pthread_once:
  1136. orl %fs:PRIVATE_FUTEX, %esi
  1137. #endif
  1138. movl $SYS_futex, %eax
  1139. - syscall
  1140. + SYSCALL
  1141. 4: addq $8, %rsp
  1142. cfi_adjust_cfa_offset(-8)
  1143. @@ -152,7 +152,7 @@ clear_once_control:
  1144. orl %fs:PRIVATE_FUTEX, %esi
  1145. #endif
  1146. movl $SYS_futex, %eax
  1147. - syscall
  1148. + SYSCALL
  1149. movq %r8, %rdi
  1150. .LcallUR:
  1151. 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
  1152. index 3bbb4c7..8ebf317 100644
  1153. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
  1154. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
  1155. @@ -82,7 +82,7 @@ __pthread_rwlock_rdlock:
  1156. #endif
  1157. addq $READERS_WAKEUP, %rdi
  1158. movl $SYS_futex, %eax
  1159. - syscall
  1160. + SYSCALL
  1161. subq $READERS_WAKEUP, %rdi
  1162. 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
  1163. index 40bcc04..d6c9c82 100644
  1164. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
  1165. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
  1166. @@ -109,7 +109,7 @@ pthread_rwlock_timedrdlock:
  1167. #endif
  1168. 21: leaq READERS_WAKEUP(%r12), %rdi
  1169. movl $SYS_futex, %eax
  1170. - syscall
  1171. + SYSCALL
  1172. movq %rax, %rdx
  1173. #ifndef __ASSUME_FUTEX_CLOCK_REALTIME
  1174. 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
  1175. index f57ef52..78a2655 100644
  1176. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
  1177. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
  1178. @@ -106,7 +106,7 @@ pthread_rwlock_timedwrlock:
  1179. #endif
  1180. 21: leaq WRITERS_WAKEUP(%r12), %rdi
  1181. movl $SYS_futex, %eax
  1182. - syscall
  1183. + SYSCALL
  1184. movq %rax, %rdx
  1185. #ifndef __ASSUME_FUTEX_CLOCK_REALTIME
  1186. 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
  1187. index d779f7b..4dec0c0 100644
  1188. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
  1189. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
  1190. @@ -79,7 +79,7 @@ __pthread_rwlock_unlock:
  1191. #endif
  1192. movl $SYS_futex, %eax
  1193. movq %r10, %rdi
  1194. - syscall
  1195. + SYSCALL
  1196. xorl %eax, %eax
  1197. retq
  1198. 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
  1199. index e444def..ba31821 100644
  1200. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
  1201. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
  1202. @@ -80,7 +80,7 @@ __pthread_rwlock_wrlock:
  1203. #endif
  1204. addq $WRITERS_WAKEUP, %rdi
  1205. movl $SYS_futex, %eax
  1206. - syscall
  1207. + SYSCALL
  1208. subq $WRITERS_WAKEUP, %rdi
  1209. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
  1210. index 1c11600..d276efa 100644
  1211. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
  1212. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
  1213. @@ -52,7 +52,7 @@ sem_post:
  1214. movl $FUTEX_WAKE, %esi
  1215. orl PRIVATE(%rdi), %esi
  1216. movl $1, %edx
  1217. - syscall
  1218. + SYSCALL
  1219. testq %rax, %rax
  1220. js 1f
  1221. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
  1222. index 880610e..06fd57c 100644
  1223. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
  1224. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
  1225. @@ -97,7 +97,7 @@ sem_timedwait:
  1226. orl PRIVATE(%rdi), %esi
  1227. movl $SYS_futex, %eax
  1228. xorl %edx, %edx
  1229. - syscall
  1230. + SYSCALL
  1231. movq %rax, %r9
  1232. #if VALUE != 0
  1233. leaq -VALUE(%rdi), %rdi
  1234. @@ -233,7 +233,7 @@ sem_timedwait:
  1235. # endif
  1236. movl $SYS_futex, %eax
  1237. xorl %edx, %edx
  1238. - syscall
  1239. + SYSCALL
  1240. movq %rax, %r14
  1241. movl 16(%rsp), %edi
  1242. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
  1243. index 8f4d068..d9b49e4 100644
  1244. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
  1245. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
  1246. @@ -81,7 +81,7 @@ sem_wait:
  1247. orl PRIVATE(%rdi), %esi
  1248. #endif
  1249. xorl %edx, %edx
  1250. - syscall
  1251. + SYSCALL
  1252. movq %rax, %rcx
  1253. xchgq %r8, %rdi
  1254. diff --git a/nptl/sysdeps/x86_64/pthreaddef.h b/nptl/sysdeps/x86_64/pthreaddef.h
  1255. index 18a15a1..ac3d6d3 100644
  1256. --- a/nptl/sysdeps/x86_64/pthreaddef.h
  1257. +++ b/nptl/sysdeps/x86_64/pthreaddef.h
  1258. @@ -48,4 +48,5 @@
  1259. /* While there is no such syscall. */
  1260. #define __exit_thread_inline(val) \
  1261. - asm volatile ("syscall" :: "a" (__NR_exit), "D" (val))
  1262. + asm volatile ("pushq %%rbx\n\tmovq syscalldb@GOTPCREL(%%rip), %%rbx\n\t" \
  1263. + "call %%rbx\n\t" :: "a" (__NR_exit), "D" (val) : "bx" )
  1264. diff --git a/nptl/sysdeps/x86_64/tls.h b/nptl/sysdeps/x86_64/tls.h
  1265. index cbb5e9e..19b18ef 100644
  1266. --- a/nptl/sysdeps/x86_64/tls.h
  1267. +++ b/nptl/sysdeps/x86_64/tls.h
  1268. @@ -28,6 +28,7 @@
  1269. # include <sysdep.h>
  1270. # include <libc-internal.h>
  1271. # include <kernel-features.h>
  1272. +# include <shim_tls.h>
  1273. /* Replacement type for __m128 since this file is included by ld.so,
  1274. which is compiled with -mno-sse. It must not change the alignment
  1275. @@ -67,6 +68,10 @@ typedef struct
  1276. # else
  1277. int __glibc_reserved1;
  1278. # endif
  1279. +
  1280. + shim_tcb_t shim_tcb; /* For graphene, we allocate a shim_tcb
  1281. + in the real tcb. */
  1282. +
  1283. int rtld_must_xmm_save;
  1284. /* Reservation of some values for the TM ABI. */
  1285. void *__private_tm[4];
  1286. @@ -137,6 +142,12 @@ typedef struct
  1287. # define GET_DTV(descr) \
  1288. (((tcbhead_t *) (descr))->dtv)
  1289. +/* For Graphene */
  1290. +#define SYSCALLDB \
  1291. + "pushq %%rbx\n\t" \
  1292. + "movq syscalldb@GOTPCREL(%%rip), %%rbx\n\t" \
  1293. + "callq *%%rbx\n\t" \
  1294. + "popq %%rbx\n\t"
  1295. /* Code to initially initialize the thread pointer. This might need
  1296. special attention since 'errno' is not yet available and if the
  1297. @@ -154,7 +165,7 @@ typedef struct
  1298. _head->self = _thrdescr; \
  1299. \
  1300. /* It is a simple syscall to set the %fs value for the thread. */ \
  1301. - asm volatile ("syscall" \
  1302. + asm volatile (SYSCALLDB \
  1303. : "=a" (_result) \
  1304. : "0" ((unsigned long int) __NR_arch_prctl), \
  1305. "D" ((unsigned long int) ARCH_SET_FS), \
  1306. diff --git a/scripts/mkinstalldirs b/scripts/mkinstalldirs
  1307. index 55d537f..57bf12b 100755
  1308. --- a/scripts/mkinstalldirs
  1309. +++ b/scripts/mkinstalldirs
  1310. @@ -126,9 +126,9 @@ do
  1311. esac
  1312. if test ! -d "$pathcomp"; then
  1313. - echo "mkdir $pathcomp"
  1314. + echo "mkdir -p $pathcomp"
  1315. - mkdir "$pathcomp" || lasterr=$?
  1316. + mkdir -p "$pathcomp" || lasterr=$?
  1317. if test ! -d "$pathcomp"; then
  1318. errstatus=$lasterr
  1319. diff --git a/shlib-versions b/shlib-versions
  1320. index 78b0ad7..5c3dcf2 100644
  1321. --- a/shlib-versions
  1322. +++ b/shlib-versions
  1323. @@ -108,3 +108,5 @@ sparc64.*-.*-.* libBrokenLocale=1 GLIBC_2.2
  1324. # This defines the libgcc soname version this glibc is to load for
  1325. # asynchronous cancellation to work correctly.
  1326. .*-.*-.* libgcc_s=1
  1327. +
  1328. +.*-.*-.* liblibos=1
  1329. diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
  1330. index ffeb093..7a9fbcb 100644
  1331. --- a/sysdeps/generic/ldsodefs.h
  1332. +++ b/sysdeps/generic/ldsodefs.h
  1333. @@ -881,8 +881,7 @@ extern void _dl_sort_fini (struct link_map **maps, size_t nmaps, char *used,
  1334. any shared object mappings. The `r_state' member of `struct r_debug'
  1335. says what change is taking place. This function's address is
  1336. the value of the `r_brk' member. */
  1337. -extern void _dl_debug_state (void);
  1338. -rtld_hidden_proto (_dl_debug_state)
  1339. +extern void __libc_dl_debug_state (void) __attribute__((weak));
  1340. /* Initialize `struct r_debug' if it has not already been done. The
  1341. argument is the run-time load address of the dynamic linker, to be put
  1342. diff --git a/sysdeps/unix/sysv/linux/_exit.c b/sysdeps/unix/sysv/linux/_exit.c
  1343. index 2468228..a9f1cd6 100644
  1344. --- a/sysdeps/unix/sysv/linux/_exit.c
  1345. +++ b/sysdeps/unix/sysv/linux/_exit.c
  1346. @@ -29,9 +29,9 @@ _exit (status)
  1347. while (1)
  1348. {
  1349. #ifdef __NR_exit_group
  1350. - INLINE_SYSCALL (exit_group, 1, status);
  1351. + INLINE_SYSCALL_ASM (exit_group, 1, status);
  1352. #endif
  1353. - INLINE_SYSCALL (exit, 1, status);
  1354. + INLINE_SYSCALL_ASM (exit, 1, status);
  1355. #ifdef ABORT_INSTRUCTION
  1356. ABORT_INSTRUCTION;
  1357. diff --git a/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S b/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
  1358. index 49f0384..ee59c00 100644
  1359. --- a/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
  1360. +++ b/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
  1361. @@ -84,7 +84,8 @@ ENTRY(____longjmp_chk)
  1362. xorl %edi, %edi
  1363. lea -sizeSS(%rsp), %RSI_LP
  1364. movl $__NR_sigaltstack, %eax
  1365. - syscall
  1366. + SYSCALL
  1367. +
  1368. /* Without working sigaltstack we cannot perform the test. */
  1369. testl %eax, %eax
  1370. jne .Lok2
  1371. diff --git a/sysdeps/unix/sysv/linux/x86_64/clock_gettime.c b/sysdeps/unix/sysv/linux/x86_64/clock_gettime.c
  1372. index f712110..f6bad14 100644
  1373. --- a/sysdeps/unix/sysv/linux/x86_64/clock_gettime.c
  1374. +++ b/sysdeps/unix/sysv/linux/x86_64/clock_gettime.c
  1375. @@ -1,5 +1,6 @@
  1376. #include "bits/libc-vdso.h"
  1377. +#if 0 /* in Graphene, disallow VDSO calls */
  1378. #ifdef SHARED
  1379. # define SYSCALL_GETTIME(id, tp) \
  1380. ({ long int (*f) (clockid_t, struct timespec *) = __vdso_clock_gettime; \
  1381. @@ -16,5 +17,6 @@
  1382. PTR_DEMANGLE (f); \
  1383. f (id, tp); })
  1384. #endif
  1385. +#endif
  1386. #include "../clock_gettime.c"
  1387. diff --git a/sysdeps/unix/sysv/linux/x86_64/clone.S b/sysdeps/unix/sysv/linux/x86_64/clone.S
  1388. index 0508730..c011e7a 100644
  1389. --- a/sysdeps/unix/sysv/linux/x86_64/clone.S
  1390. +++ b/sysdeps/unix/sysv/linux/x86_64/clone.S
  1391. @@ -59,11 +59,15 @@ ENTRY (__clone)
  1392. jz SYSCALL_ERROR_LABEL
  1393. /* Insert the argument onto the new stack. */
  1394. - subq $16,%rsi
  1395. - movq %rcx,8(%rsi)
  1396. + subq $24,%rsi
  1397. + movq %rcx,16(%rsi)
  1398. /* Save the function pointer. It will be popped off in the
  1399. child in the ebx frobbing below. */
  1400. + movq %rdi,8(%rsi)
  1401. +
  1402. + /* Push an additional pointer as return address into the stack */
  1403. + leaq L(clone_return)(%rip),%rdi
  1404. movq %rdi,0(%rsi)
  1405. /* Do the system call. */
  1406. @@ -76,8 +80,9 @@ ENTRY (__clone)
  1407. /* End FDE now, because in the child the unwind info will be
  1408. wrong. */
  1409. cfi_endproc;
  1410. - syscall
  1411. + SYSCALL
  1412. +L(clone_return):
  1413. testq %rax,%rax
  1414. jl SYSCALL_ERROR_LABEL
  1415. jz L(thread_start)
  1416. @@ -99,13 +104,14 @@ L(thread_start):
  1417. movl $-1, %eax
  1418. jne 2f
  1419. movl $SYS_ify(getpid), %eax
  1420. - syscall
  1421. + SYSCALL
  1422. 2: movl %eax, %fs:PID
  1423. movl %eax, %fs:TID
  1424. 1:
  1425. #endif
  1426. /* Set up arguments for the function call. */
  1427. + addq $8,%rsp /* Skip the return address */
  1428. popq %rax /* Function to call. */
  1429. popq %rdi /* Argument. */
  1430. call *%rax
  1431. diff --git a/sysdeps/unix/sysv/linux/x86_64/getcontext.S b/sysdeps/unix/sysv/linux/x86_64/getcontext.S
  1432. index 140db03..870fb02 100644
  1433. --- a/sysdeps/unix/sysv/linux/x86_64/getcontext.S
  1434. +++ b/sysdeps/unix/sysv/linux/x86_64/getcontext.S
  1435. @@ -75,7 +75,7 @@ ENTRY(__getcontext)
  1436. #endif
  1437. movl $_NSIG8,%r10d
  1438. movl $__NR_rt_sigprocmask, %eax
  1439. - syscall
  1440. + SYSCALL
  1441. cmpq $-4095, %rax /* Check %rax for error. */
  1442. jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
  1443. diff --git a/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c b/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c
  1444. index 440ca7f..571125d 100644
  1445. --- a/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c
  1446. +++ b/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c
  1447. @@ -17,6 +17,7 @@
  1448. #include <sys/time.h>
  1449. +#if 0 /* In graphene, do not use vsyscall or VDSO call */
  1450. #ifdef SHARED
  1451. # include <dl-vdso.h>
  1452. @@ -42,7 +43,8 @@ asm (".type __gettimeofday, %gnu_indirect_function");
  1453. asm (".globl __GI___gettimeofday\n"
  1454. "__GI___gettimeofday = __gettimeofday");
  1455. -#else
  1456. +#endif
  1457. +#endif
  1458. # include <sysdep.h>
  1459. # include <errno.h>
  1460. @@ -54,6 +56,5 @@ __gettimeofday (struct timeval *tv, struct timezone *tz)
  1461. }
  1462. libc_hidden_def (__gettimeofday)
  1463. -#endif
  1464. weak_alias (__gettimeofday, gettimeofday)
  1465. libc_hidden_weak (gettimeofday)
  1466. diff --git a/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S b/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
  1467. index 0fd47f2..0247e2f 100644
  1468. --- a/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
  1469. +++ b/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
  1470. @@ -30,6 +30,7 @@ ENTRY (sched_getcpu)
  1471. sub $0x8, %rsp
  1472. cfi_adjust_cfa_offset(8)
  1473. +#if 0 /* for Graphene, never do VDSO calls */
  1474. movq %rsp, %rdi
  1475. xorl %esi, %esi
  1476. movl $VGETCPU_CACHE_OFFSET, %edx
  1477. @@ -39,16 +40,19 @@ ENTRY (sched_getcpu)
  1478. movq __vdso_getcpu(%rip), %rax
  1479. PTR_DEMANGLE (%rax)
  1480. callq *%rax
  1481. -#else
  1482. -# ifdef __NR_getcpu
  1483. +#endif
  1484. +#endif
  1485. +
  1486. +#ifdef __NR_getcpu
  1487. movl $__NR_getcpu, %eax
  1488. - syscall
  1489. -# ifndef __ASSUME_GETCPU_SYSCALL
  1490. + SYSCALL
  1491. +#endif
  1492. +
  1493. +#if 0 /* for Graphene, never do vsyscall */
  1494. +# ifndef __ASSUME_GETCPU_SYSCALL
  1495. cmpq $-ENOSYS, %rax
  1496. jne 1f
  1497. -# endif
  1498. -# endif
  1499. -# ifndef __ASSUME_GETCPU_SYSCALL
  1500. +
  1501. movq $VSYSCALL_ADDR_vgetcpu, %rax
  1502. callq *%rax
  1503. 1:
  1504. diff --git a/sysdeps/unix/sysv/linux/x86_64/setcontext.S b/sysdeps/unix/sysv/linux/x86_64/setcontext.S
  1505. index b726fa0..96bf0ec 100644
  1506. --- a/sysdeps/unix/sysv/linux/x86_64/setcontext.S
  1507. +++ b/sysdeps/unix/sysv/linux/x86_64/setcontext.S
  1508. @@ -43,7 +43,7 @@ ENTRY(__setcontext)
  1509. movl $SIG_SETMASK, %edi
  1510. movl $_NSIG8,%r10d
  1511. movl $__NR_rt_sigprocmask, %eax
  1512. - syscall
  1513. + SYSCALL
  1514. popq %rdi /* Reload %rdi, adjust stack. */
  1515. cfi_adjust_cfa_offset(-8)
  1516. cmpq $-4095, %rax /* Check %rax for error. */
  1517. diff --git a/sysdeps/unix/sysv/linux/x86_64/sigaction.c b/sysdeps/unix/sysv/linux/x86_64/sigaction.c
  1518. index ab23985..39d0bdc 100644
  1519. --- a/sysdeps/unix/sysv/linux/x86_64/sigaction.c
  1520. +++ b/sysdeps/unix/sysv/linux/x86_64/sigaction.c
  1521. @@ -129,7 +129,8 @@ asm \
  1522. " .type __" #name ",@function\n" \
  1523. "__" #name ":\n" \
  1524. " movq $" #syscall ", %rax\n" \
  1525. - " syscall\n" \
  1526. + " movq syscalldb@GOTPCREL(%rip), %rbx\n" \
  1527. + " call *%rbx\n" \
  1528. ".LEND_" #name ":\n" \
  1529. ".section .eh_frame,\"a\",@progbits\n" \
  1530. ".LSTARTFRAME_" #name ":\n" \
  1531. diff --git a/sysdeps/unix/sysv/linux/x86_64/swapcontext.S b/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
  1532. index b3854fa..fd42f66 100644
  1533. --- a/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
  1534. +++ b/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
  1535. @@ -75,7 +75,7 @@ ENTRY(__swapcontext)
  1536. movl $SIG_SETMASK, %edi
  1537. movl $_NSIG8,%r10d
  1538. movl $__NR_rt_sigprocmask, %eax
  1539. - syscall
  1540. + SYSCALL
  1541. cmpq $-4095, %rax /* Check %rax for error. */
  1542. jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
  1543. diff --git a/sysdeps/unix/sysv/linux/x86_64/syscall.S b/sysdeps/unix/sysv/linux/x86_64/syscall.S
  1544. index 92c2f5b..7b7ee12 100644
  1545. --- a/sysdeps/unix/sysv/linux/x86_64/syscall.S
  1546. +++ b/sysdeps/unix/sysv/linux/x86_64/syscall.S
  1547. @@ -34,7 +34,7 @@ ENTRY (syscall)
  1548. movq %r8, %r10
  1549. movq %r9, %r8
  1550. movq 8(%rsp),%r9 /* arg6 is on the stack. */
  1551. - syscall /* Do the system call. */
  1552. + SYSCALL /* Do the system call. */
  1553. cmpq $-4095, %rax /* Check %rax for error. */
  1554. jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
  1555. ret /* Return to caller. */
  1556. diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  1557. index 4a9a9d9..3b7434d 100644
  1558. --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  1559. +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  1560. @@ -21,6 +21,7 @@
  1561. /* There is some commonality. */
  1562. #include <sysdeps/unix/x86_64/sysdep.h>
  1563. #include <tls.h>
  1564. +#include "syscalldb.h"
  1565. #ifdef IS_IN_rtld
  1566. # include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
  1567. @@ -172,11 +173,18 @@
  1568. Syscalls of more than 6 arguments are not supported. */
  1569. +# undef SYSCALL
  1570. +# define SYSCALL \
  1571. + pushq %rbx; \
  1572. + movq syscalldb@GOTPCREL(%rip), %rbx; \
  1573. + call *%rbx; \
  1574. + popq %rbx;
  1575. +
  1576. # undef DO_CALL
  1577. # define DO_CALL(syscall_name, args) \
  1578. DOARGS_##args \
  1579. movl $SYS_ify (syscall_name), %eax; \
  1580. - syscall;
  1581. + SYSCALL
  1582. # define DOARGS_0 /* nothing */
  1583. # define DOARGS_1 /* nothing */
  1584. @@ -190,9 +198,20 @@
  1585. /* Define a macro which expands inline into the wrapper code for a system
  1586. call. */
  1587. # undef INLINE_SYSCALL
  1588. -# define INLINE_SYSCALL(name, nr, args...) \
  1589. +# define INLINE_SYSCALL(name, nr_args...) \
  1590. + ({ \
  1591. + unsigned long int resultvar = INTERNAL_SYSCALL (name, , ##nr_args); \
  1592. + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
  1593. + { \
  1594. + __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
  1595. + resultvar = (unsigned long int) -1; \
  1596. + } \
  1597. + (long int) resultvar; })
  1598. +
  1599. +# undef INLINE_SYSCALL_ASM
  1600. +# define INLINE_SYSCALL_ASM(name, nr_args...) \
  1601. ({ \
  1602. - unsigned long int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
  1603. + unsigned long int resultvar = INTERNAL_SYSCALL_ASM (name, , ##nr_args); \
  1604. if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
  1605. { \
  1606. __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
  1607. @@ -204,9 +223,9 @@
  1608. into the wrapper code for a system call. It should be used when size
  1609. of any argument > size of long int. */
  1610. # undef INLINE_SYSCALL_TYPES
  1611. -# define INLINE_SYSCALL_TYPES(name, nr, args...) \
  1612. +# define INLINE_SYSCALL_TYPES(name, nr_args...) \
  1613. ({ \
  1614. - unsigned long int resultvar = INTERNAL_SYSCALL_TYPES (name, , nr, args); \
  1615. + unsigned long int resultvar = INTERNAL_SYSCALL_TYPES (name, , ##nr_args); \
  1616. if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
  1617. { \
  1618. __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
  1619. @@ -223,13 +242,20 @@
  1620. LOAD_ARGS_##nr (args) \
  1621. LOAD_REGS_##nr \
  1622. asm volatile ( \
  1623. - "syscall\n\t" \
  1624. + "movq syscalldb@GOTPCREL(%%rip), %%rbx\n\t" \
  1625. + "call *%%rbx\n\t" \
  1626. : "=a" (resultvar) \
  1627. - : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx"); \
  1628. + : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx", "bx"); \
  1629. (long int) resultvar; })
  1630. +# define INTERNAL_SYSCALL_NCS_ASM INTERNAL_SYSCALL_NCS
  1631. +
  1632. # undef INTERNAL_SYSCALL
  1633. -# define INTERNAL_SYSCALL(name, err, nr, args...) \
  1634. - INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
  1635. +# define INTERNAL_SYSCALL(name, err, nr_args...) \
  1636. + INTERNAL_SYSCALL_NCS (__NR_##name, err, ##nr_args)
  1637. +
  1638. +# undef INTERNAL_SYSCALL_ASM
  1639. +# define INTERNAL_SYSCALL_ASM(name, err, nr_args...) \
  1640. + INTERNAL_SYSCALL_NCS_ASM (__NR_##name, err, ##nr_args)
  1641. # define INTERNAL_SYSCALL_NCS_TYPES(name, err, nr, args...) \
  1642. ({ \
  1643. @@ -237,9 +263,10 @@
  1644. LOAD_ARGS_TYPES_##nr (args) \
  1645. LOAD_REGS_TYPES_##nr (args) \
  1646. asm volatile ( \
  1647. - "syscall\n\t" \
  1648. + "movq syscalldb@GOTPCREL(%%rip), %%rbx\n\t" \
  1649. + "call *%%rbx\n\t" \
  1650. : "=a" (resultvar) \
  1651. - : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx"); \
  1652. + : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx", "bx"); \
  1653. (long int) resultvar; })
  1654. # undef INTERNAL_SYSCALL_TYPES
  1655. # define INTERNAL_SYSCALL_TYPES(name, err, nr, args...) \
  1656. @@ -252,6 +279,7 @@
  1657. # undef INTERNAL_SYSCALL_ERRNO
  1658. # define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
  1659. +# if 0 /* for Graphene, never do vsyscall */
  1660. # ifdef SHARED
  1661. # define INLINE_VSYSCALL(name, nr, args...) \
  1662. ({ \
  1663. @@ -300,12 +328,13 @@
  1664. v_ret; \
  1665. })
  1666. -# else
  1667. -# define INLINE_VSYSCALL(name, nr, args...) \
  1668. - INLINE_SYSCALL (name, nr, ##args)
  1669. -# define INTERNAL_VSYSCALL(name, err, nr, args...) \
  1670. - INTERNAL_SYSCALL (name, err, nr, ##args)
  1671. # endif
  1672. +# endif
  1673. +
  1674. +# define INLINE_VSYSCALL(name, nr_args...) \
  1675. + INLINE_SYSCALL (name, ##nr_args)
  1676. +# define INTERNAL_VSYSCALL(name, err, nr_args...) \
  1677. + INTERNAL_SYSCALL (name, err, ##nr_args)
  1678. # define LOAD_ARGS_0()
  1679. # define LOAD_REGS_0
  1680. diff --git a/sysdeps/unix/sysv/linux/x86_64/time.c b/sysdeps/unix/sysv/linux/x86_64/time.c
  1681. deleted file mode 100644
  1682. index 79f1fab..0000000
  1683. --- a/sysdeps/unix/sysv/linux/x86_64/time.c
  1684. +++ /dev/null
  1685. @@ -1,60 +0,0 @@
  1686. -/* Copyright (C) 2001-2014 Free Software Foundation, Inc.
  1687. - This file is part of the GNU C Library.
  1688. -
  1689. - The GNU C Library is free software; you can redistribute it and/or
  1690. - modify it under the terms of the GNU Lesser General Public
  1691. - License as published by the Free Software Foundation; either
  1692. - version 2.1 of the License, or (at your option) any later version.
  1693. -
  1694. - The GNU C Library is distributed in the hope that it will be useful,
  1695. - but WITHOUT ANY WARRANTY; without even the implied warranty of
  1696. - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  1697. - Lesser General Public License for more details.
  1698. -
  1699. - You should have received a copy of the GNU Lesser General Public
  1700. - License along with the GNU C Library; if not, see
  1701. - <http://www.gnu.org/licenses/>. */
  1702. -
  1703. -#ifdef SHARED
  1704. -/* Redefine time so that the compiler won't complain about the type
  1705. - mismatch with the IFUNC selector in strong_alias, below. */
  1706. -#undef time
  1707. -#define time __redirect_time
  1708. -#include <time.h>
  1709. -
  1710. -#include <dl-vdso.h>
  1711. -
  1712. -#define VSYSCALL_ADDR_vtime 0xffffffffff600400
  1713. -
  1714. -/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
  1715. - ifunc symbol properly. */
  1716. -extern __typeof (__redirect_time) __libc_time;
  1717. -void *time_ifunc (void) __asm__ ("__libc_time");
  1718. -
  1719. -void *
  1720. -time_ifunc (void)
  1721. -{
  1722. - PREPARE_VERSION (linux26, "LINUX_2.6", 61765110);
  1723. -
  1724. - /* If the vDSO is not available we fall back on the old vsyscall. */
  1725. - return _dl_vdso_vsym ("__vdso_time", &linux26) ?: (void *) VSYSCALL_ADDR_vtime;
  1726. -}
  1727. -__asm (".type __libc_time, %gnu_indirect_function");
  1728. -
  1729. -#undef time
  1730. -strong_alias (__libc_time, time)
  1731. -libc_hidden_ver (__libc_time, time)
  1732. -
  1733. -#else
  1734. -
  1735. -# include <time.h>
  1736. -# include <sysdep.h>
  1737. -
  1738. -time_t
  1739. -time (time_t *t)
  1740. -{
  1741. - INTERNAL_SYSCALL_DECL (err);
  1742. - return INTERNAL_SYSCALL (time, err, 1, t);
  1743. -}
  1744. -
  1745. -#endif
  1746. diff --git a/sysdeps/unix/sysv/linux/x86_64/vfork.S b/sysdeps/unix/sysv/linux/x86_64/vfork.S
  1747. index d3b450a..76bda33 100644
  1748. --- a/sysdeps/unix/sysv/linux/x86_64/vfork.S
  1749. +++ b/sysdeps/unix/sysv/linux/x86_64/vfork.S
  1750. @@ -38,7 +38,7 @@ ENTRY (__vfork)
  1751. /* Stuff the syscall number in RAX and enter into the kernel. */
  1752. movl $SYS_ify (vfork), %eax
  1753. - syscall
  1754. + SYSCALL
  1755. /* Push back the return PC. */
  1756. pushq %rdi
  1757. diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
  1758. index 504c95f..dcfc259 100644
  1759. --- a/sysdeps/x86_64/dl-machine.h
  1760. +++ b/sysdeps/x86_64/dl-machine.h
  1761. @@ -529,7 +529,8 @@ elf_machine_lazy_rel (struct link_map *map,
  1762. value = ((ElfW(Addr) (*) (void)) value) ();
  1763. *reloc_addr = value;
  1764. }
  1765. - else
  1766. + /* for graphene, get around R_X86_64_NONE */
  1767. + else if (__builtin_expect (r_type != R_X86_64_NONE, 1))
  1768. _dl_reloc_bad_type (map, r_type, 1);
  1769. }