glibc-2.19.patch 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347
  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. diff --git a/Makefile b/Makefile
  15. index 51d4690..d72c4b0 100644
  16. --- a/Makefile
  17. +++ b/Makefile
  18. @@ -177,6 +177,8 @@ $(inst_includedir)/gnu/stubs.h: $(+force)
  19. install-others-nosubdir: $(installed-stubs)
  20. endif
  21. +# For Graphene
  22. +CFLAGS-syscalldb.c = -fPIC
  23. # Since stubs.h is never needed when building the library, we simplify the
  24. # hairy installation process by producing it in place only as the last part
  25. diff --git a/Versions.def b/Versions.def
  26. index 759c754..e1a270e 100644
  27. --- a/Versions.def
  28. +++ b/Versions.def
  29. @@ -41,6 +41,7 @@ libc {
  30. GCC_3.0
  31. %endif
  32. GLIBC_PRIVATE
  33. + SHIM
  34. }
  35. libcrypt {
  36. GLIBC_2.0
  37. @@ -50,6 +51,7 @@ libdl {
  38. GLIBC_2.1
  39. GLIBC_2.3.3
  40. GLIBC_2.3.4
  41. + SHIM
  42. }
  43. libm {
  44. GLIBC_2.0
  45. @@ -108,6 +110,7 @@ libpthread {
  46. GLIBC_2.18
  47. GLIBC_2.19
  48. GLIBC_PRIVATE
  49. + SHIM
  50. }
  51. libresolv {
  52. GLIBC_2.0
  53. @@ -135,6 +138,7 @@ ld {
  54. GLIBC_2.3
  55. GLIBC_2.4
  56. GLIBC_PRIVATE
  57. + SHIM
  58. }
  59. libthread_db {
  60. GLIBC_2.1.3
  61. diff --git a/dlfcn/Versions b/dlfcn/Versions
  62. index 97902f0..c1874c1 100644
  63. --- a/dlfcn/Versions
  64. +++ b/dlfcn/Versions
  65. @@ -14,4 +14,7 @@ libdl {
  66. GLIBC_PRIVATE {
  67. _dlfcn_hook;
  68. }
  69. + SHIM {
  70. + syscalldb;
  71. + }
  72. }
  73. diff --git a/elf/Makefile b/elf/Makefile
  74. index 4c58fc9..0ae2fa8 100644
  75. --- a/elf/Makefile
  76. +++ b/elf/Makefile
  77. @@ -21,7 +21,7 @@ subdir := elf
  78. include ../Makeconfig
  79. -headers = elf.h bits/elfclass.h link.h bits/link.h
  80. +headers = elf.h bits/elfclass.h link.h bits/link.h syscalldb.h
  81. routines = $(dl-routines) dl-support dl-iteratephdr \
  82. dl-addr enbl-secure dl-profstub \
  83. dl-origin dl-libc dl-sym dl-tsd dl-sysdep
  84. @@ -31,7 +31,8 @@ routines = $(dl-routines) dl-support dl-iteratephdr \
  85. dl-routines = $(addprefix dl-,load lookup object reloc deps hwcaps \
  86. runtime error init fini debug misc \
  87. version profile conflict tls origin scope \
  88. - execstack caller open close trampoline)
  89. + execstack caller open close trampoline) \
  90. + syscalldb syscallas
  91. ifeq (yes,$(use-ldconfig))
  92. dl-routines += dl-cache
  93. endif
  94. diff --git a/elf/Versions b/elf/Versions
  95. index 2383992..98687f6 100644
  96. --- a/elf/Versions
  97. +++ b/elf/Versions
  98. @@ -24,6 +24,9 @@ libc {
  99. _dl_sym; _dl_vsym;
  100. __libc_dlclose; __libc_dlopen_mode; __libc_dlsym;
  101. }
  102. + SHIM {
  103. + syscalldb; glibc_option;
  104. + }
  105. }
  106. ld {
  107. @@ -62,4 +65,7 @@ ld {
  108. # Pointer protection.
  109. __pointer_chk_guard;
  110. }
  111. + SHIM {
  112. + syscalldb; glibc_version; glibc_option; register_library;
  113. + }
  114. }
  115. diff --git a/elf/dl-debug.c b/elf/dl-debug.c
  116. index 4e7c593..3e0bff4 100644
  117. --- a/elf/dl-debug.c
  118. +++ b/elf/dl-debug.c
  119. @@ -34,7 +34,7 @@ extern const int verify_link_map_members
  120. normally finds it via the DT_DEBUG entry in the dynamic section, but in
  121. a statically-linked program there is no dynamic section for the debugger
  122. to examine and it looks for this particular symbol name. */
  123. -struct r_debug _r_debug;
  124. +struct r_debug __libc_r_debug;
  125. /* Initialize _r_debug if it has not already been done. The argument is
  126. @@ -48,7 +48,7 @@ _dl_debug_initialize (ElfW(Addr) ldbase,
  127. struct r_debug *r;
  128. if (ns == LM_ID_BASE)
  129. - r = &_r_debug;
  130. + r = &__libc_r_debug;
  131. else
  132. r = &GL(dl_ns)[ns]._ns_debug;
  133. @@ -56,9 +56,9 @@ _dl_debug_initialize (ElfW(Addr) ldbase,
  134. {
  135. /* Tell the debugger where to find the map of loaded objects. */
  136. r->r_version = 1 /* R_DEBUG_VERSION XXX */;
  137. - r->r_ldbase = ldbase ?: _r_debug.r_ldbase;
  138. + r->r_ldbase = ldbase ?: __libc_r_debug.r_ldbase;
  139. r->r_map = (void *) GL(dl_ns)[ns]._ns_loaded;
  140. r->r_brk = (ElfW(Addr)) &_dl_debug_state;
  141. }
  142. return r;
  143. diff --git a/elf/dl-load.c b/elf/dl-load.c
  144. index 1be7a3c..c560ec1 100644
  145. --- a/elf/dl-load.c
  146. +++ b/elf/dl-load.c
  147. @@ -39,6 +39,8 @@
  148. #include <dl-dst.h>
  149. +#include <glibc-version.h>
  150. +
  151. /* On some systems, no flag bits are given to specify file mapping. */
  152. #ifndef MAP_FILE
  153. # define MAP_FILE 0
  154. @@ -1595,6 +1597,9 @@ cannot enable executable stack as shared object requires");
  155. DL_AFTER_LOAD (l);
  156. #endif
  157. + /* register the library to SHIM */
  158. + register_library(l->l_name, l->l_addr);
  159. +
  160. /* Now that the object is fully initialized add it to the object list. */
  161. _dl_add_to_namespace_list (l, nsid);
  162. diff --git a/elf/link.h b/elf/link.h
  163. index d5905d1..f4e108a 100644
  164. --- a/elf/link.h
  165. +++ b/elf/link.h
  166. @@ -65,6 +65,7 @@ struct r_debug
  167. /* This is the instance of that structure used by the dynamic linker. */
  168. extern struct r_debug _r_debug;
  169. +asm (".symver _r_debug, __libc_r_debug@GLIBC_PRIVATE");
  170. /* This symbol refers to the "dynamic structure" in the `.dynamic' section
  171. of whatever module refers to `_DYNAMIC'. So, to find its own
  172. diff --git a/elf/rtld.c b/elf/rtld.c
  173. index 6dcbabc..c87c773 100644
  174. --- a/elf/rtld.c
  175. +++ b/elf/rtld.c
  176. @@ -356,6 +356,23 @@ _dl_start_final (void *arg, struct dl_start_final_info *info)
  177. return start_addr;
  178. }
  179. +/* For graphene, check if glibc version match to the compatible SHIM
  180. + library. If not, tell the user to update glibc. */
  181. +#include "glibc-version.h"
  182. +
  183. +volatile const int glibc_version __attribute__((weak)) = GLIBC_VERSION;
  184. +
  185. +static void __attribute__((noinline,optimize("-O0")))
  186. +check_glibc_version (void)
  187. +{
  188. + if (glibc_version != GLIBC_VERSION)
  189. + {
  190. + _dl_fatal_printf ("Warning from Graphene: "
  191. + "Glibc version is incorrect. Please rebuild Glibc.\n");
  192. + _exit (1);
  193. + }
  194. +}
  195. +
  196. static ElfW(Addr) __attribute_used__ internal_function
  197. _dl_start (void *arg)
  198. {
  199. @@ -546,6 +563,9 @@ _dl_start (void *arg)
  200. therefore need not test whether we have to allocate the array
  201. for the relocation results (as done in dl-reloc.c). */
  202. + /* For Graphene, check if the glibc version is correct. */
  203. + check_glibc_version();
  204. +
  205. /* Now life is sane; we can call functions and access global data.
  206. Set up to use the operating system facilities, and find out from
  207. the operating system's program loader where to find the program
  208. diff --git a/malloc/arena.c b/malloc/arena.c
  209. index 5088a25..33a3879 100644
  210. --- a/malloc/arena.c
  211. +++ b/malloc/arena.c
  212. @@ -21,6 +21,27 @@
  213. /* Compile-time constants. */
  214. +#ifndef HEAP_MAX_SIZE
  215. +# ifdef DEFAULT_MMAP_THRESHOLD_MAX
  216. +# define DEFAULT_HEAP_MAX_SIZE (2 * DEFAULT_MMAP_THRESHOLD_MAX)
  217. +# else
  218. +# define DEFAULT_HEAP_MAX_SIZE (1024 * 1024) /* must be a power of two */
  219. +# endif
  220. +# include <sysdep.h>
  221. +static long int heap_max_size = 0;
  222. +# define HEAP_MAX_SIZE \
  223. + ({ \
  224. + if (!heap_max_size) { \
  225. + long int size = glibc_option("heap_size"); \
  226. + if (size > 0) \
  227. + heap_max_size = size; \
  228. + else \
  229. + heap_max_size = DEFAULT_HEAP_MAX_SIZE; \
  230. + } \
  231. + heap_max_size; \
  232. + })
  233. +#endif
  234. +
  235. #define HEAP_MIN_SIZE (32 * 1024)
  236. #ifndef HEAP_MAX_SIZE
  237. # ifdef DEFAULT_MMAP_THRESHOLD_MAX
  238. @@ -545,17 +566,6 @@ new_heap (size_t size, size_t top_pad)
  239. mapping (on Linux, this is the case for all non-writable mappings
  240. anyway). */
  241. p2 = MAP_FAILED;
  242. - if (aligned_heap_area)
  243. - {
  244. - p2 = (char *) MMAP (aligned_heap_area, HEAP_MAX_SIZE, PROT_NONE,
  245. - MAP_NORESERVE);
  246. - aligned_heap_area = NULL;
  247. - if (p2 != MAP_FAILED && ((unsigned long) p2 & (HEAP_MAX_SIZE - 1)))
  248. - {
  249. - __munmap (p2, HEAP_MAX_SIZE);
  250. - p2 = MAP_FAILED;
  251. - }
  252. - }
  253. if (p2 == MAP_FAILED)
  254. {
  255. p1 = (char *) MMAP (0, HEAP_MAX_SIZE << 1, PROT_NONE, MAP_NORESERVE);
  256. @@ -566,8 +576,6 @@ new_heap (size_t size, size_t top_pad)
  257. ul = p2 - p1;
  258. if (ul)
  259. __munmap (p1, ul);
  260. - else
  261. - aligned_heap_area = p2 + HEAP_MAX_SIZE;
  262. __munmap (p2 + HEAP_MAX_SIZE, HEAP_MAX_SIZE - ul);
  263. }
  264. else
  265. diff --git a/nptl/Makefile b/nptl/Makefile
  266. index 57cc8c6..81f1bf4 100644
  267. --- a/nptl/Makefile
  268. +++ b/nptl/Makefile
  269. @@ -20,7 +20,7 @@
  270. #
  271. subdir := nptl
  272. -headers := pthread.h semaphore.h bits/semaphore.h
  273. +headers := pthread.h semaphore.h bits/semaphore.h syscalldb.h
  274. extra-libs := libpthread
  275. extra-libs-others := $(extra-libs)
  276. diff --git a/nptl/Versions b/nptl/Versions
  277. index bb11277..354149a 100644
  278. --- a/nptl/Versions
  279. +++ b/nptl/Versions
  280. @@ -31,6 +31,9 @@ libc {
  281. # Internal libc interface to libpthread
  282. __libc_dl_error_tsd;
  283. }
  284. + SHIM {
  285. + syscalldb; glibc_option;
  286. + }
  287. }
  288. libpthread {
  289. @@ -262,4 +265,8 @@ libpthread {
  290. __pthread_clock_gettime; __pthread_clock_settime;
  291. __pthread_unwind; __pthread_get_minstack;
  292. }
  293. +
  294. + SHIM {
  295. + syscalldb; glibc_option;
  296. + }
  297. }
  298. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S b/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S
  299. index 89fda5e..f6963f6 100644
  300. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S
  301. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S
  302. @@ -111,7 +111,8 @@ ENTRY(__pthread_disable_asynccancel)
  303. xorq %r10, %r10
  304. addq $CANCELHANDLING, %rdi
  305. LOAD_PRIVATE_FUTEX_WAIT (%esi)
  306. - syscall
  307. + SYSCALLDB
  308. +
  309. movl %fs:CANCELHANDLING, %eax
  310. jmp 3b
  311. END(__pthread_disable_asynccancel)
  312. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
  313. index f2dca07..0ce7c67 100644
  314. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
  315. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
  316. @@ -90,7 +90,7 @@ __lll_lock_wait_private:
  317. 1: LIBC_PROBE (lll_lock_wait_private, 1, %rdi)
  318. movl $SYS_futex, %eax
  319. - syscall
  320. + SYSCALLDB
  321. 2: movl %edx, %eax
  322. xchgl %eax, (%rdi) /* NB: lock is implied */
  323. @@ -130,7 +130,7 @@ __lll_lock_wait:
  324. 1: LIBC_PROBE (lll_lock_wait, 2, %rdi, %rsi)
  325. movl $SYS_futex, %eax
  326. - syscall
  327. + SYSCALLDB
  328. 2: movl %edx, %eax
  329. xchgl %eax, (%rdi) /* NB: lock is implied */
  330. @@ -185,7 +185,7 @@ __lll_timedlock_wait:
  331. 1: movl $SYS_futex, %eax
  332. movl $2, %edx
  333. - syscall
  334. + SYSCALLDB
  335. 2: xchgl %edx, (%rdi) /* NB: lock is implied */
  336. @@ -279,7 +279,7 @@ __lll_timedlock_wait:
  337. LOAD_FUTEX_WAIT (%esi)
  338. movq %r12, %rdi
  339. movl $SYS_futex, %eax
  340. - syscall
  341. + SYSCALLDB
  342. /* NB: %edx == 2 */
  343. xchgl %edx, (%r12)
  344. @@ -336,7 +336,7 @@ __lll_unlock_wake_private:
  345. LOAD_PRIVATE_FUTEX_WAKE (%esi)
  346. movl $1, %edx /* Wake one thread. */
  347. movl $SYS_futex, %eax
  348. - syscall
  349. + SYSCALLDB
  350. popq %rdx
  351. cfi_adjust_cfa_offset(-8)
  352. @@ -366,7 +366,7 @@ __lll_unlock_wake:
  353. LOAD_FUTEX_WAKE (%esi)
  354. movl $1, %edx /* Wake one thread. */
  355. movl $SYS_futex, %eax
  356. - syscall
  357. + SYSCALLDB
  358. popq %rdx
  359. cfi_adjust_cfa_offset(-8)
  360. @@ -435,7 +435,7 @@ __lll_timedwait_tid:
  361. #endif
  362. movq %r12, %rdi
  363. movl $SYS_futex, %eax
  364. - syscall
  365. + SYSCALLDB
  366. cmpl $0, (%rdi)
  367. jne 1f
  368. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
  369. index 0a26739..8aae14a 100644
  370. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
  371. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
  372. @@ -214,7 +214,7 @@ LLL_STUB_UNWIND_INFO_END
  373. register const struct timespec *__to __asm ("r10") = timeout; \
  374. int __status; \
  375. register __typeof (val) _val __asm ("edx") = (val); \
  376. - __asm __volatile ("syscall" \
  377. + __asm __volatile (SYSCALLDB \
  378. : "=a" (__status) \
  379. : "0" (SYS_futex), "D" (futex), \
  380. "S" (__lll_private_flag (FUTEX_WAIT, private)), \
  381. @@ -229,7 +229,7 @@ LLL_STUB_UNWIND_INFO_END
  382. int __status; \
  383. register __typeof (nr) _nr __asm ("edx") = (nr); \
  384. LIBC_PROBE (lll_futex_wake, 3, futex, nr, private); \
  385. - __asm __volatile ("syscall" \
  386. + __asm __volatile (SYSCALLDB \
  387. : "=a" (__status) \
  388. : "0" (SYS_futex), "D" (futex), \
  389. "S" (__lll_private_flag (FUTEX_WAKE, private)), \
  390. @@ -540,7 +540,7 @@ extern int __lll_timedlock_elision (int *futex, short *adapt_count,
  391. { \
  392. int ignore; \
  393. __asm __volatile (LOCK_INSTR "orl %3, (%2)\n\t" \
  394. - "syscall" \
  395. + SYSCALLDB \
  396. : "=m" (futex), "=a" (ignore) \
  397. : "D" (&(futex)), "i" (FUTEX_OWNER_DIED), \
  398. "S" (__lll_private_flag (FUTEX_WAKE, private)), \
  399. @@ -555,7 +555,7 @@ extern int __lll_timedlock_elision (int *futex, short *adapt_count,
  400. register int __nr_move __asm ("r10") = nr_move; \
  401. register void *__mutex __asm ("r8") = mutex; \
  402. register int __val __asm ("r9") = val; \
  403. - __asm __volatile ("syscall" \
  404. + __asm __volatile (SYSCALLDB \
  405. : "=a" (__res) \
  406. : "0" (__NR_futex), "D" ((void *) ftx), \
  407. "S" (__lll_private_flag (FUTEX_CMP_REQUEUE, \
  408. @@ -581,7 +581,7 @@ extern int __lll_timedlock_elision (int *futex, short *adapt_count,
  409. if (_tid != 0) \
  410. __asm __volatile ("xorq %%r10, %%r10\n\t" \
  411. "1:\tmovq %2, %%rax\n\t" \
  412. - "syscall\n\t" \
  413. + SYSCALLDB \
  414. "cmpl $0, (%%rdi)\n\t" \
  415. "jne 1b" \
  416. : "=&a" (__ignore) \
  417. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
  418. index 990b6f9..b01214d 100644
  419. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
  420. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
  421. @@ -80,7 +80,7 @@ __lll_robust_lock_wait:
  422. jnz 2f
  423. 1: movl $SYS_futex, %eax
  424. - syscall
  425. + SYSCALLDB
  426. movl (%rdi), %eax
  427. @@ -145,7 +145,7 @@ __lll_robust_timedlock_wait:
  428. jnz 6f
  429. 5: movl $SYS_futex, %eax
  430. - syscall
  431. + SYSCALLDB
  432. movl %eax, %ecx
  433. movl (%rdi), %eax
  434. @@ -257,7 +257,7 @@ __lll_robust_timedlock_wait:
  435. LOAD_FUTEX_WAIT (%esi)
  436. movq %r12, %rdi
  437. movl $SYS_futex, %eax
  438. - syscall
  439. + SYSCALLDB
  440. movq %rax, %rcx
  441. movl (%r12), %eax
  442. 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
  443. index eec17f2..a350340 100644
  444. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S
  445. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S
  446. @@ -62,7 +62,7 @@ pthread_barrier_wait:
  447. #endif
  448. xorq %r10, %r10
  449. 8: movl $SYS_futex, %eax
  450. - syscall
  451. + SYSCALLDB
  452. /* Don't return on spurious wakeups. The syscall does not change
  453. any register except %eax so there is no need to reload any of
  454. @@ -109,7 +109,7 @@ pthread_barrier_wait:
  455. movl $FUTEX_WAKE, %esi
  456. orl PRIVATE(%rdi), %esi
  457. movl $SYS_futex, %eax
  458. - syscall
  459. + SYSCALLDB
  460. /* Increment LEFT. If this brings the count back to the
  461. initial count unlock the object. */
  462. 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
  463. index 985e0f1..d559456 100644
  464. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
  465. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
  466. @@ -90,7 +90,7 @@ __pthread_cond_broadcast:
  467. movl $SYS_futex, %eax
  468. movl $1, %edx
  469. movl $0x7fffffff, %r10d
  470. - syscall
  471. + SYSCALLDB
  472. /* For any kind of error, which mainly is EAGAIN, we try again
  473. with WAKE. The general test also covers running on old
  474. @@ -106,7 +106,7 @@ __pthread_cond_broadcast:
  475. movl $SYS_futex, %eax
  476. movl $1, %edx
  477. movl $0x7fffffff, %r10d
  478. - syscall
  479. + SYSCALLDB
  480. /* For any kind of error, which mainly is EAGAIN, we try again
  481. with WAKE. The general test also covers running on old
  482. @@ -172,7 +172,7 @@ __pthread_cond_broadcast:
  483. orl $FUTEX_WAKE, %esi
  484. #endif
  485. movl $SYS_futex, %eax
  486. - syscall
  487. + SYSCALLDB
  488. jmp 10b
  489. .size __pthread_cond_broadcast, .-__pthread_cond_broadcast
  490. versioned_symbol (libpthread, __pthread_cond_broadcast, pthread_cond_broadcast,
  491. 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
  492. index 53d65b6..16df581 100644
  493. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
  494. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
  495. @@ -82,7 +82,7 @@ __pthread_cond_signal:
  496. addq $cond_lock, %r8
  497. #endif
  498. movl $FUTEX_OP_CLEAR_WAKE_IF_GT_ONE, %r9d
  499. - syscall
  500. + SYSCALLDB
  501. #if cond_lock != 0
  502. subq $cond_lock, %r8
  503. #endif
  504. @@ -99,7 +99,7 @@ __pthread_cond_signal:
  505. movq %rcx, %r8
  506. xorq %r10, %r10
  507. movl (%rdi), %r9d // XXX Can this be right?
  508. - syscall
  509. + SYSCALLDB
  510. leaq -cond_futex(%rdi), %r8
  511. @@ -118,7 +118,7 @@ __pthread_cond_signal:
  512. movl $SYS_futex, %eax
  513. /* %rdx should be 1 already from $FUTEX_WAKE_OP syscall.
  514. movl $1, %edx */
  515. - syscall
  516. + SYSCALLDB
  517. /* Unlock. */
  518. 4: LOCK
  519. 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
  520. index 0dc2340..8aff242 100644
  521. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
  522. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
  523. @@ -188,7 +188,7 @@ __pthread_cond_timedwait:
  524. movq %r12, %rdx
  525. addq $cond_futex, %rdi
  526. movl $SYS_futex, %eax
  527. - syscall
  528. + SYSCALLDB
  529. cmpl $0, %eax
  530. sete %r15b
  531. @@ -234,7 +234,7 @@ __pthread_cond_timedwait:
  532. movq %r12, %rdx
  533. addq $cond_futex, %rdi
  534. movl $SYS_futex, %eax
  535. - syscall
  536. + SYSCALLDB
  537. 62: movq %rax, %r14
  538. movl (%rsp), %edi
  539. @@ -321,7 +321,7 @@ __pthread_cond_timedwait:
  540. orl $FUTEX_WAKE, %esi
  541. #endif
  542. movl $SYS_futex, %eax
  543. - syscall
  544. + SYSCALLDB
  545. subq $cond_nwaiters, %rdi
  546. 55: LOCK
  547. @@ -485,15 +485,8 @@ __pthread_cond_timedwait:
  548. /* Only clocks 0 and 1 are allowed so far. Both are handled in the
  549. kernel. */
  550. leaq 32(%rsp), %rsi
  551. -# ifdef SHARED
  552. - mov __vdso_clock_gettime@GOTPCREL(%rip), %RAX_LP
  553. - mov (%rax), %RAX_LP
  554. - PTR_DEMANGLE (%RAX_LP)
  555. - call *%rax
  556. -# else
  557. movl $__NR_clock_gettime, %eax
  558. - syscall
  559. -# endif
  560. + SYSCALLDB
  561. /* Compute relative timeout. */
  562. movq (%r13), %rcx
  563. @@ -560,7 +553,7 @@ __pthread_cond_timedwait:
  564. # endif
  565. addq $cond_futex, %rdi
  566. movl $SYS_futex, %eax
  567. - syscall
  568. + SYSCALLDB
  569. movq %rax, %r14
  570. movl (%rsp), %edi
  571. @@ -732,7 +725,7 @@ __condvar_cleanup2:
  572. orl $FUTEX_WAKE, %esi
  573. #endif
  574. movl $SYS_futex, %eax
  575. - syscall
  576. + SYSCALLDB
  577. subq $cond_nwaiters, %rdi
  578. movl $1, %r12d
  579. @@ -769,7 +762,7 @@ __condvar_cleanup2:
  580. orl $FUTEX_WAKE, %esi
  581. #endif
  582. movl $SYS_futex, %eax
  583. - syscall
  584. + SYSCALLDB
  585. /* Lock the mutex only if we don't own it already. This only happens
  586. in case of PI mutexes, if we got cancelled after a successful
  587. 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
  588. index 0e61d0a..b4bcc15 100644
  589. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
  590. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
  591. @@ -138,7 +138,7 @@ __pthread_cond_wait:
  592. movl $(FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %esi
  593. movl $SYS_futex, %eax
  594. - syscall
  595. + SYSCALLDB
  596. cmpl $0, %eax
  597. sete %r8b
  598. @@ -180,7 +180,7 @@ __pthread_cond_wait:
  599. #endif
  600. 60: xorb %r8b, %r8b
  601. movl $SYS_futex, %eax
  602. - syscall
  603. + SYSCALLDB
  604. 62: movl (%rsp), %edi
  605. callq __pthread_disable_asynccancel
  606. @@ -239,7 +239,7 @@ __pthread_cond_wait:
  607. orl $FUTEX_WAKE, %esi
  608. #endif
  609. movl $SYS_futex, %eax
  610. - syscall
  611. + SYSCALLDB
  612. subq $cond_nwaiters, %rdi
  613. 17: LOCK
  614. @@ -455,7 +455,7 @@ __condvar_cleanup1:
  615. orl $FUTEX_WAKE, %esi
  616. #endif
  617. movl $SYS_futex, %eax
  618. - syscall
  619. + SYSCALLDB
  620. subq $cond_nwaiters, %rdi
  621. movl $1, %ecx
  622. @@ -493,7 +493,7 @@ __condvar_cleanup1:
  623. orl $FUTEX_WAKE, %esi
  624. #endif
  625. movl $SYS_futex, %eax
  626. - syscall
  627. + SYSCALLDB
  628. /* Lock the mutex only if we don't own it already. This only happens
  629. in case of PI mutexes, if we got cancelled after a successful
  630. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
  631. index 2cbe2fa..489998a 100644
  632. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
  633. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
  634. @@ -90,7 +90,7 @@ __pthread_once:
  635. # endif
  636. #endif
  637. movl $SYS_futex, %eax
  638. - syscall
  639. + SYSCALLDB
  640. jmp 6b
  641. /* Preserve the pointer to the control variable. */
  642. @@ -123,7 +123,7 @@ __pthread_once:
  643. orl %fs:PRIVATE_FUTEX, %esi
  644. #endif
  645. movl $SYS_futex, %eax
  646. - syscall
  647. + SYSCALLDB
  648. 4: addq $8, %rsp
  649. cfi_adjust_cfa_offset(-8)
  650. @@ -152,7 +152,7 @@ clear_once_control:
  651. orl %fs:PRIVATE_FUTEX, %esi
  652. #endif
  653. movl $SYS_futex, %eax
  654. - syscall
  655. + SYSCALLDB
  656. movq %r8, %rdi
  657. .LcallUR:
  658. 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
  659. index 3bbb4c7..53d5ca6 100644
  660. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
  661. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
  662. @@ -82,7 +82,7 @@ __pthread_rwlock_rdlock:
  663. #endif
  664. addq $READERS_WAKEUP, %rdi
  665. movl $SYS_futex, %eax
  666. - syscall
  667. + SYSCALLDB
  668. subq $READERS_WAKEUP, %rdi
  669. 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
  670. index 40bcc04..348170e 100644
  671. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
  672. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
  673. @@ -109,7 +109,7 @@ pthread_rwlock_timedrdlock:
  674. #endif
  675. 21: leaq READERS_WAKEUP(%r12), %rdi
  676. movl $SYS_futex, %eax
  677. - syscall
  678. + SYSCALLDB
  679. movq %rax, %rdx
  680. #ifndef __ASSUME_FUTEX_CLOCK_REALTIME
  681. 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
  682. index f57ef52..e9ac77f 100644
  683. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
  684. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
  685. @@ -106,7 +106,7 @@ pthread_rwlock_timedwrlock:
  686. #endif
  687. 21: leaq WRITERS_WAKEUP(%r12), %rdi
  688. movl $SYS_futex, %eax
  689. - syscall
  690. + SYSCALLDB
  691. movq %rax, %rdx
  692. #ifndef __ASSUME_FUTEX_CLOCK_REALTIME
  693. 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
  694. index d779f7b..849c74f 100644
  695. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
  696. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
  697. @@ -79,7 +79,7 @@ __pthread_rwlock_unlock:
  698. #endif
  699. movl $SYS_futex, %eax
  700. movq %r10, %rdi
  701. - syscall
  702. + SYSCALLDB
  703. xorl %eax, %eax
  704. retq
  705. 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
  706. index e444def..fd94930 100644
  707. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
  708. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
  709. @@ -80,7 +80,7 @@ __pthread_rwlock_wrlock:
  710. #endif
  711. addq $WRITERS_WAKEUP, %rdi
  712. movl $SYS_futex, %eax
  713. - syscall
  714. + SYSCALLDB
  715. subq $WRITERS_WAKEUP, %rdi
  716. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
  717. index 1c11600..bd166cf 100644
  718. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
  719. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
  720. @@ -52,7 +52,7 @@ sem_post:
  721. movl $FUTEX_WAKE, %esi
  722. orl PRIVATE(%rdi), %esi
  723. movl $1, %edx
  724. - syscall
  725. + SYSCALLDB
  726. testq %rax, %rax
  727. js 1f
  728. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
  729. index 880610e..e520049 100644
  730. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
  731. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
  732. @@ -97,7 +97,7 @@ sem_timedwait:
  733. orl PRIVATE(%rdi), %esi
  734. movl $SYS_futex, %eax
  735. xorl %edx, %edx
  736. - syscall
  737. + SYSCALLDB
  738. movq %rax, %r9
  739. #if VALUE != 0
  740. leaq -VALUE(%rdi), %rdi
  741. @@ -233,7 +233,7 @@ sem_timedwait:
  742. # endif
  743. movl $SYS_futex, %eax
  744. xorl %edx, %edx
  745. - syscall
  746. + SYSCALLDB
  747. movq %rax, %r14
  748. movl 16(%rsp), %edi
  749. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
  750. index 8f4d068..fe6dfbf 100644
  751. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
  752. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
  753. @@ -81,7 +81,7 @@ sem_wait:
  754. orl PRIVATE(%rdi), %esi
  755. #endif
  756. xorl %edx, %edx
  757. - syscall
  758. + SYSCALLDB
  759. movq %rax, %rcx
  760. xchgq %r8, %rdi
  761. diff --git a/nptl/sysdeps/x86_64/pthreaddef.h b/nptl/sysdeps/x86_64/pthreaddef.h
  762. index 18a15a1..f050241 100644
  763. --- a/nptl/sysdeps/x86_64/pthreaddef.h
  764. +++ b/nptl/sysdeps/x86_64/pthreaddef.h
  765. @@ -48,4 +48,4 @@
  766. /* While there is no such syscall. */
  767. #define __exit_thread_inline(val) \
  768. - asm volatile ("syscall" :: "a" (__NR_exit), "D" (val))
  769. + asm volatile (SYSCALLDB :: "a" (__NR_exit), "D" (val))
  770. diff --git a/nptl/sysdeps/x86_64/tls.h b/nptl/sysdeps/x86_64/tls.h
  771. index cbb5e9e..9b87e25 100644
  772. --- a/nptl/sysdeps/x86_64/tls.h
  773. +++ b/nptl/sysdeps/x86_64/tls.h
  774. @@ -28,6 +28,8 @@
  775. # include <sysdep.h>
  776. # include <libc-internal.h>
  777. # include <kernel-features.h>
  778. +# include <shim_tls.h>
  779. +# include <syscalldb.h>
  780. /* Replacement type for __m128 since this file is included by ld.so,
  781. which is compiled with -mno-sse. It must not change the alignment
  782. @@ -67,6 +69,10 @@ typedef struct
  783. # else
  784. int __glibc_reserved1;
  785. # endif
  786. +
  787. + shim_tcb_t shim_tcb; /* For graphene, we allocate a shim_tcb
  788. + in the real tcb. */
  789. +
  790. int rtld_must_xmm_save;
  791. /* Reservation of some values for the TM ABI. */
  792. void *__private_tm[4];
  793. @@ -137,7 +143,6 @@ typedef struct
  794. # define GET_DTV(descr) \
  795. (((tcbhead_t *) (descr))->dtv)
  796. -
  797. /* Code to initially initialize the thread pointer. This might need
  798. special attention since 'errno' is not yet available and if the
  799. operation can cause a failure 'errno' must not be touched.
  800. @@ -154,7 +159,7 @@ typedef struct
  801. _head->self = _thrdescr; \
  802. \
  803. /* It is a simple syscall to set the %fs value for the thread. */ \
  804. - asm volatile ("syscall" \
  805. + asm volatile (SYSCALLDB \
  806. : "=a" (_result) \
  807. : "0" ((unsigned long int) __NR_arch_prctl), \
  808. "D" ((unsigned long int) ARCH_SET_FS), \
  809. diff --git a/scripts/mkinstalldirs b/scripts/mkinstalldirs
  810. index 55d537f..57bf12b 100755
  811. --- a/scripts/mkinstalldirs
  812. +++ b/scripts/mkinstalldirs
  813. @@ -126,9 +126,9 @@ do
  814. esac
  815. if test ! -d "$pathcomp"; then
  816. - echo "mkdir $pathcomp"
  817. + echo "mkdir -p $pathcomp"
  818. - mkdir "$pathcomp" || lasterr=$?
  819. + mkdir -p "$pathcomp" || lasterr=$?
  820. if test ! -d "$pathcomp"; then
  821. errstatus=$lasterr
  822. diff --git a/sysdeps/unix/sysv/linux/_exit.c b/sysdeps/unix/sysv/linux/_exit.c
  823. index 2468228..a9f1cd6 100644
  824. --- a/sysdeps/unix/sysv/linux/_exit.c
  825. +++ b/sysdeps/unix/sysv/linux/_exit.c
  826. @@ -29,9 +29,9 @@ _exit (status)
  827. while (1)
  828. {
  829. #ifdef __NR_exit_group
  830. - INLINE_SYSCALL (exit_group, 1, status);
  831. + INLINE_SYSCALL_ASM (exit_group, 1, status);
  832. #endif
  833. - INLINE_SYSCALL (exit, 1, status);
  834. + INLINE_SYSCALL_ASM (exit, 1, status);
  835. #ifdef ABORT_INSTRUCTION
  836. ABORT_INSTRUCTION;
  837. diff --git a/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S b/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
  838. index 49f0384..6b1a975 100644
  839. --- a/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
  840. +++ b/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
  841. @@ -84,7 +84,8 @@ ENTRY(____longjmp_chk)
  842. xorl %edi, %edi
  843. lea -sizeSS(%rsp), %RSI_LP
  844. movl $__NR_sigaltstack, %eax
  845. - syscall
  846. + SYSCALLDB
  847. +
  848. /* Without working sigaltstack we cannot perform the test. */
  849. testl %eax, %eax
  850. jne .Lok2
  851. diff --git a/sysdeps/unix/sysv/linux/x86_64/clock_gettime.c b/sysdeps/unix/sysv/linux/x86_64/clock_gettime.c
  852. index f712110..f6bad14 100644
  853. --- a/sysdeps/unix/sysv/linux/x86_64/clock_gettime.c
  854. +++ b/sysdeps/unix/sysv/linux/x86_64/clock_gettime.c
  855. @@ -1,5 +1,6 @@
  856. #include "bits/libc-vdso.h"
  857. +#if 0 /* in Graphene, disallow VDSO calls */
  858. #ifdef SHARED
  859. # define SYSCALL_GETTIME(id, tp) \
  860. ({ long int (*f) (clockid_t, struct timespec *) = __vdso_clock_gettime; \
  861. @@ -16,5 +17,6 @@
  862. PTR_DEMANGLE (f); \
  863. f (id, tp); })
  864. #endif
  865. +#endif
  866. #include "../clock_gettime.c"
  867. diff --git a/sysdeps/unix/sysv/linux/x86_64/clone.S b/sysdeps/unix/sysv/linux/x86_64/clone.S
  868. index 0508730..e1b35ec 100644
  869. --- a/sysdeps/unix/sysv/linux/x86_64/clone.S
  870. +++ b/sysdeps/unix/sysv/linux/x86_64/clone.S
  871. @@ -76,5 +80,5 @@ ENTRY (__clone)
  872. /* End FDE now, because in the child the unwind info will be
  873. wrong. */
  874. cfi_endproc;
  875. - syscall
  876. + SYSCALLDB
  877. @@ -99,10 +104,10 @@ L(thread_start):
  878. movl $-1, %eax
  879. jne 2f
  880. movl $SYS_ify(getpid), %eax
  881. - syscall
  882. + SYSCALLDB
  883. 2: movl %eax, %fs:PID
  884. movl %eax, %fs:TID
  885. 1:
  886. #endif
  887. /* Set up arguments for the function call. */
  888. diff --git a/sysdeps/unix/sysv/linux/x86_64/getcontext.S b/sysdeps/unix/sysv/linux/x86_64/getcontext.S
  889. index 140db03..6967f10 100644
  890. --- a/sysdeps/unix/sysv/linux/x86_64/getcontext.S
  891. +++ b/sysdeps/unix/sysv/linux/x86_64/getcontext.S
  892. @@ -75,7 +75,7 @@ ENTRY(__getcontext)
  893. #endif
  894. movl $_NSIG8,%r10d
  895. movl $__NR_rt_sigprocmask, %eax
  896. - syscall
  897. + SYSCALLDB
  898. cmpq $-4095, %rax /* Check %rax for error. */
  899. jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
  900. diff --git a/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c b/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c
  901. index 440ca7f..571125d 100644
  902. --- a/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c
  903. +++ b/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c
  904. @@ -17,6 +17,7 @@
  905. #include <sys/time.h>
  906. +#if 0 /* In graphene, do not use vsyscall or VDSO call */
  907. #ifdef SHARED
  908. # include <dl-vdso.h>
  909. @@ -42,7 +43,8 @@ asm (".type __gettimeofday, %gnu_indirect_function");
  910. asm (".globl __GI___gettimeofday\n"
  911. "__GI___gettimeofday = __gettimeofday");
  912. -#else
  913. +#endif
  914. +#endif
  915. # include <sysdep.h>
  916. # include <errno.h>
  917. @@ -54,6 +56,5 @@ __gettimeofday (struct timeval *tv, struct timezone *tz)
  918. }
  919. libc_hidden_def (__gettimeofday)
  920. -#endif
  921. weak_alias (__gettimeofday, gettimeofday)
  922. libc_hidden_weak (gettimeofday)
  923. diff --git a/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S b/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
  924. index 0fd47f2..7a82975 100644
  925. --- a/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
  926. +++ b/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
  927. @@ -30,6 +30,7 @@ ENTRY (sched_getcpu)
  928. sub $0x8, %rsp
  929. cfi_adjust_cfa_offset(8)
  930. +#if 0 /* for Graphene, never do VDSO calls */
  931. movq %rsp, %rdi
  932. xorl %esi, %esi
  933. movl $VGETCPU_CACHE_OFFSET, %edx
  934. @@ -39,16 +40,19 @@ ENTRY (sched_getcpu)
  935. movq __vdso_getcpu(%rip), %rax
  936. PTR_DEMANGLE (%rax)
  937. callq *%rax
  938. -#else
  939. -# ifdef __NR_getcpu
  940. +#endif
  941. +#endif
  942. +
  943. +#ifdef __NR_getcpu
  944. movl $__NR_getcpu, %eax
  945. - syscall
  946. -# ifndef __ASSUME_GETCPU_SYSCALL
  947. + SYSCALLDB
  948. +#endif
  949. +
  950. +#if 0 /* for Graphene, never do vsyscall */
  951. +# ifndef __ASSUME_GETCPU_SYSCALL
  952. cmpq $-ENOSYS, %rax
  953. jne 1f
  954. -# endif
  955. -# endif
  956. -# ifndef __ASSUME_GETCPU_SYSCALL
  957. +
  958. movq $VSYSCALL_ADDR_vgetcpu, %rax
  959. callq *%rax
  960. 1:
  961. diff --git a/sysdeps/unix/sysv/linux/x86_64/setcontext.S b/sysdeps/unix/sysv/linux/x86_64/setcontext.S
  962. index b726fa0..bb3ae34 100644
  963. --- a/sysdeps/unix/sysv/linux/x86_64/setcontext.S
  964. +++ b/sysdeps/unix/sysv/linux/x86_64/setcontext.S
  965. @@ -43,7 +43,7 @@ ENTRY(__setcontext)
  966. movl $SIG_SETMASK, %edi
  967. movl $_NSIG8,%r10d
  968. movl $__NR_rt_sigprocmask, %eax
  969. - syscall
  970. + SYSCALLDB
  971. popq %rdi /* Reload %rdi, adjust stack. */
  972. cfi_adjust_cfa_offset(-8)
  973. cmpq $-4095, %rax /* Check %rax for error. */
  974. diff --git a/sysdeps/unix/sysv/linux/x86_64/sigaction.c b/sysdeps/unix/sysv/linux/x86_64/sigaction.c
  975. index ab23985..38a6b69 100644
  976. --- a/sysdeps/unix/sysv/linux/x86_64/sigaction.c
  977. +++ b/sysdeps/unix/sysv/linux/x86_64/sigaction.c
  978. @@ -129,7 +129,7 @@ asm \
  979. " .type __" #name ",@function\n" \
  980. "__" #name ":\n" \
  981. " movq $" #syscall ", %rax\n" \
  982. - " syscall\n" \
  983. + SYSCALLDB_ASM \
  984. ".LEND_" #name ":\n" \
  985. ".section .eh_frame,\"a\",@progbits\n" \
  986. ".LSTARTFRAME_" #name ":\n" \
  987. diff --git a/sysdeps/unix/sysv/linux/x86_64/swapcontext.S b/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
  988. index b3854fa..6369bfe 100644
  989. --- a/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
  990. +++ b/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
  991. @@ -75,7 +75,7 @@ ENTRY(__swapcontext)
  992. movl $SIG_SETMASK, %edi
  993. movl $_NSIG8,%r10d
  994. movl $__NR_rt_sigprocmask, %eax
  995. - syscall
  996. + SYSCALLDB
  997. cmpq $-4095, %rax /* Check %rax for error. */
  998. jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
  999. diff --git a/sysdeps/unix/sysv/linux/x86_64/syscall.S b/sysdeps/unix/sysv/linux/x86_64/syscall.S
  1000. index 92c2f5b..e32ebb2 100644
  1001. --- a/sysdeps/unix/sysv/linux/x86_64/syscall.S
  1002. +++ b/sysdeps/unix/sysv/linux/x86_64/syscall.S
  1003. @@ -31,10 +31,12 @@
  1004. movq %rsi, %rdi /* shift arg1 - arg5. */
  1005. movq %rdx, %rsi
  1006. movq %rcx, %rdx
  1007. + /* DEP 8/17/17: Keep kernel calling
  1008. + * convention and fix in libOS */
  1009. movq %r8, %r10
  1010. movq %r9, %r8
  1011. movq 8(%rsp),%r9 /* arg6 is on the stack. */
  1012. - syscall /* Do the system call. */
  1013. + SYSCALLDB /* Do the system call. */
  1014. cmpq $-4095, %rax /* Check %rax for error. */
  1015. jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
  1016. ret /* Return to caller. */
  1017. diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  1018. index 4a9a9d9..dc452ed 100644
  1019. --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  1020. +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  1021. @@ -21,6 +21,7 @@
  1022. /* There is some commonality. */
  1023. #include <sysdeps/unix/x86_64/sysdep.h>
  1024. #include <tls.h>
  1025. +#include "syscalldb.h"
  1026. #ifdef IS_IN_rtld
  1027. # include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
  1028. @@ -176,7 +177,7 @@
  1029. # define DO_CALL(syscall_name, args) \
  1030. DOARGS_##args \
  1031. movl $SYS_ify (syscall_name), %eax; \
  1032. - syscall;
  1033. + SYSCALLDB
  1034. # define DOARGS_0 /* nothing */
  1035. # define DOARGS_1 /* nothing */
  1036. @@ -190,9 +191,20 @@
  1037. /* Define a macro which expands inline into the wrapper code for a system
  1038. call. */
  1039. # undef INLINE_SYSCALL
  1040. -# define INLINE_SYSCALL(name, nr, args...) \
  1041. +# define INLINE_SYSCALL(name, nr_args...) \
  1042. ({ \
  1043. - unsigned long int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
  1044. + unsigned long int resultvar = INTERNAL_SYSCALL (name, , ##nr_args); \
  1045. + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
  1046. + { \
  1047. + __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
  1048. + resultvar = (unsigned long int) -1; \
  1049. + } \
  1050. + (long int) resultvar; })
  1051. +
  1052. +# undef INLINE_SYSCALL_ASM
  1053. +# define INLINE_SYSCALL_ASM(name, nr_args...) \
  1054. + ({ \
  1055. + unsigned long int resultvar = INTERNAL_SYSCALL_ASM (name, , ##nr_args); \
  1056. if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
  1057. { \
  1058. __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
  1059. @@ -204,9 +216,9 @@
  1060. into the wrapper code for a system call. It should be used when size
  1061. of any argument > size of long int. */
  1062. # undef INLINE_SYSCALL_TYPES
  1063. -# define INLINE_SYSCALL_TYPES(name, nr, args...) \
  1064. +# define INLINE_SYSCALL_TYPES(name, nr_args...) \
  1065. ({ \
  1066. - unsigned long int resultvar = INTERNAL_SYSCALL_TYPES (name, , nr, args); \
  1067. + unsigned long int resultvar = INTERNAL_SYSCALL_TYPES (name, , ##nr_args); \
  1068. if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
  1069. { \
  1070. __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
  1071. @@ -223,13 +235,19 @@
  1072. LOAD_ARGS_##nr (args) \
  1073. LOAD_REGS_##nr \
  1074. asm volatile ( \
  1075. - "syscall\n\t" \
  1076. + SYSCALLDB \
  1077. : "=a" (resultvar) \
  1078. : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx"); \
  1079. (long int) resultvar; })
  1080. +# define INTERNAL_SYSCALL_NCS_ASM INTERNAL_SYSCALL_NCS
  1081. +
  1082. # undef INTERNAL_SYSCALL
  1083. -# define INTERNAL_SYSCALL(name, err, nr, args...) \
  1084. - INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
  1085. +# define INTERNAL_SYSCALL(name, err, nr_args...) \
  1086. + INTERNAL_SYSCALL_NCS (__NR_##name, err, ##nr_args)
  1087. +
  1088. +# undef INTERNAL_SYSCALL_ASM
  1089. +# define INTERNAL_SYSCALL_ASM(name, err, nr_args...) \
  1090. + INTERNAL_SYSCALL_NCS_ASM (__NR_##name, err, ##nr_args)
  1091. # define INTERNAL_SYSCALL_NCS_TYPES(name, err, nr, args...) \
  1092. ({ \
  1093. @@ -237,7 +255,7 @@
  1094. LOAD_ARGS_TYPES_##nr (args) \
  1095. LOAD_REGS_TYPES_##nr (args) \
  1096. asm volatile ( \
  1097. - "syscall\n\t" \
  1098. + SYSCALLDB \
  1099. : "=a" (resultvar) \
  1100. : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx"); \
  1101. (long int) resultvar; })
  1102. @@ -252,6 +270,7 @@
  1103. # undef INTERNAL_SYSCALL_ERRNO
  1104. # define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
  1105. +# if 0 /* for Graphene, never do vsyscall */
  1106. # ifdef SHARED
  1107. # define INLINE_VSYSCALL(name, nr, args...) \
  1108. ({ \
  1109. @@ -300,12 +319,13 @@
  1110. v_ret; \
  1111. })
  1112. -# else
  1113. -# define INLINE_VSYSCALL(name, nr, args...) \
  1114. - INLINE_SYSCALL (name, nr, ##args)
  1115. -# define INTERNAL_VSYSCALL(name, err, nr, args...) \
  1116. - INTERNAL_SYSCALL (name, err, nr, ##args)
  1117. # endif
  1118. +# endif
  1119. +
  1120. +# define INLINE_VSYSCALL(name, nr_args...) \
  1121. + INLINE_SYSCALL (name, ##nr_args)
  1122. +# define INTERNAL_VSYSCALL(name, err, nr_args...) \
  1123. + INTERNAL_SYSCALL (name, err, ##nr_args)
  1124. # define LOAD_ARGS_0()
  1125. # define LOAD_REGS_0
  1126. diff --git a/sysdeps/unix/sysv/linux/x86_64/time.c b/sysdeps/unix/sysv/linux/x86_64/time.c
  1127. deleted file mode 100644
  1128. index 79f1fab..0000000
  1129. --- a/sysdeps/unix/sysv/linux/x86_64/time.c
  1130. +++ /dev/null
  1131. @@ -1,60 +0,0 @@
  1132. -/* Copyright (C) 2001-2014 Free Software Foundation, Inc.
  1133. - This file is part of the GNU C Library.
  1134. -
  1135. - The GNU C Library is free software; you can redistribute it and/or
  1136. - modify it under the terms of the GNU Lesser General Public
  1137. - License as published by the Free Software Foundation; either
  1138. - version 2.1 of the License, or (at your option) any later version.
  1139. -
  1140. - The GNU C Library is distributed in the hope that it will be useful,
  1141. - but WITHOUT ANY WARRANTY; without even the implied warranty of
  1142. - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  1143. - Lesser General Public License for more details.
  1144. -
  1145. - You should have received a copy of the GNU Lesser General Public
  1146. - License along with the GNU C Library; if not, see
  1147. - <http://www.gnu.org/licenses/>. */
  1148. -
  1149. -#ifdef SHARED
  1150. -/* Redefine time so that the compiler won't complain about the type
  1151. - mismatch with the IFUNC selector in strong_alias, below. */
  1152. -#undef time
  1153. -#define time __redirect_time
  1154. -#include <time.h>
  1155. -
  1156. -#include <dl-vdso.h>
  1157. -
  1158. -#define VSYSCALL_ADDR_vtime 0xffffffffff600400
  1159. -
  1160. -/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
  1161. - ifunc symbol properly. */
  1162. -extern __typeof (__redirect_time) __libc_time;
  1163. -void *time_ifunc (void) __asm__ ("__libc_time");
  1164. -
  1165. -void *
  1166. -time_ifunc (void)
  1167. -{
  1168. - PREPARE_VERSION (linux26, "LINUX_2.6", 61765110);
  1169. -
  1170. - /* If the vDSO is not available we fall back on the old vsyscall. */
  1171. - return _dl_vdso_vsym ("__vdso_time", &linux26) ?: (void *) VSYSCALL_ADDR_vtime;
  1172. -}
  1173. -__asm (".type __libc_time, %gnu_indirect_function");
  1174. -
  1175. -#undef time
  1176. -strong_alias (__libc_time, time)
  1177. -libc_hidden_ver (__libc_time, time)
  1178. -
  1179. -#else
  1180. -
  1181. -# include <time.h>
  1182. -# include <sysdep.h>
  1183. -
  1184. -time_t
  1185. -time (time_t *t)
  1186. -{
  1187. - INTERNAL_SYSCALL_DECL (err);
  1188. - return INTERNAL_SYSCALL (time, err, 1, t);
  1189. -}
  1190. -
  1191. -#endif
  1192. diff --git a/sysdeps/unix/sysv/linux/x86_64/vfork.S b/sysdeps/unix/sysv/linux/x86_64/vfork.S
  1193. index d3b450a..75a63e1 100644
  1194. --- a/sysdeps/unix/sysv/linux/x86_64/vfork.S
  1195. +++ b/sysdeps/unix/sysv/linux/x86_64/vfork.S
  1196. @@ -38,7 +38,7 @@ ENTRY (__vfork)
  1197. /* Stuff the syscall number in RAX and enter into the kernel. */
  1198. movl $SYS_ify (vfork), %eax
  1199. - syscall
  1200. + SYSCALLDB
  1201. /* Push back the return PC. */
  1202. pushq %rdi
  1203. diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
  1204. index 504c95f..dcfc259 100644
  1205. --- a/sysdeps/x86_64/dl-machine.h
  1206. +++ b/sysdeps/x86_64/dl-machine.h
  1207. @@ -529,7 +529,8 @@ elf_machine_lazy_rel (struct link_map *map,
  1208. value = ((ElfW(Addr) (*) (void)) value) ();
  1209. *reloc_addr = value;
  1210. }
  1211. - else
  1212. + /* for graphene, get around R_X86_64_NONE */
  1213. + else if (__builtin_expect (r_type != R_X86_64_NONE, 1))
  1214. _dl_reloc_bad_type (map, r_type, 1);
  1215. }
  1216. diff --git a/sysdeps/x86_64/hp-timing.h b/sysdeps/x86_64/hp-timing.h
  1217. index d88206c..886c500 100644
  1218. --- a/sysdeps/x86_64/hp-timing.h
  1219. +++ b/sysdeps/x86_64/hp-timing.h
  1220. @@ -18,23 +18,6 @@
  1221. #ifndef _HP_TIMING_H
  1222. -/* We can use some of the i686 implementation without changes. */
  1223. -# include <sysdeps/i386/i686/hp-timing.h>
  1224. -
  1225. -/* The "=A" constraint used in 32-bit mode does not work in 64-bit mode. */
  1226. -# undef HP_TIMING_NOW
  1227. -# define HP_TIMING_NOW(Var) \
  1228. - ({ unsigned int _hi, _lo; \
  1229. - asm volatile ("rdtsc" : "=a" (_lo), "=d" (_hi)); \
  1230. - (Var) = ((unsigned long long int) _hi << 32) | _lo; })
  1231. -
  1232. -/* The funny business for 32-bit mode is not required here. */
  1233. -# undef HP_TIMING_ACCUM
  1234. -# define HP_TIMING_ACCUM(Sum, Diff) \
  1235. - do { \
  1236. - hp_timing_t __diff = (Diff) - GLRO(dl_hp_timing_overhead); \
  1237. - __asm__ __volatile__ ("lock; addq %1, %0" \
  1238. - : "=m" (Sum) : "r" (__diff), "m" (Sum)); \
  1239. - } while (0)
  1240. +# include <sysdeps/generic/hp-timing.h>
  1241. #endif /* hp-timing.h */