glibc-2.19.patch 42 KB

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