glibc-2.27.patch 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  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. @@ -46,6 +46,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. @@ -1318,6 +1319,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 dl-addr-obj enbl-secure dl-profstub \
  27. dl-origin dl-libc dl-sym dl-sysdep dl-error \
  28. @@ -33,7 +33,8 @@ dl-routines = $(addprefix dl-,load looku
  29. runtime init fini debug misc \
  30. version profile tls origin scope \
  31. execstack caller open close trampoline \
  32. - exception sort-maps)
  33. + exception sort-maps) \
  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. @@ -439,6 +439,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__
  62. _dl_start (void *arg)
  63. {
  64. @@ -510,6 +527,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. @@ -79,4 +82,7 @@ ld {
  77. # Set value of a tunable.
  78. __tunable_get_val;
  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. @@ -916,7 +916,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. @@ -179,6 +179,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/_exit.c b/sysdeps/unix/sysv/linux/_exit.c
  107. --- a/sysdeps/unix/sysv/linux/_exit.c 2018-02-01 10:17:18.000000000 -0600
  108. +++ b/sysdeps/unix/sysv/linux/_exit.c 2019-05-27 17:26:39.209526816 -0500
  109. @@ -28,9 +28,9 @@ _exit (int status)
  110. while (1)
  111. {
  112. #ifdef __NR_exit_group
  113. - INLINE_SYSCALL (exit_group, 1, status);
  114. + INLINE_SYSCALL_ASM (exit_group, 1, status);
  115. #endif
  116. - INLINE_SYSCALL (exit, 1, status);
  117. + INLINE_SYSCALL_ASM (exit, 1, status);
  118. #ifdef ABORT_INSTRUCTION
  119. ABORT_INSTRUCTION;
  120. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/cancellation.S b/sysdeps/unix/sysv/linux/x86_64/cancellation.S
  121. --- a/sysdeps/unix/sysv/linux/x86_64/cancellation.S
  122. +++ b/sysdeps/unix/sysv/linux/x86_64/cancellation.S
  123. @@ -109,7 +109,7 @@ ENTRY(__pthread_disable_asynccancel)
  124. xorq %r10, %r10
  125. addq $CANCELHANDLING, %rdi
  126. LOAD_PRIVATE_FUTEX_WAIT (%esi)
  127. - syscall
  128. + SYSCALLDB
  129. movl %fs:CANCELHANDLING, %eax
  130. jmp 3b
  131. END(__pthread_disable_asynccancel)
  132. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/clone.S b/sysdeps/unix/sysv/linux/x86_64/clone.S
  133. --- a/sysdeps/unix/sysv/linux/x86_64/clone.S
  134. +++ b/sysdeps/unix/sysv/linux/x86_64/clone.S
  135. @@ -73,7 +73,7 @@ ENTRY (__clone)
  136. /* End FDE now, because in the child the unwind info will be
  137. wrong. */
  138. cfi_endproc;
  139. - syscall
  140. + SYSCALLDB
  141. testq %rax,%rax
  142. jl SYSCALL_ERROR_LABEL
  143. @@ -96,7 +96,7 @@ L(thread_start):
  144. /* Call exit with return value from function call. */
  145. movq %rax, %rdi
  146. movl $SYS_ify(exit), %eax
  147. - syscall
  148. + SYSCALLDB
  149. cfi_endproc;
  150. cfi_startproc;
  151. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/getcontext.S b/sysdeps/unix/sysv/linux/x86_64/getcontext.S
  152. --- a/sysdeps/unix/sysv/linux/x86_64/getcontext.S
  153. +++ b/sysdeps/unix/sysv/linux/x86_64/getcontext.S
  154. @@ -75,7 +75,7 @@ ENTRY(__getcontext)
  155. #endif
  156. movl $_NSIG8,%r10d
  157. movl $__NR_rt_sigprocmask, %eax
  158. - syscall
  159. + SYSCALLDB
  160. cmpq $-4095, %rax /* Check %rax for error. */
  161. jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
  162. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S b/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
  163. --- a/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
  164. +++ b/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
  165. @@ -84,7 +84,7 @@ ENTRY(____longjmp_chk)
  166. xorl %edi, %edi
  167. lea -sizeSS(%rsp), %RSI_LP
  168. movl $__NR_sigaltstack, %eax
  169. - syscall
  170. + SYSCALLDB
  171. /* Without working sigaltstack we cannot perform the test. */
  172. testl %eax, %eax
  173. jne .Lok2
  174. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S b/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
  175. --- a/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
  176. +++ b/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
  177. @@ -90,7 +90,7 @@ __lll_lock_wait_private:
  178. 1: LIBC_PROBE (lll_lock_wait_private, 1, %rdi)
  179. movl $SYS_futex, %eax
  180. - syscall
  181. + SYSCALLDB
  182. 2: movl %edx, %eax
  183. xchgl %eax, (%rdi) /* NB: lock is implied */
  184. @@ -130,7 +130,7 @@ __lll_lock_wait:
  185. 1: LIBC_PROBE (lll_lock_wait, 2, %rdi, %rsi)
  186. movl $SYS_futex, %eax
  187. - syscall
  188. + SYSCALLDB
  189. 2: movl %edx, %eax
  190. xchgl %eax, (%rdi) /* NB: lock is implied */
  191. @@ -185,7 +185,7 @@ __lll_timedlock_wait:
  192. 1: movl $SYS_futex, %eax
  193. movl $2, %edx
  194. - syscall
  195. + SYSCALLDB
  196. 2: xchgl %edx, (%rdi) /* NB: lock is implied */
  197. @@ -279,7 +279,7 @@ __lll_timedlock_wait:
  198. LOAD_FUTEX_WAIT (%esi)
  199. movq %r12, %rdi
  200. movl $SYS_futex, %eax
  201. - syscall
  202. + SYSCALLDB
  203. /* NB: %edx == 2 */
  204. xchgl %edx, (%r12)
  205. @@ -336,7 +336,7 @@ __lll_unlock_wake_private:
  206. LOAD_PRIVATE_FUTEX_WAKE (%esi)
  207. movl $1, %edx /* Wake one thread. */
  208. movl $SYS_futex, %eax
  209. - syscall
  210. + SYSCALLDB
  211. popq %rdx
  212. cfi_adjust_cfa_offset(-8)
  213. @@ -366,7 +366,7 @@ __lll_unlock_wake:
  214. LOAD_FUTEX_WAKE (%esi)
  215. movl $1, %edx /* Wake one thread. */
  216. movl $SYS_futex, %eax
  217. - syscall
  218. + SYSCALLDB
  219. popq %rdx
  220. cfi_adjust_cfa_offset(-8)
  221. @@ -436,7 +436,7 @@ __lll_timedwait_tid:
  222. #endif
  223. movq %r12, %rdi
  224. movl $SYS_futex, %eax
  225. - syscall
  226. + SYSCALLDB
  227. cmpl $0, (%rdi)
  228. jne 1f
  229. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/setcontext.S b/sysdeps/unix/sysv/linux/x86_64/setcontext.S
  230. --- a/sysdeps/unix/sysv/linux/x86_64/setcontext.S
  231. +++ b/sysdeps/unix/sysv/linux/x86_64/setcontext.S
  232. @@ -43,7 +43,7 @@ ENTRY(__setcontext)
  233. movl $SIG_SETMASK, %edi
  234. movl $_NSIG8,%r10d
  235. movl $__NR_rt_sigprocmask, %eax
  236. - syscall
  237. + SYSCALLDB
  238. popq %rdi /* Reload %rdi, adjust stack. */
  239. cfi_adjust_cfa_offset(-8)
  240. cmpq $-4095, %rax /* Check %rax for error. */
  241. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/sigaction.c b/sysdeps/unix/sysv/linux/x86_64/sigaction.c
  242. --- a/sysdeps/unix/sysv/linux/x86_64/sigaction.c
  243. +++ b/sysdeps/unix/sysv/linux/x86_64/sigaction.c
  244. @@ -120,7 +120,7 @@ asm \
  245. " .type __" #name ",@function\n" \
  246. "__" #name ":\n" \
  247. " movq $" #syscall ", %rax\n" \
  248. - " syscall\n" \
  249. + SYSCALLDB_ASM \
  250. ".LEND_" #name ":\n" \
  251. ".section .eh_frame,\"a\",@progbits\n" \
  252. ".LSTARTFRAME_" #name ":\n" \
  253. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/swapcontext.S b/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
  254. --- a/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
  255. +++ b/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
  256. @@ -75,7 +75,7 @@ ENTRY(__swapcontext)
  257. movl $SIG_SETMASK, %edi
  258. movl $_NSIG8,%r10d
  259. movl $__NR_rt_sigprocmask, %eax
  260. - syscall
  261. + SYSCALLDB
  262. cmpq $-4095, %rax /* Check %rax for error. */
  263. jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
  264. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/syscall.S b/sysdeps/unix/sysv/linux/x86_64/syscall.S
  265. --- a/sysdeps/unix/sysv/linux/x86_64/syscall.S
  266. +++ b/sysdeps/unix/sysv/linux/x86_64/syscall.S
  267. @@ -34,7 +34,7 @@ ENTRY (syscall)
  268. movq %r8, %r10
  269. movq %r9, %r8
  270. movq 8(%rsp),%r9 /* arg6 is on the stack. */
  271. - syscall /* Do the system call. */
  272. + SYSCALLDB /* Do the system call. */
  273. cmpq $-4095, %rax /* Check %rax for error. */
  274. jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
  275. ret /* Return to caller. */
  276. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  277. --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  278. +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  279. @@ -22,6 +22,7 @@
  280. #include <sysdeps/unix/sysv/linux/sysdep.h>
  281. #include <sysdeps/unix/x86_64/sysdep.h>
  282. #include <tls.h>
  283. +#include "syscalldb.h"
  284. #if IS_IN (rtld)
  285. # include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
  286. @@ -177,7 +178,7 @@
  287. # define DO_CALL(syscall_name, args) \
  288. DOARGS_##args \
  289. movl $SYS_ify (syscall_name), %eax; \
  290. - syscall;
  291. + SYSCALLDB;
  292. # define DOARGS_0 /* nothing */
  293. # define DOARGS_1 /* nothing */
  294. @@ -191,9 +192,20 @@
  295. /* Define a macro which expands inline into the wrapper code for a system
  296. call. */
  297. # undef INLINE_SYSCALL
  298. -# define INLINE_SYSCALL(name, nr, args...) \
  299. +# define INLINE_SYSCALL(name, nr_args...) \
  300. ({ \
  301. - unsigned long int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
  302. + unsigned long int resultvar = INTERNAL_SYSCALL (name, , ##nr_args); \
  303. + if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, ))) \
  304. + { \
  305. + __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
  306. + resultvar = (unsigned long int) -1; \
  307. + } \
  308. + (long int) resultvar; })
  309. +
  310. +# undef INLINE_SYSCALL_ASM
  311. +# define INLINE_SYSCALL_ASM(name, nr_args...) \
  312. + ({ \
  313. + unsigned long int resultvar = INTERNAL_SYSCALL_ASM (name, , ##nr_args); \
  314. if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, ))) \
  315. { \
  316. __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
  317. @@ -205,9 +217,9 @@
  318. into the wrapper code for a system call. It should be used when size
  319. of any argument > size of long int. */
  320. # undef INLINE_SYSCALL_TYPES
  321. -# define INLINE_SYSCALL_TYPES(name, nr, args...) \
  322. +# define INLINE_SYSCALL_TYPES(name, nr_args...) \
  323. ({ \
  324. - unsigned long int resultvar = INTERNAL_SYSCALL_TYPES (name, , nr, args); \
  325. + unsigned long int resultvar = INTERNAL_SYSCALL_TYPES (name, , ##nr_args); \
  326. if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, ))) \
  327. { \
  328. __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
  329. @@ -236,12 +248,19 @@
  330. #define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
  331. internal_syscall##nr (number, err, args)
  332. +#undef INTERNAL_SYSCALL_ASM
  333. +#define INTERNAL_SYSCALL_ASM(name, err, nr, args...) \
  334. + INTERNAL_SYSCALL_NCS_ASM (SYS_ify (name), err, nr, args)
  335. +
  336. +#undef INTERNAL_SYSCALL_NCS_ASM
  337. +#define INTERNAL_SYSCALL_NCS_ASM INTERNAL_SYSCALL_NCS
  338. +
  339. #undef internal_syscall0
  340. #define internal_syscall0(number, err, dummy...) \
  341. ({ \
  342. unsigned long int resultvar; \
  343. asm volatile ( \
  344. - "syscall\n\t" \
  345. + SYSCALLDB \
  346. : "=a" (resultvar) \
  347. : "0" (number) \
  348. : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
  349. @@ -255,7 +270,7 @@
  350. TYPEFY (arg1, __arg1) = ARGIFY (arg1); \
  351. register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
  352. asm volatile ( \
  353. - "syscall\n\t" \
  354. + SYSCALLDB \
  355. : "=a" (resultvar) \
  356. : "0" (number), "r" (_a1) \
  357. : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
  358. @@ -271,7 +286,7 @@
  359. register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
  360. register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
  361. asm volatile ( \
  362. - "syscall\n\t" \
  363. + SYSCALLDB \
  364. : "=a" (resultvar) \
  365. : "0" (number), "r" (_a1), "r" (_a2) \
  366. : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
  367. @@ -289,7 +304,7 @@
  368. register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
  369. register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
  370. asm volatile ( \
  371. - "syscall\n\t" \
  372. + SYSCALLDB \
  373. : "=a" (resultvar) \
  374. : "0" (number), "r" (_a1), "r" (_a2), "r" (_a3) \
  375. : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
  376. @@ -309,7 +324,7 @@
  377. register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
  378. register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
  379. asm volatile ( \
  380. - "syscall\n\t" \
  381. + SYSCALLDB \
  382. : "=a" (resultvar) \
  383. : "0" (number), "r" (_a1), "r" (_a2), "r" (_a3), "r" (_a4) \
  384. : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
  385. @@ -331,7 +346,7 @@
  386. register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
  387. register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
  388. asm volatile ( \
  389. - "syscall\n\t" \
  390. + SYSCALLDB \
  391. : "=a" (resultvar) \
  392. : "0" (number), "r" (_a1), "r" (_a2), "r" (_a3), "r" (_a4), \
  393. "r" (_a5) \
  394. @@ -356,7 +371,7 @@
  395. register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
  396. register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
  397. asm volatile ( \
  398. - "syscall\n\t" \
  399. + SYSCALLDB \
  400. : "=a" (resultvar) \
  401. : "0" (number), "r" (_a1), "r" (_a2), "r" (_a3), "r" (_a4), \
  402. "r" (_a5), "r" (_a6) \
  403. diff -ruNp a/sysdeps/unix/sysv/linux/x86_64/vfork.S b/sysdeps/unix/sysv/linux/x86_64/vfork.S
  404. --- a/sysdeps/unix/sysv/linux/x86_64/vfork.S
  405. +++ b/sysdeps/unix/sysv/linux/x86_64/vfork.S
  406. @@ -36,7 +36,7 @@ ENTRY (__vfork)
  407. /* Stuff the syscall number in RAX and enter into the kernel. */
  408. movl $SYS_ify (vfork), %eax
  409. - syscall
  410. + SYSCALLDB
  411. /* Push back the return PC. */
  412. pushq %rdi
  413. diff -ruNp a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
  414. --- a/sysdeps/x86_64/dl-machine.h
  415. +++ b/sysdeps/x86_64/dl-machine.h
  416. @@ -577,7 +577,8 @@ elf_machine_lazy_rel (struct link_map *m
  417. value = ((ElfW(Addr) (*) (void)) value) ();
  418. *reloc_addr = value;
  419. }
  420. - else
  421. + /* for graphene, get around R_X86_64_NONE */
  422. + else if (__builtin_expect (r_type != R_X86_64_NONE, 1))
  423. _dl_reloc_bad_type (map, r_type, 1);
  424. }
  425. diff -ruNp a/sysdeps/x86_64/nptl/tls.h b/sysdeps/x86_64/nptl/tls.h
  426. --- a/sysdeps/x86_64/nptl/tls.h
  427. +++ b/sysdeps/x86_64/nptl/tls.h
  428. @@ -29,6 +29,8 @@
  429. # include <libc-pointer-arith.h> /* For cast_to_integer. */
  430. # include <kernel-features.h>
  431. # include <dl-dtv.h>
  432. +# include <shim_tls.h>
  433. +# include <syscalldb.h>
  434. /* Replacement type for __m128 since this file is included by ld.so,
  435. which is compiled with -mno-sse. It must not change the alignment
  436. @@ -56,6 +58,10 @@ typedef struct
  437. # else
  438. int __glibc_reserved1;
  439. # endif
  440. +
  441. + shim_tcb_t shim_tcb; /* For graphene, we allocate a shim_tcb
  442. + in the real tcb. */
  443. +
  444. int __glibc_unused1;
  445. /* Reservation of some values for the TM ABI. */
  446. void *__private_tm[4];
  447. @@ -144,7 +149,7 @@ typedef struct
  448. _head->self = _thrdescr; \
  449. \
  450. /* It is a simple syscall to set the %fs value for the thread. */ \
  451. - asm volatile ("syscall" \
  452. + asm volatile (SYSCALLDB \
  453. : "=a" (_result) \
  454. : "0" ((unsigned long int) __NR_arch_prctl), \
  455. "D" ((unsigned long int) ARCH_SET_FS), \