glibc-2.23.patch 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. diff -ruNp a/elf/dl-load.c b/elf/dl-load.c
  2. --- a/elf/dl-load.c
  3. +++ b/elf/dl-load.c
  4. @@ -45,6 +45,7 @@
  5. #include <dl-machine-reject-phdr.h>
  6. #include <dl-sysdep-open.h>
  7. +#include <glibc-version.h>
  8. #include <endian.h>
  9. #if BYTE_ORDER == BIG_ENDIAN
  10. @@ -1415,6 +1416,9 @@ cannot enable executable stack as shared
  11. DL_AFTER_LOAD (l);
  12. #endif
  13. + /* register the library to SHIM */
  14. + register_library(l->l_name, l->l_addr);
  15. +
  16. /* Now that the object is fully initialized add it to the object list. */
  17. _dl_add_to_namespace_list (l, nsid);
  18. diff -ruNp a/elf/Makefile b/elf/Makefile
  19. --- a/elf/Makefile
  20. +++ b/elf/Makefile
  21. @@ -21,7 +21,7 @@ subdir := elf
  22. include ../Makeconfig
  23. -headers = elf.h bits/elfclass.h link.h bits/link.h
  24. +headers = elf.h bits/elfclass.h link.h bits/link.h syscalldb.h
  25. routines = $(all-dl-routines) dl-support dl-iteratephdr \
  26. dl-addr enbl-secure dl-profstub \
  27. dl-origin dl-libc dl-sym dl-tsd dl-sysdep
  28. @@ -31,7 +31,8 @@ routines = $(all-dl-routines) dl-support
  29. dl-routines = $(addprefix dl-,load lookup object reloc deps hwcaps \
  30. runtime error init fini debug misc \
  31. version profile conflict tls origin scope \
  32. - execstack caller open close trampoline)
  33. + execstack caller open close trampoline) \
  34. + syscalldb syscallas
  35. ifeq (yes,$(use-ldconfig))
  36. dl-routines += dl-cache
  37. endif
  38. diff -ruNp a/elf/rtld.c b/elf/rtld.c
  39. --- a/elf/rtld.c
  40. +++ b/elf/rtld.c
  41. @@ -332,6 +332,23 @@ _dl_start_final (void *arg, struct dl_st
  42. return start_addr;
  43. }
  44. +/* For graphene, check if glibc version match to the compatible SHIM
  45. + library. If not, tell the user to update glibc. */
  46. +#include "glibc-version.h"
  47. +
  48. +const unsigned int glibc_version __attribute__((weak)) = GLIBC_VERSION;
  49. +
  50. +static void __attribute__((noinline,optimize("-O0")))
  51. +check_glibc_version (void)
  52. +{
  53. + if (glibc_version != GLIBC_VERSION)
  54. + {
  55. + _dl_fatal_printf ("Warning from Graphene: "
  56. + "Glibc version is incorrect. Please rebuild Glibc.\n");
  57. + _exit (1);
  58. + }
  59. +}
  60. +
  61. static ElfW(Addr) __attribute_used__ internal_function
  62. _dl_start (void *arg)
  63. {
  64. @@ -402,6 +419,9 @@ _dl_start (void *arg)
  65. therefore need not test whether we have to allocate the array
  66. for the relocation results (as done in dl-reloc.c). */
  67. + /* For Graphene, check if the glibc version is correct. */
  68. + check_glibc_version();
  69. +
  70. /* Now life is sane; we can call functions and access global data.
  71. Set up to use the operating system facilities, and find out from
  72. the operating system's program loader where to find the program
  73. diff -ruNp a/elf/Versions b/elf/Versions
  74. --- a/elf/Versions
  75. +++ b/elf/Versions
  76. @@ -65,4 +68,7 @@ ld {
  77. # Pointer protection.
  78. __pointer_chk_guard;
  79. }
  80. + SHIM {
  81. + syscalldb; glibc_version; glibc_option; register_library;
  82. + }
  83. }
  84. diff -ruNp a/Makeconfig b/Makeconfig
  85. --- a/Makeconfig
  86. +++ b/Makeconfig
  87. @@ -841,7 +841,8 @@ endif # $(+cflags) == ""
  88. # current directory.
  89. +includes = -I$(..)include $(if $(subdir),$(objpfx:%/=-I%)) \
  90. $(+sysdep-includes) $(includes) \
  91. - $(patsubst %/,-I%,$(..)) $(libio-include) -I. $(sysincludes)
  92. + $(patsubst %/,-I%,$(..)) $(libio-include) -I. $(sysincludes) \
  93. + -I$(common-objpfx)../shim/include
  94. # Since libio has several internal header files, we use a -I instead
  95. # of many little headers in the include directory.
  96. diff -ruNp a/Makefile b/Makefile
  97. --- a/Makefile
  98. +++ b/Makefile
  99. @@ -178,6 +178,8 @@ $(inst_includedir)/gnu/stubs.h: $(+force
  100. install-others-nosubdir: $(installed-stubs)
  101. endif
  102. +# For Graphene
  103. +CFLAGS-syscalldb.c = -fPIC
  104. # Since stubs.h is never needed when building the library, we simplify the
  105. # hairy installation process by producing it in place only as the last part
  106. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/cancellation.S b/sysdeps/unix/sysv/linux/x86_64/cancellation.S
  107. --- a/sysdeps/unix/sysv/linux/x86_64/cancellation.S
  108. +++ b/sysdeps/unix/sysv/linux/x86_64/cancellation.S
  109. @@ -111,7 +111,7 @@ ENTRY(__pthread_disable_asynccancel)
  110. xorq %r10, %r10
  111. addq $CANCELHANDLING, %rdi
  112. LOAD_PRIVATE_FUTEX_WAIT (%esi)
  113. - syscall
  114. + SYSCALLDB
  115. movl %fs:CANCELHANDLING, %eax
  116. jmp 3b
  117. END(__pthread_disable_asynccancel)
  118. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/clone.S b/sysdeps/unix/sysv/linux/x86_64/clone.S
  119. --- a/sysdeps/unix/sysv/linux/x86_64/clone.S
  120. +++ b/sysdeps/unix/sysv/linux/x86_64/clone.S
  121. @@ -76,7 +76,7 @@ ENTRY (__clone)
  122. /* End FDE now, because in the child the unwind info will be
  123. wrong. */
  124. cfi_endproc;
  125. - syscall
  126. + SYSCALLDB
  127. testq %rax,%rax
  128. jl SYSCALL_ERROR_LABEL
  129. @@ -98,7 +98,7 @@ L(thread_start):
  130. movl $-1, %eax
  131. jne 2f
  132. movl $SYS_ify(getpid), %eax
  133. - syscall
  134. + SYSCALLDB
  135. 2: movl %eax, %fs:PID
  136. movl %eax, %fs:TID
  137. 1:
  138. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/getcontext.S b/sysdeps/unix/sysv/linux/x86_64/getcontext.S
  139. --- a/sysdeps/unix/sysv/linux/x86_64/getcontext.S
  140. +++ b/sysdeps/unix/sysv/linux/x86_64/getcontext.S
  141. @@ -75,7 +75,7 @@ ENTRY(__getcontext)
  142. #endif
  143. movl $_NSIG8,%r10d
  144. movl $__NR_rt_sigprocmask, %eax
  145. - syscall
  146. + SYSCALLDB
  147. cmpq $-4095, %rax /* Check %rax for error. */
  148. jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
  149. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S b/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
  150. --- a/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
  151. +++ b/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
  152. @@ -84,7 +84,8 @@ ENTRY(____longjmp_chk)
  153. xorl %edi, %edi
  154. lea -sizeSS(%rsp), %RSI_LP
  155. movl $__NR_sigaltstack, %eax
  156. - syscall
  157. + SYSCALLDB
  158. +
  159. /* Without working sigaltstack we cannot perform the test. */
  160. testl %eax, %eax
  161. jne .Lok2
  162. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S b/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
  163. --- a/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
  164. +++ b/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
  165. @@ -90,7 +90,7 @@ __lll_lock_wait_private:
  166. 1: LIBC_PROBE (lll_lock_wait_private, 1, %rdi)
  167. movl $SYS_futex, %eax
  168. - syscall
  169. + SYSCALLDB
  170. 2: movl %edx, %eax
  171. xchgl %eax, (%rdi) /* NB: lock is implied */
  172. @@ -130,7 +130,7 @@ __lll_lock_wait:
  173. 1: LIBC_PROBE (lll_lock_wait, 2, %rdi, %rsi)
  174. movl $SYS_futex, %eax
  175. - syscall
  176. + SYSCALLDB
  177. 2: movl %edx, %eax
  178. xchgl %eax, (%rdi) /* NB: lock is implied */
  179. @@ -185,7 +185,7 @@ __lll_timedlock_wait:
  180. 1: movl $SYS_futex, %eax
  181. movl $2, %edx
  182. - syscall
  183. + SYSCALLDB
  184. 2: xchgl %edx, (%rdi) /* NB: lock is implied */
  185. @@ -279,7 +279,7 @@ __lll_timedlock_wait:
  186. LOAD_FUTEX_WAIT (%esi)
  187. movq %r12, %rdi
  188. movl $SYS_futex, %eax
  189. - syscall
  190. + SYSCALLDB
  191. /* NB: %edx == 2 */
  192. xchgl %edx, (%r12)
  193. @@ -336,7 +336,7 @@ __lll_unlock_wake_private:
  194. LOAD_PRIVATE_FUTEX_WAKE (%esi)
  195. movl $1, %edx /* Wake one thread. */
  196. movl $SYS_futex, %eax
  197. - syscall
  198. + SYSCALLDB
  199. popq %rdx
  200. cfi_adjust_cfa_offset(-8)
  201. @@ -366,7 +366,7 @@ __lll_unlock_wake:
  202. LOAD_FUTEX_WAKE (%esi)
  203. movl $1, %edx /* Wake one thread. */
  204. movl $SYS_futex, %eax
  205. - syscall
  206. + SYSCALLDB
  207. popq %rdx
  208. cfi_adjust_cfa_offset(-8)
  209. @@ -436,7 +436,7 @@ __lll_timedwait_tid:
  210. #endif
  211. movq %r12, %rdi
  212. movl $SYS_futex, %eax
  213. - syscall
  214. + SYSCALLDB
  215. cmpl $0, (%rdi)
  216. jne 1f
  217. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S b/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
  218. --- a/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
  219. +++ b/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
  220. @@ -80,7 +80,7 @@ __lll_robust_lock_wait:
  221. jnz 2f
  222. 1: movl $SYS_futex, %eax
  223. - syscall
  224. + SYSCALLDB
  225. movl (%rdi), %eax
  226. @@ -145,7 +145,7 @@ __lll_robust_timedlock_wait:
  227. jnz 6f
  228. 5: movl $SYS_futex, %eax
  229. - syscall
  230. + SYSCALLDB
  231. movl %eax, %ecx
  232. movl (%rdi), %eax
  233. @@ -257,7 +257,7 @@ __lll_robust_timedlock_wait:
  234. LOAD_FUTEX_WAIT (%esi)
  235. movq %r12, %rdi
  236. movl $SYS_futex, %eax
  237. - syscall
  238. + SYSCALLDB
  239. movq %rax, %rcx
  240. movl (%r12), %eax
  241. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S b/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
  242. --- a/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
  243. +++ b/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
  244. @@ -87,7 +87,7 @@ ENTRY(__pthread_cond_broadcast)
  245. movl $SYS_futex, %eax
  246. movl $1, %edx
  247. movl $0x7fffffff, %r10d
  248. - syscall
  249. + SYSCALLDB
  250. /* For any kind of error, which mainly is EAGAIN, we try again
  251. with WAKE. The general test also covers running on old
  252. @@ -103,7 +103,7 @@ ENTRY(__pthread_cond_broadcast)
  253. movl $SYS_futex, %eax
  254. movl $1, %edx
  255. movl $0x7fffffff, %r10d
  256. - syscall
  257. + SYSCALLDB
  258. /* For any kind of error, which mainly is EAGAIN, we try again
  259. with WAKE. The general test also covers running on old
  260. @@ -169,7 +169,7 @@ ENTRY(__pthread_cond_broadcast)
  261. orl $FUTEX_WAKE, %esi
  262. #endif
  263. movl $SYS_futex, %eax
  264. - syscall
  265. + SYSCALLDB
  266. jmp 10b
  267. END(__pthread_cond_broadcast)
  268. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S b/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
  269. --- a/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
  270. +++ b/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
  271. @@ -78,7 +78,7 @@ ENTRY(__pthread_cond_signal)
  272. addq $cond_lock, %r8
  273. #endif
  274. movl $FUTEX_OP_CLEAR_WAKE_IF_GT_ONE, %r9d
  275. - syscall
  276. + SYSCALLDB
  277. #if cond_lock != 0
  278. subq $cond_lock, %r8
  279. #endif
  280. @@ -95,7 +95,7 @@ ENTRY(__pthread_cond_signal)
  281. movq %rcx, %r8
  282. xorq %r10, %r10
  283. movl (%rdi), %r9d // XXX Can this be right?
  284. - syscall
  285. + SYSCALLDB
  286. leaq -cond_futex(%rdi), %r8
  287. @@ -114,7 +114,7 @@ ENTRY(__pthread_cond_signal)
  288. movl $SYS_futex, %eax
  289. /* %rdx should be 1 already from $FUTEX_WAKE_OP syscall.
  290. movl $1, %edx */
  291. - syscall
  292. + SYSCALLDB
  293. /* Unlock. */
  294. 4: LOCK
  295. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S b/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
  296. --- a/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
  297. +++ b/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
  298. @@ -175,7 +175,7 @@ __pthread_cond_timedwait:
  299. movq %r12, %rdx
  300. addq $cond_futex, %rdi
  301. movl $SYS_futex, %eax
  302. - syscall
  303. + SYSCALLDB
  304. cmpl $0, %eax
  305. sete %r15b
  306. @@ -221,7 +221,7 @@ __pthread_cond_timedwait:
  307. movq %r12, %rdx
  308. addq $cond_futex, %rdi
  309. movl $SYS_futex, %eax
  310. - syscall
  311. + SYSCALLDB
  312. 62: movq %rax, %r14
  313. movl (%rsp), %edi
  314. @@ -308,7 +308,7 @@ __pthread_cond_timedwait:
  315. orl $FUTEX_WAKE, %esi
  316. #endif
  317. movl $SYS_futex, %eax
  318. - syscall
  319. + SYSCALLDB
  320. subq $cond_nwaiters, %rdi
  321. 55: LOCK
  322. @@ -521,7 +521,7 @@ __condvar_cleanup2:
  323. orl $FUTEX_WAKE, %esi
  324. #endif
  325. movl $SYS_futex, %eax
  326. - syscall
  327. + SYSCALLDB
  328. subq $cond_nwaiters, %rdi
  329. movl $1, %r12d
  330. @@ -558,7 +558,7 @@ __condvar_cleanup2:
  331. orl $FUTEX_WAKE, %esi
  332. #endif
  333. movl $SYS_futex, %eax
  334. - syscall
  335. + SYSCALLDB
  336. /* Lock the mutex only if we don't own it already. This only happens
  337. in case of PI mutexes, if we got cancelled after a successful
  338. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S b/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
  339. --- a/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
  340. +++ b/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
  341. @@ -138,7 +138,7 @@ __pthread_cond_wait:
  342. movl $(FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %esi
  343. movl $SYS_futex, %eax
  344. - syscall
  345. + SYSCALLDB
  346. cmpl $0, %eax
  347. sete %r8b
  348. @@ -180,7 +180,7 @@ __pthread_cond_wait:
  349. #endif
  350. 60: xorb %r8b, %r8b
  351. movl $SYS_futex, %eax
  352. - syscall
  353. + SYSCALLDB
  354. 62: movl (%rsp), %edi
  355. callq __pthread_disable_asynccancel
  356. @@ -239,7 +239,7 @@ __pthread_cond_wait:
  357. orl $FUTEX_WAKE, %esi
  358. #endif
  359. movl $SYS_futex, %eax
  360. - syscall
  361. + SYSCALLDB
  362. subq $cond_nwaiters, %rdi
  363. 17: LOCK
  364. @@ -455,7 +455,7 @@ __condvar_cleanup1:
  365. orl $FUTEX_WAKE, %esi
  366. #endif
  367. movl $SYS_futex, %eax
  368. - syscall
  369. + SYSCALLDB
  370. subq $cond_nwaiters, %rdi
  371. movl $1, %ecx
  372. @@ -493,7 +493,7 @@ __condvar_cleanup1:
  373. orl $FUTEX_WAKE, %esi
  374. #endif
  375. movl $SYS_futex, %eax
  376. - syscall
  377. + SYSCALLDB
  378. /* Lock the mutex only if we don't own it already. This only happens
  379. in case of PI mutexes, if we got cancelled after a successful
  380. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/setcontext.S b/sysdeps/unix/sysv/linux/x86_64/setcontext.S
  381. --- a/sysdeps/unix/sysv/linux/x86_64/setcontext.S
  382. +++ b/sysdeps/unix/sysv/linux/x86_64/setcontext.S
  383. @@ -43,7 +43,7 @@ ENTRY(__setcontext)
  384. movl $SIG_SETMASK, %edi
  385. movl $_NSIG8,%r10d
  386. movl $__NR_rt_sigprocmask, %eax
  387. - syscall
  388. + SYSCALLDB
  389. popq %rdi /* Reload %rdi, adjust stack. */
  390. cfi_adjust_cfa_offset(-8)
  391. cmpq $-4095, %rax /* Check %rax for error. */
  392. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/sigaction.c b/sysdeps/unix/sysv/linux/x86_64/sigaction.c
  393. --- a/sysdeps/unix/sysv/linux/x86_64/sigaction.c
  394. +++ b/sysdeps/unix/sysv/linux/x86_64/sigaction.c
  395. @@ -120,7 +120,7 @@ asm \
  396. " .type __" #name ",@function\n" \
  397. "__" #name ":\n" \
  398. " movq $" #syscall ", %rax\n" \
  399. - " syscall\n" \
  400. + SYSCALLDB_ASM \
  401. ".LEND_" #name ":\n" \
  402. ".section .eh_frame,\"a\",@progbits\n" \
  403. ".LSTARTFRAME_" #name ":\n" \
  404. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/swapcontext.S b/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
  405. --- a/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
  406. +++ b/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
  407. @@ -75,7 +75,7 @@ ENTRY(__swapcontext)
  408. movl $SIG_SETMASK, %edi
  409. movl $_NSIG8,%r10d
  410. movl $__NR_rt_sigprocmask, %eax
  411. - syscall
  412. + SYSCALLDB
  413. cmpq $-4095, %rax /* Check %rax for error. */
  414. jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
  415. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/syscall.S b/sysdeps/unix/sysv/linux/x86_64/syscall.S
  416. --- a/sysdeps/unix/sysv/linux/x86_64/syscall.S
  417. +++ b/sysdeps/unix/sysv/linux/x86_64/syscall.S
  418. @@ -34,7 +34,7 @@ ENTRY (syscall)
  419. movq %r8, %r10
  420. movq %r9, %r8
  421. movq 8(%rsp),%r9 /* arg6 is on the stack. */
  422. - syscall /* Do the system call. */
  423. + SYSCALLDB /* Do the system call. */
  424. cmpq $-4095, %rax /* Check %rax for error. */
  425. jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
  426. ret /* Return to caller. */
  427. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  428. --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  429. +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  430. @@ -22,6 +22,7 @@
  431. #include <sysdeps/unix/sysv/linux/sysdep.h>
  432. #include <sysdeps/unix/x86_64/sysdep.h>
  433. #include <tls.h>
  434. +#include "syscalldb.h"
  435. #if IS_IN (rtld)
  436. # include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
  437. @@ -177,7 +178,7 @@
  438. # define DO_CALL(syscall_name, args) \
  439. DOARGS_##args \
  440. movl $SYS_ify (syscall_name), %eax; \
  441. - syscall;
  442. + SYSCALLDB;
  443. # define DOARGS_0 /* nothing */
  444. # define DOARGS_1 /* nothing */
  445. @@ -227,6 +239,6 @@
  446. LOAD_ARGS_##nr (args) \
  447. LOAD_REGS_##nr \
  448. asm volatile ( \
  449. - "syscall\n\t" \
  450. + SYSCALLDB \
  451. : "=a" (resultvar) \
  452. : "0" (name) ASM_ARGS_##nr : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
  453. @@ -241,7 +259,7 @@
  454. LOAD_ARGS_TYPES_##nr (args) \
  455. LOAD_REGS_TYPES_##nr (args) \
  456. asm volatile ( \
  457. - "syscall\n\t" \
  458. + SYSCALLDB \
  459. : "=a" (resultvar) \
  460. : "0" (name) ASM_ARGS_##nr : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
  461. (long int) resultvar; })
  462. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/vfork.S b/sysdeps/unix/sysv/linux/x86_64/vfork.S
  463. --- a/sysdeps/unix/sysv/linux/x86_64/vfork.S
  464. +++ b/sysdeps/unix/sysv/linux/x86_64/vfork.S
  465. @@ -46,7 +46,7 @@ ENTRY (__vfork)
  466. /* Stuff the syscall number in RAX and enter into the kernel. */
  467. movl $SYS_ify (vfork), %eax
  468. - syscall
  469. + SYSCALLDB
  470. /* Push back the return PC. */
  471. pushq %rdi
  472. diff -ruNp a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
  473. --- a/sysdeps/x86_64/dl-machine.h
  474. +++ b/sysdeps/x86_64/dl-machine.h
  475. @@ -554,7 +554,8 @@ elf_machine_lazy_rel (struct link_map *m
  476. value = ((ElfW(Addr) (*) (void)) value) ();
  477. *reloc_addr = value;
  478. }
  479. - else
  480. + /* for graphene, get around R_X86_64_NONE */
  481. + else if (__builtin_expect (r_type != R_X86_64_NONE, 1))
  482. _dl_reloc_bad_type (map, r_type, 1);
  483. }
  484. diff -ruNp a/sysdeps/x86_64/nptl/tls.h b/sysdeps/x86_64/nptl/tls.h
  485. --- a/sysdeps/x86_64/nptl/tls.h
  486. +++ b/sysdeps/x86_64/nptl/tls.h
  487. @@ -28,6 +28,7 @@
  488. # include <sysdep.h>
  489. # include <libc-internal.h>
  490. # include <kernel-features.h>
  491. +# include <syscalldb.h>
  492. /* Replacement type for __m128 since this file is included by ld.so,
  493. which is compiled with -mno-sse. It must not change the alignment
  494. @@ -155,7 +160,7 @@ typedef struct
  495. _head->self = _thrdescr; \
  496. \
  497. /* It is a simple syscall to set the %fs value for the thread. */ \
  498. - asm volatile ("syscall" \
  499. + asm volatile (SYSCALLDB \
  500. : "=a" (_result) \
  501. : "0" ((unsigned long int) __NR_arch_prctl), \
  502. "D" ((unsigned long int) ARCH_SET_FS), \