glibc-2.19.patch 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172
  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. @@ -493,6 +488,6 @@
  548. # else
  549. movl $__NR_clock_gettime, %eax
  550. - syscall
  551. + SYSCALLDB
  552. # endif
  553. /* Compute relative timeout. */
  554. @@ -560,7 +553,7 @@ __pthread_cond_timedwait:
  555. # endif
  556. addq $cond_futex, %rdi
  557. movl $SYS_futex, %eax
  558. - syscall
  559. + SYSCALLDB
  560. movq %rax, %r14
  561. movl (%rsp), %edi
  562. @@ -732,7 +725,7 @@ __condvar_cleanup2:
  563. orl $FUTEX_WAKE, %esi
  564. #endif
  565. movl $SYS_futex, %eax
  566. - syscall
  567. + SYSCALLDB
  568. subq $cond_nwaiters, %rdi
  569. movl $1, %r12d
  570. @@ -769,7 +762,7 @@ __condvar_cleanup2:
  571. orl $FUTEX_WAKE, %esi
  572. #endif
  573. movl $SYS_futex, %eax
  574. - syscall
  575. + SYSCALLDB
  576. /* Lock the mutex only if we don't own it already. This only happens
  577. in case of PI mutexes, if we got cancelled after a successful
  578. 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
  579. index 0e61d0a..b4bcc15 100644
  580. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
  581. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
  582. @@ -138,7 +138,7 @@ __pthread_cond_wait:
  583. movl $(FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %esi
  584. movl $SYS_futex, %eax
  585. - syscall
  586. + SYSCALLDB
  587. cmpl $0, %eax
  588. sete %r8b
  589. @@ -180,7 +180,7 @@ __pthread_cond_wait:
  590. #endif
  591. 60: xorb %r8b, %r8b
  592. movl $SYS_futex, %eax
  593. - syscall
  594. + SYSCALLDB
  595. 62: movl (%rsp), %edi
  596. callq __pthread_disable_asynccancel
  597. @@ -239,7 +239,7 @@ __pthread_cond_wait:
  598. orl $FUTEX_WAKE, %esi
  599. #endif
  600. movl $SYS_futex, %eax
  601. - syscall
  602. + SYSCALLDB
  603. subq $cond_nwaiters, %rdi
  604. 17: LOCK
  605. @@ -455,7 +455,7 @@ __condvar_cleanup1:
  606. orl $FUTEX_WAKE, %esi
  607. #endif
  608. movl $SYS_futex, %eax
  609. - syscall
  610. + SYSCALLDB
  611. subq $cond_nwaiters, %rdi
  612. movl $1, %ecx
  613. @@ -493,7 +493,7 @@ __condvar_cleanup1:
  614. orl $FUTEX_WAKE, %esi
  615. #endif
  616. movl $SYS_futex, %eax
  617. - syscall
  618. + SYSCALLDB
  619. /* Lock the mutex only if we don't own it already. This only happens
  620. in case of PI mutexes, if we got cancelled after a successful
  621. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
  622. index 2cbe2fa..489998a 100644
  623. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
  624. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
  625. @@ -90,7 +90,7 @@ __pthread_once:
  626. # endif
  627. #endif
  628. movl $SYS_futex, %eax
  629. - syscall
  630. + SYSCALLDB
  631. jmp 6b
  632. /* Preserve the pointer to the control variable. */
  633. @@ -123,7 +123,7 @@ __pthread_once:
  634. orl %fs:PRIVATE_FUTEX, %esi
  635. #endif
  636. movl $SYS_futex, %eax
  637. - syscall
  638. + SYSCALLDB
  639. 4: addq $8, %rsp
  640. cfi_adjust_cfa_offset(-8)
  641. @@ -152,7 +152,7 @@ clear_once_control:
  642. orl %fs:PRIVATE_FUTEX, %esi
  643. #endif
  644. movl $SYS_futex, %eax
  645. - syscall
  646. + SYSCALLDB
  647. movq %r8, %rdi
  648. .LcallUR:
  649. 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
  650. index 3bbb4c7..53d5ca6 100644
  651. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
  652. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
  653. @@ -82,7 +82,7 @@ __pthread_rwlock_rdlock:
  654. #endif
  655. addq $READERS_WAKEUP, %rdi
  656. movl $SYS_futex, %eax
  657. - syscall
  658. + SYSCALLDB
  659. subq $READERS_WAKEUP, %rdi
  660. 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
  661. index 40bcc04..348170e 100644
  662. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
  663. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
  664. @@ -109,7 +109,7 @@ pthread_rwlock_timedrdlock:
  665. #endif
  666. 21: leaq READERS_WAKEUP(%r12), %rdi
  667. movl $SYS_futex, %eax
  668. - syscall
  669. + SYSCALLDB
  670. movq %rax, %rdx
  671. #ifndef __ASSUME_FUTEX_CLOCK_REALTIME
  672. 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
  673. index f57ef52..e9ac77f 100644
  674. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
  675. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
  676. @@ -106,7 +106,7 @@ pthread_rwlock_timedwrlock:
  677. #endif
  678. 21: leaq WRITERS_WAKEUP(%r12), %rdi
  679. movl $SYS_futex, %eax
  680. - syscall
  681. + SYSCALLDB
  682. movq %rax, %rdx
  683. #ifndef __ASSUME_FUTEX_CLOCK_REALTIME
  684. 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
  685. index d779f7b..849c74f 100644
  686. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
  687. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
  688. @@ -79,7 +79,7 @@ __pthread_rwlock_unlock:
  689. #endif
  690. movl $SYS_futex, %eax
  691. movq %r10, %rdi
  692. - syscall
  693. + SYSCALLDB
  694. xorl %eax, %eax
  695. retq
  696. 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
  697. index e444def..fd94930 100644
  698. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
  699. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
  700. @@ -80,7 +80,7 @@ __pthread_rwlock_wrlock:
  701. #endif
  702. addq $WRITERS_WAKEUP, %rdi
  703. movl $SYS_futex, %eax
  704. - syscall
  705. + SYSCALLDB
  706. subq $WRITERS_WAKEUP, %rdi
  707. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
  708. index 1c11600..bd166cf 100644
  709. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
  710. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
  711. @@ -52,7 +52,7 @@ sem_post:
  712. movl $FUTEX_WAKE, %esi
  713. orl PRIVATE(%rdi), %esi
  714. movl $1, %edx
  715. - syscall
  716. + SYSCALLDB
  717. testq %rax, %rax
  718. js 1f
  719. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
  720. index 880610e..e520049 100644
  721. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
  722. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
  723. @@ -97,7 +97,7 @@ sem_timedwait:
  724. orl PRIVATE(%rdi), %esi
  725. movl $SYS_futex, %eax
  726. xorl %edx, %edx
  727. - syscall
  728. + SYSCALLDB
  729. movq %rax, %r9
  730. #if VALUE != 0
  731. leaq -VALUE(%rdi), %rdi
  732. @@ -233,7 +233,7 @@ sem_timedwait:
  733. # endif
  734. movl $SYS_futex, %eax
  735. xorl %edx, %edx
  736. - syscall
  737. + SYSCALLDB
  738. movq %rax, %r14
  739. movl 16(%rsp), %edi
  740. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
  741. index 8f4d068..fe6dfbf 100644
  742. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
  743. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
  744. @@ -81,7 +81,7 @@ sem_wait:
  745. orl PRIVATE(%rdi), %esi
  746. #endif
  747. xorl %edx, %edx
  748. - syscall
  749. + SYSCALLDB
  750. movq %rax, %rcx
  751. xchgq %r8, %rdi
  752. diff --git a/nptl/sysdeps/x86_64/pthreaddef.h b/nptl/sysdeps/x86_64/pthreaddef.h
  753. index 18a15a1..f050241 100644
  754. --- a/nptl/sysdeps/x86_64/pthreaddef.h
  755. +++ b/nptl/sysdeps/x86_64/pthreaddef.h
  756. @@ -48,4 +48,4 @@
  757. /* While there is no such syscall. */
  758. #define __exit_thread_inline(val) \
  759. - asm volatile ("syscall" :: "a" (__NR_exit), "D" (val))
  760. + asm volatile (SYSCALLDB :: "a" (__NR_exit), "D" (val))
  761. diff --git a/nptl/sysdeps/x86_64/tls.h b/nptl/sysdeps/x86_64/tls.h
  762. index cbb5e9e..9b87e25 100644
  763. --- a/nptl/sysdeps/x86_64/tls.h
  764. +++ b/nptl/sysdeps/x86_64/tls.h
  765. @@ -28,6 +28,8 @@
  766. # include <sysdep.h>
  767. # include <libc-internal.h>
  768. # include <kernel-features.h>
  769. +# include <shim_tls.h>
  770. +# include <syscalldb.h>
  771. /* Replacement type for __m128 since this file is included by ld.so,
  772. which is compiled with -mno-sse. It must not change the alignment
  773. @@ -67,6 +69,10 @@ typedef struct
  774. # else
  775. int __glibc_reserved1;
  776. # endif
  777. +
  778. + shim_tcb_t shim_tcb; /* For graphene, we allocate a shim_tcb
  779. + in the real tcb. */
  780. +
  781. int rtld_must_xmm_save;
  782. /* Reservation of some values for the TM ABI. */
  783. void *__private_tm[4];
  784. @@ -137,7 +143,6 @@ typedef struct
  785. # define GET_DTV(descr) \
  786. (((tcbhead_t *) (descr))->dtv)
  787. -
  788. /* Code to initially initialize the thread pointer. This might need
  789. special attention since 'errno' is not yet available and if the
  790. operation can cause a failure 'errno' must not be touched.
  791. @@ -154,7 +159,7 @@ typedef struct
  792. _head->self = _thrdescr; \
  793. \
  794. /* It is a simple syscall to set the %fs value for the thread. */ \
  795. - asm volatile ("syscall" \
  796. + asm volatile (SYSCALLDB \
  797. : "=a" (_result) \
  798. : "0" ((unsigned long int) __NR_arch_prctl), \
  799. "D" ((unsigned long int) ARCH_SET_FS), \
  800. diff --git a/scripts/mkinstalldirs b/scripts/mkinstalldirs
  801. index 55d537f..57bf12b 100755
  802. --- a/scripts/mkinstalldirs
  803. +++ b/scripts/mkinstalldirs
  804. @@ -126,9 +126,9 @@ do
  805. esac
  806. if test ! -d "$pathcomp"; then
  807. - echo "mkdir $pathcomp"
  808. + echo "mkdir -p $pathcomp"
  809. - mkdir "$pathcomp" || lasterr=$?
  810. + mkdir -p "$pathcomp" || lasterr=$?
  811. if test ! -d "$pathcomp"; then
  812. errstatus=$lasterr
  813. diff --git a/sysdeps/unix/sysv/linux/_exit.c b/sysdeps/unix/sysv/linux/_exit.c
  814. index 2468228..a9f1cd6 100644
  815. --- a/sysdeps/unix/sysv/linux/_exit.c
  816. +++ b/sysdeps/unix/sysv/linux/_exit.c
  817. @@ -29,9 +29,9 @@ _exit (status)
  818. while (1)
  819. {
  820. #ifdef __NR_exit_group
  821. - INLINE_SYSCALL (exit_group, 1, status);
  822. + INLINE_SYSCALL_ASM (exit_group, 1, status);
  823. #endif
  824. - INLINE_SYSCALL (exit, 1, status);
  825. + INLINE_SYSCALL_ASM (exit, 1, status);
  826. #ifdef ABORT_INSTRUCTION
  827. ABORT_INSTRUCTION;
  828. diff --git a/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S b/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
  829. index 49f0384..6b1a975 100644
  830. --- a/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
  831. +++ b/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
  832. @@ -84,7 +84,8 @@ ENTRY(____longjmp_chk)
  833. xorl %edi, %edi
  834. lea -sizeSS(%rsp), %RSI_LP
  835. movl $__NR_sigaltstack, %eax
  836. - syscall
  837. + SYSCALLDB
  838. +
  839. /* Without working sigaltstack we cannot perform the test. */
  840. testl %eax, %eax
  841. jne .Lok2
  842. diff --git a/sysdeps/unix/sysv/linux/x86_64/clone.S b/sysdeps/unix/sysv/linux/x86_64/clone.S
  843. index 0508730..e1b35ec 100644
  844. --- a/sysdeps/unix/sysv/linux/x86_64/clone.S
  845. +++ b/sysdeps/unix/sysv/linux/x86_64/clone.S
  846. @@ -76,5 +80,5 @@ ENTRY (__clone)
  847. /* End FDE now, because in the child the unwind info will be
  848. wrong. */
  849. cfi_endproc;
  850. - syscall
  851. + SYSCALLDB
  852. @@ -99,10 +104,10 @@ L(thread_start):
  853. movl $-1, %eax
  854. jne 2f
  855. movl $SYS_ify(getpid), %eax
  856. - syscall
  857. + SYSCALLDB
  858. 2: movl %eax, %fs:PID
  859. movl %eax, %fs:TID
  860. 1:
  861. #endif
  862. /* Set up arguments for the function call. */
  863. diff --git a/sysdeps/unix/sysv/linux/x86_64/getcontext.S b/sysdeps/unix/sysv/linux/x86_64/getcontext.S
  864. index 140db03..6967f10 100644
  865. --- a/sysdeps/unix/sysv/linux/x86_64/getcontext.S
  866. +++ b/sysdeps/unix/sysv/linux/x86_64/getcontext.S
  867. @@ -75,7 +75,7 @@ ENTRY(__getcontext)
  868. #endif
  869. movl $_NSIG8,%r10d
  870. movl $__NR_rt_sigprocmask, %eax
  871. - syscall
  872. + SYSCALLDB
  873. cmpq $-4095, %rax /* Check %rax for error. */
  874. jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
  875. diff --git a/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S b/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
  876. index 0fd47f2..7a82975 100644
  877. --- a/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
  878. +++ b/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
  879. @@ -44,7 +45,7 @@
  880. #else
  881. # ifdef __NR_getcpu
  882. movl $__NR_getcpu, %eax
  883. - syscall
  884. + SYSCALLDB
  885. # ifndef __ASSUME_GETCPU_SYSCALL
  886. cmpq $-ENOSYS, %rax
  887. jne 1f
  888. diff --git a/sysdeps/unix/sysv/linux/x86_64/setcontext.S b/sysdeps/unix/sysv/linux/x86_64/setcontext.S
  889. index b726fa0..bb3ae34 100644
  890. --- a/sysdeps/unix/sysv/linux/x86_64/setcontext.S
  891. +++ b/sysdeps/unix/sysv/linux/x86_64/setcontext.S
  892. @@ -43,7 +43,7 @@ ENTRY(__setcontext)
  893. movl $SIG_SETMASK, %edi
  894. movl $_NSIG8,%r10d
  895. movl $__NR_rt_sigprocmask, %eax
  896. - syscall
  897. + SYSCALLDB
  898. popq %rdi /* Reload %rdi, adjust stack. */
  899. cfi_adjust_cfa_offset(-8)
  900. cmpq $-4095, %rax /* Check %rax for error. */
  901. diff --git a/sysdeps/unix/sysv/linux/x86_64/sigaction.c b/sysdeps/unix/sysv/linux/x86_64/sigaction.c
  902. index ab23985..38a6b69 100644
  903. --- a/sysdeps/unix/sysv/linux/x86_64/sigaction.c
  904. +++ b/sysdeps/unix/sysv/linux/x86_64/sigaction.c
  905. @@ -129,7 +129,7 @@ asm \
  906. " .type __" #name ",@function\n" \
  907. "__" #name ":\n" \
  908. " movq $" #syscall ", %rax\n" \
  909. - " syscall\n" \
  910. + SYSCALLDB_ASM \
  911. ".LEND_" #name ":\n" \
  912. ".section .eh_frame,\"a\",@progbits\n" \
  913. ".LSTARTFRAME_" #name ":\n" \
  914. diff --git a/sysdeps/unix/sysv/linux/x86_64/swapcontext.S b/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
  915. index b3854fa..6369bfe 100644
  916. --- a/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
  917. +++ b/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
  918. @@ -75,7 +75,7 @@ ENTRY(__swapcontext)
  919. movl $SIG_SETMASK, %edi
  920. movl $_NSIG8,%r10d
  921. movl $__NR_rt_sigprocmask, %eax
  922. - syscall
  923. + SYSCALLDB
  924. cmpq $-4095, %rax /* Check %rax for error. */
  925. jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
  926. diff --git a/sysdeps/unix/sysv/linux/x86_64/syscall.S b/sysdeps/unix/sysv/linux/x86_64/syscall.S
  927. index 92c2f5b..e32ebb2 100644
  928. --- a/sysdeps/unix/sysv/linux/x86_64/syscall.S
  929. +++ b/sysdeps/unix/sysv/linux/x86_64/syscall.S
  930. @@ -31,10 +31,12 @@
  931. movq %rsi, %rdi /* shift arg1 - arg5. */
  932. movq %rdx, %rsi
  933. movq %rcx, %rdx
  934. + /* DEP 8/17/17: Keep kernel calling
  935. + * convention and fix in libOS */
  936. movq %r8, %r10
  937. movq %r9, %r8
  938. movq 8(%rsp),%r9 /* arg6 is on the stack. */
  939. - syscall /* Do the system call. */
  940. + SYSCALLDB /* Do the system call. */
  941. cmpq $-4095, %rax /* Check %rax for error. */
  942. jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
  943. ret /* Return to caller. */
  944. diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  945. index 4a9a9d9..dc452ed 100644
  946. --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  947. +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  948. @@ -21,6 +21,7 @@
  949. /* There is some commonality. */
  950. #include <sysdeps/unix/x86_64/sysdep.h>
  951. #include <tls.h>
  952. +#include "syscalldb.h"
  953. #ifdef IS_IN_rtld
  954. # include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
  955. @@ -176,7 +177,7 @@
  956. # define DO_CALL(syscall_name, args) \
  957. DOARGS_##args \
  958. movl $SYS_ify (syscall_name), %eax; \
  959. - syscall;
  960. + SYSCALLDB
  961. # define DOARGS_0 /* nothing */
  962. # define DOARGS_1 /* nothing */
  963. @@ -190,9 +191,20 @@
  964. /* Define a macro which expands inline into the wrapper code for a system
  965. call. */
  966. # undef INLINE_SYSCALL
  967. -# define INLINE_SYSCALL(name, nr, args...) \
  968. +# define INLINE_SYSCALL(name, nr_args...) \
  969. ({ \
  970. - unsigned long int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
  971. + unsigned long int resultvar = INTERNAL_SYSCALL (name, , ##nr_args); \
  972. + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
  973. + { \
  974. + __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
  975. + resultvar = (unsigned long int) -1; \
  976. + } \
  977. + (long int) resultvar; })
  978. +
  979. +# undef INLINE_SYSCALL_ASM
  980. +# define INLINE_SYSCALL_ASM(name, nr_args...) \
  981. + ({ \
  982. + unsigned long int resultvar = INTERNAL_SYSCALL_ASM (name, , ##nr_args); \
  983. if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
  984. { \
  985. __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
  986. @@ -204,9 +216,9 @@
  987. into the wrapper code for a system call. It should be used when size
  988. of any argument > size of long int. */
  989. # undef INLINE_SYSCALL_TYPES
  990. -# define INLINE_SYSCALL_TYPES(name, nr, args...) \
  991. +# define INLINE_SYSCALL_TYPES(name, nr_args...) \
  992. ({ \
  993. - unsigned long int resultvar = INTERNAL_SYSCALL_TYPES (name, , nr, args); \
  994. + unsigned long int resultvar = INTERNAL_SYSCALL_TYPES (name, , ##nr_args); \
  995. if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
  996. { \
  997. __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
  998. @@ -223,13 +235,19 @@
  999. LOAD_ARGS_##nr (args) \
  1000. LOAD_REGS_##nr \
  1001. asm volatile ( \
  1002. - "syscall\n\t" \
  1003. + SYSCALLDB \
  1004. : "=a" (resultvar) \
  1005. : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx"); \
  1006. (long int) resultvar; })
  1007. +# define INTERNAL_SYSCALL_NCS_ASM INTERNAL_SYSCALL_NCS
  1008. +
  1009. # undef INTERNAL_SYSCALL
  1010. -# define INTERNAL_SYSCALL(name, err, nr, args...) \
  1011. - INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
  1012. +# define INTERNAL_SYSCALL(name, err, nr_args...) \
  1013. + INTERNAL_SYSCALL_NCS (__NR_##name, err, ##nr_args)
  1014. +
  1015. +# undef INTERNAL_SYSCALL_ASM
  1016. +# define INTERNAL_SYSCALL_ASM(name, err, nr_args...) \
  1017. + INTERNAL_SYSCALL_NCS_ASM (__NR_##name, err, ##nr_args)
  1018. # define INTERNAL_SYSCALL_NCS_TYPES(name, err, nr, args...) \
  1019. ({ \
  1020. @@ -237,7 +255,7 @@
  1021. LOAD_ARGS_TYPES_##nr (args) \
  1022. LOAD_REGS_TYPES_##nr (args) \
  1023. asm volatile ( \
  1024. - "syscall\n\t" \
  1025. + SYSCALLDB \
  1026. : "=a" (resultvar) \
  1027. : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx"); \
  1028. (long int) resultvar; })
  1029. diff --git a/sysdeps/unix/sysv/linux/x86_64/vfork.S b/sysdeps/unix/sysv/linux/x86_64/vfork.S
  1030. index d3b450a..75a63e1 100644
  1031. --- a/sysdeps/unix/sysv/linux/x86_64/vfork.S
  1032. +++ b/sysdeps/unix/sysv/linux/x86_64/vfork.S
  1033. @@ -38,7 +38,7 @@ ENTRY (__vfork)
  1034. /* Stuff the syscall number in RAX and enter into the kernel. */
  1035. movl $SYS_ify (vfork), %eax
  1036. - syscall
  1037. + SYSCALLDB
  1038. /* Push back the return PC. */
  1039. pushq %rdi
  1040. diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
  1041. index 504c95f..dcfc259 100644
  1042. --- a/sysdeps/x86_64/dl-machine.h
  1043. +++ b/sysdeps/x86_64/dl-machine.h
  1044. @@ -529,7 +529,8 @@ elf_machine_lazy_rel (struct link_map *map,
  1045. value = ((ElfW(Addr) (*) (void)) value) ();
  1046. *reloc_addr = value;
  1047. }
  1048. - else
  1049. + /* for graphene, get around R_X86_64_NONE */
  1050. + else if (__builtin_expect (r_type != R_X86_64_NONE, 1))
  1051. _dl_reloc_bad_type (map, r_type, 1);
  1052. }
  1053. diff --git a/sysdeps/x86_64/hp-timing.h b/sysdeps/x86_64/hp-timing.h
  1054. index d88206c..886c500 100644
  1055. --- a/sysdeps/x86_64/hp-timing.h
  1056. +++ b/sysdeps/x86_64/hp-timing.h
  1057. @@ -18,23 +18,6 @@
  1058. #ifndef _HP_TIMING_H
  1059. -/* We can use some of the i686 implementation without changes. */
  1060. -# include <sysdeps/i386/i686/hp-timing.h>
  1061. -
  1062. -/* The "=A" constraint used in 32-bit mode does not work in 64-bit mode. */
  1063. -# undef HP_TIMING_NOW
  1064. -# define HP_TIMING_NOW(Var) \
  1065. - ({ unsigned int _hi, _lo; \
  1066. - asm volatile ("rdtsc" : "=a" (_lo), "=d" (_hi)); \
  1067. - (Var) = ((unsigned long long int) _hi << 32) | _lo; })
  1068. -
  1069. -/* The funny business for 32-bit mode is not required here. */
  1070. -# undef HP_TIMING_ACCUM
  1071. -# define HP_TIMING_ACCUM(Sum, Diff) \
  1072. - do { \
  1073. - hp_timing_t __diff = (Diff) - GLRO(dl_hp_timing_overhead); \
  1074. - __asm__ __volatile__ ("lock; addq %1, %0" \
  1075. - : "=m" (Sum) : "r" (__diff), "m" (Sum)); \
  1076. - } while (0)
  1077. +# include <sysdeps/generic/hp-timing.h>
  1078. #endif /* hp-timing.h */