glibc-2.19.patch 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904
  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/configure b/configure
  77. index fc023d0..b71c1f9 100755
  78. --- a/configure
  79. +++ b/configure
  80. @@ -630,7 +630,8 @@ SED
  81. MAKEINFO
  82. MSGFMT
  83. MAKE
  84. -LD
  85. +LD_GOLD
  86. +LD_BFD
  87. AS
  88. OBJCOPY
  89. OBJDUMP
  90. @@ -4593,17 +4594,22 @@ if test $ac_verc_fail = yes; then
  91. AS=: critic_missing="$critic_missing as"
  92. fi
  93. -for ac_prog in $LD
  94. +LD_BFD=
  95. +LD_GOLD=
  96. +ld_is_gold="`$LD --version | sed -n 's/^GNU \(gold\).*$/\1/p'`"
  97. +if test -z "$ld_is_gold"; then
  98. + LD_BFD=$LD
  99. + for ac_prog in $LD_BFD
  100. do
  101. # Extract the first word of "$ac_prog", so it can be a program name with args.
  102. set dummy $ac_prog; ac_word=$2
  103. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
  104. $as_echo_n "checking for $ac_word... " >&6; }
  105. -if ${ac_cv_prog_LD+:} false; then :
  106. +if ${ac_cv_prog_LD_BFD+:} false; then :
  107. $as_echo_n "(cached) " >&6
  108. else
  109. - if test -n "$LD"; then
  110. - ac_cv_prog_LD="$LD" # Let the user override the test.
  111. + if test -n "$LD_BFD"; then
  112. + ac_cv_prog_LD_BFD="$LD_BFD" # Let the user override the test.
  113. else
  114. as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
  115. for as_dir in $PATH
  116. @@ -4612,7 +4618,7 @@ do
  117. test -z "$as_dir" && as_dir=.
  118. for ac_exec_ext in '' $ac_executable_extensions; do
  119. if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
  120. - ac_cv_prog_LD="$ac_prog"
  121. + ac_cv_prog_LD_BFD="$ac_prog"
  122. $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
  123. break 2
  124. fi
  125. @@ -4622,26 +4628,26 @@ IFS=$as_save_IFS
  126. fi
  127. fi
  128. -LD=$ac_cv_prog_LD
  129. -if test -n "$LD"; then
  130. - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
  131. -$as_echo "$LD" >&6; }
  132. +LD_BFD=$ac_cv_prog_LD_BFD
  133. +if test -n "$LD_BFD"; then
  134. + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD_BFD" >&5
  135. +$as_echo "$LD_BFD" >&6; }
  136. else
  137. { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
  138. $as_echo "no" >&6; }
  139. fi
  140. - test -n "$LD" && break
  141. + test -n "$LD_BFD" && break
  142. done
  143. -if test -z "$LD"; then
  144. +if test -z "$LD_BFD"; then
  145. ac_verc_fail=yes
  146. else
  147. # Found it, now check the version.
  148. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking version of $LD" >&5
  149. -$as_echo_n "checking version of $LD... " >&6; }
  150. - ac_prog_version=`$LD --version 2>&1 | sed -n 's/^.*GNU ld.* \([0-9][0-9]*\.[0-9.]*\).*$/\1/p'`
  151. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking version of $LD_BFD" >&5
  152. +$as_echo_n "checking version of $LD_BFD... " >&6; }
  153. + ac_prog_version=`$LD_BFD --version 2>&1 | sed -n 's/^.*GNU ld.* \([0-9][0-9]*\.[0-9.]*\).*$/\1/p'`
  154. case $ac_prog_version in
  155. '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
  156. 2.1[0-9][0-9]*|2.[2-9][0-9]*|[3-9].*|[1-9][0-9]*)
  157. @@ -4653,9 +4659,80 @@ $as_echo_n "checking version of $LD... " >&6; }
  158. $as_echo "$ac_prog_version" >&6; }
  159. fi
  160. if test $ac_verc_fail = yes; then
  161. - LD=: critic_missing="$critic_missing ld"
  162. + LD_BFD=:
  163. fi
  164. +else
  165. +# Accept gold 1.11 or higher.
  166. + LD_GOLD=$LD
  167. + for ac_prog in $LD_GOLD
  168. +do
  169. + # Extract the first word of "$ac_prog", so it can be a program name with args.
  170. +set dummy $ac_prog; ac_word=$2
  171. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
  172. +$as_echo_n "checking for $ac_word... " >&6; }
  173. +if ${ac_cv_prog_LD_GOLD+:} false; then :
  174. + $as_echo_n "(cached) " >&6
  175. +else
  176. + if test -n "$LD_GOLD"; then
  177. + ac_cv_prog_LD_GOLD="$LD_GOLD" # Let the user override the test.
  178. +else
  179. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
  180. +for as_dir in $PATH
  181. +do
  182. + IFS=$as_save_IFS
  183. + test -z "$as_dir" && as_dir=.
  184. + for ac_exec_ext in '' $ac_executable_extensions; do
  185. + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
  186. + ac_cv_prog_LD_GOLD="$ac_prog"
  187. + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
  188. + break 2
  189. + fi
  190. +done
  191. + done
  192. +IFS=$as_save_IFS
  193. +
  194. +fi
  195. +fi
  196. +LD_GOLD=$ac_cv_prog_LD_GOLD
  197. +if test -n "$LD_GOLD"; then
  198. + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD_GOLD" >&5
  199. +$as_echo "$LD_GOLD" >&6; }
  200. +else
  201. + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
  202. +$as_echo "no" >&6; }
  203. +fi
  204. +
  205. +
  206. + test -n "$LD_GOLD" && break
  207. +done
  208. +
  209. +if test -z "$LD_GOLD"; then
  210. + ac_verc_fail=yes
  211. +else
  212. + # Found it, now check the version.
  213. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking version of $LD_GOLD" >&5
  214. +$as_echo_n "checking version of $LD_GOLD... " >&6; }
  215. + ac_prog_version=`$LD_GOLD --version 2>&1 | sed -n 's/^.*GNU gold.* \([0-9][0-9]*\.[0-9.]*\).*$/\1/p'`
  216. + case $ac_prog_version in
  217. + '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
  218. + 1.1[1-9]*|1.[2-9][0-9]*|1.1[0-9][0-9]*|[2-9].*|[1-9][0-9]*)
  219. + ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
  220. + *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
  221. +
  222. + esac
  223. + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_prog_version" >&5
  224. +$as_echo "$ac_prog_version" >&6; }
  225. +fi
  226. +if test $ac_verc_fail = yes; then
  227. + LD_GOLD=:
  228. +fi
  229. +
  230. +fi
  231. +# Neither ld nor gold are new enough.
  232. +if test -z "$LD_BFD" && test -z "$LD_GOLD"; then
  233. + critic_missing="$critic_missing ld"
  234. +fi
  235. # These programs are version sensitive.
  236. @@ -6391,6 +6468,16 @@ $as_echo "$libc_cv_use_default_link" >&6; }
  237. use_default_link=$libc_cv_use_default_link
  238. fi
  239. +# The gold linker has no builtin default linker script,
  240. +# and the fallback of editing the builtin linker
  241. +# script is not available. Therefore if use_default_link
  242. +# is `no' then we can't use gold. This check is independent
  243. +# of gold's version and is used to sanity check that the
  244. +# linker continues to produce a useful shared link.
  245. +if test "$ld_is_gold" && test "$use_default_link" = "no"; then
  246. + as_fn_error $? "$LD did not generate a useful shared link. Try using GNU ld.bfd?" "$LINENO" 5
  247. +fi
  248. +
  249. { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker output format" >&5
  250. $as_echo_n "checking linker output format... " >&6; }
  251. if ${libc_cv_output_format+:} false; then :
  252. @@ -6409,6 +6496,17 @@ fi
  253. $as_echo "$libc_cv_output_format" >&6; }
  254. +# The gold linker has no builtin default linker script,
  255. +# and the fallback of parsing the builtin linker
  256. +# script to determine the target is not available.
  257. +# Therefore if libc_cv_output_format is `unknown' then
  258. +# we can't use gold. This check is independent of gold's
  259. +# version and is used to sanity check that the linker
  260. +# continues to support --print-output-format.
  261. +if test "$ld_is_gold" && test "$libc_cv_output_format" = "unknown"; then
  262. + as_fn_error $? "$LD did not support --print-output-format. Try using GNU ld.bfd?" "$LINENO" 5
  263. +fi
  264. +
  265. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -fno-toplevel-reorder -fno-section-anchors" >&5
  266. $as_echo_n "checking for -fno-toplevel-reorder -fno-section-anchors... " >&6; }
  267. if ${libc_cv_fno_toplevel_reorder+:} false; then :
  268. diff --git a/dlfcn/Versions b/dlfcn/Versions
  269. index 97902f0..c1874c1 100644
  270. --- a/dlfcn/Versions
  271. +++ b/dlfcn/Versions
  272. @@ -14,4 +14,7 @@ libdl {
  273. GLIBC_PRIVATE {
  274. _dlfcn_hook;
  275. }
  276. + SHIM {
  277. + syscalldb;
  278. + }
  279. }
  280. diff --git a/elf/Makefile b/elf/Makefile
  281. index 4c58fc9..0ae2fa8 100644
  282. --- a/elf/Makefile
  283. +++ b/elf/Makefile
  284. @@ -21,7 +21,7 @@ subdir := elf
  285. include ../Makeconfig
  286. -headers = elf.h bits/elfclass.h link.h bits/link.h
  287. +headers = elf.h bits/elfclass.h link.h bits/link.h syscalldb.h
  288. routines = $(dl-routines) dl-support dl-iteratephdr \
  289. dl-addr enbl-secure dl-profstub \
  290. dl-origin dl-libc dl-sym dl-tsd dl-sysdep
  291. @@ -31,7 +31,8 @@ routines = $(dl-routines) dl-support dl-iteratephdr \
  292. dl-routines = $(addprefix dl-,load lookup object reloc deps hwcaps \
  293. runtime error init fini debug misc \
  294. version profile conflict tls origin scope \
  295. - execstack caller open close trampoline)
  296. + execstack caller open close trampoline) \
  297. + syscalldb syscallas
  298. ifeq (yes,$(use-ldconfig))
  299. dl-routines += dl-cache
  300. endif
  301. diff --git a/elf/Versions b/elf/Versions
  302. index 2383992..1cdf63a 100644
  303. --- a/elf/Versions
  304. +++ b/elf/Versions
  305. @@ -24,14 +24,15 @@ libc {
  306. _dl_sym; _dl_vsym;
  307. __libc_dlclose; __libc_dlopen_mode; __libc_dlsym;
  308. }
  309. + SHIM {
  310. + syscalldb; glibc_option;
  311. + }
  312. }
  313. ld {
  314. GLIBC_2.0 {
  315. # Function from libc.so which must be shared with libc.
  316. __libc_memalign; calloc; free; malloc; realloc;
  317. -
  318. - _r_debug;
  319. }
  320. GLIBC_2.1 {
  321. # functions used in other libraries
  322. @@ -57,9 +58,12 @@ ld {
  323. _rtld_global; _rtld_global_ro;
  324. # Only here for gdb while a better method is developed.
  325. - _dl_debug_state;
  326. + __libc_r_debug; __libc_dl_debug_state;
  327. # Pointer protection.
  328. __pointer_chk_guard;
  329. }
  330. + SHIM {
  331. + syscalldb; glibc_vers_2_17; glibc_option; register_library;
  332. + }
  333. }
  334. diff --git a/elf/circleload1.c b/elf/circleload1.c
  335. index 990ff84..ccf92d3 100644
  336. --- a/elf/circleload1.c
  337. +++ b/elf/circleload1.c
  338. @@ -5,7 +5,7 @@
  339. #include <stdlib.h>
  340. #include <string.h>
  341. -#define MAPS ((struct link_map *) _r_debug.r_map)
  342. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  343. static int
  344. check_loaded_objects (const char **loaded)
  345. diff --git a/elf/dl-close.c b/elf/dl-close.c
  346. index 5bf1de7..a887133 100644
  347. --- a/elf/dl-close.c
  348. +++ b/elf/dl-close.c
  349. @@ -473,7 +473,7 @@ _dl_close_worker (struct link_map *map)
  350. /* Notify the debugger we are about to remove some loaded objects. */
  351. struct r_debug *r = _dl_debug_initialize (0, nsid);
  352. r->r_state = RT_DELETE;
  353. - _dl_debug_state ();
  354. + __libc_dl_debug_state ();
  355. LIBC_PROBE (unmap_start, 2, nsid, r);
  356. if (unload_global)
  357. @@ -739,7 +739,7 @@ _dl_close_worker (struct link_map *map)
  358. /* Notify the debugger those objects are finalized and gone. */
  359. r->r_state = RT_CONSISTENT;
  360. - _dl_debug_state ();
  361. + __libc_dl_debug_state ();
  362. LIBC_PROBE (unmap_complete, 2, nsid, r);
  363. /* Recheck if we need to retry, release the lock. */
  364. diff --git a/elf/dl-debug.c b/elf/dl-debug.c
  365. index 4e7c593..3e0bff4 100644
  366. --- a/elf/dl-debug.c
  367. +++ b/elf/dl-debug.c
  368. @@ -34,7 +34,7 @@ extern const int verify_link_map_members[(VERIFY_MEMBER (l_addr)
  369. normally finds it via the DT_DEBUG entry in the dynamic section, but in
  370. a statically-linked program there is no dynamic section for the debugger
  371. to examine and it looks for this particular symbol name. */
  372. -struct r_debug _r_debug;
  373. +struct r_debug __libc_r_debug __attribute__((weak));
  374. /* Initialize _r_debug if it has not already been done. The argument is
  375. @@ -48,7 +48,7 @@ _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns)
  376. struct r_debug *r;
  377. if (ns == LM_ID_BASE)
  378. - r = &_r_debug;
  379. + r = &__libc_r_debug;
  380. else
  381. r = &GL(dl_ns)[ns]._ns_debug;
  382. @@ -56,9 +56,9 @@ _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns)
  383. {
  384. /* Tell the debugger where to find the map of loaded objects. */
  385. r->r_version = 1 /* R_DEBUG_VERSION XXX */;
  386. - r->r_ldbase = ldbase ?: _r_debug.r_ldbase;
  387. + r->r_ldbase = ldbase ?: __libc_r_debug.r_ldbase;
  388. r->r_map = (void *) GL(dl_ns)[ns]._ns_loaded;
  389. - r->r_brk = (ElfW(Addr)) &_dl_debug_state;
  390. + r->r_brk = (ElfW(Addr)) &__libc_dl_debug_state;
  391. }
  392. return r;
  393. @@ -70,7 +70,7 @@ _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns)
  394. examining the r_brk member of struct r_debug, but GDB 4.15 in fact looks
  395. for this particular symbol name in the PT_INTERP file. */
  396. void
  397. -_dl_debug_state (void)
  398. +__libc_dl_debug_state (void)
  399. {
  400. }
  401. -rtld_hidden_def (_dl_debug_state)
  402. +__attribute__((weak));
  403. diff --git a/elf/dl-load.c b/elf/dl-load.c
  404. index 1be7a3c..c560ec1 100644
  405. --- a/elf/dl-load.c
  406. +++ b/elf/dl-load.c
  407. @@ -39,6 +39,8 @@
  408. #include <dl-dst.h>
  409. +#include <glibc-version.h>
  410. +
  411. /* On some systems, no flag bits are given to specify file mapping. */
  412. #ifndef MAP_FILE
  413. # define MAP_FILE 0
  414. @@ -902,7 +904,7 @@ lose (int code, int fd, const char *name, char *realname, struct link_map *l,
  415. if (r != NULL)
  416. {
  417. r->r_state = RT_CONSISTENT;
  418. - _dl_debug_state ();
  419. + __libc_dl_debug_state ();
  420. LIBC_PROBE (map_failed, 2, nsid, r);
  421. }
  422. @@ -1048,7 +1050,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
  423. call _dl_debug_initialize in a static program in case dynamic
  424. linking has not been used before. */
  425. r->r_state = RT_ADD;
  426. - _dl_debug_state ();
  427. + __libc_dl_debug_state ();
  428. LIBC_PROBE (map_start, 2, nsid, r);
  429. make_consistent = true;
  430. }
  431. @@ -1595,6 +1597,9 @@ cannot enable executable stack as shared object requires");
  432. DL_AFTER_LOAD (l);
  433. #endif
  434. + /* register the library to SHIM */
  435. + register_library(l->l_name, l->l_addr);
  436. +
  437. /* Now that the object is fully initialized add it to the object list. */
  438. _dl_add_to_namespace_list (l, nsid);
  439. diff --git a/elf/dl-open.c b/elf/dl-open.c
  440. index a9ca6b3..829d212 100644
  441. --- a/elf/dl-open.c
  442. +++ b/elf/dl-open.c
  443. @@ -290,7 +290,7 @@ dl_open_worker (void *a)
  444. /* Notify the debugger all new objects are now ready to go. */
  445. struct r_debug *r = _dl_debug_initialize (0, args->nsid);
  446. r->r_state = RT_CONSISTENT;
  447. - _dl_debug_state ();
  448. + __libc_dl_debug_state ();
  449. LIBC_PROBE (map_complete, 3, args->nsid, r, new);
  450. /* Print scope information. */
  451. diff --git a/elf/link.h b/elf/link.h
  452. index d5905d1..f4e108a 100644
  453. --- a/elf/link.h
  454. +++ b/elf/link.h
  455. @@ -64,7 +64,7 @@ struct r_debug
  456. };
  457. /* This is the instance of that structure used by the dynamic linker. */
  458. -extern struct r_debug _r_debug;
  459. +extern struct r_debug __libc_r_debug;
  460. /* This symbol refers to the "dynamic structure" in the `.dynamic' section
  461. of whatever module refers to `_DYNAMIC'. So, to find its own
  462. diff --git a/elf/loadtest.c b/elf/loadtest.c
  463. index 727469b..568ddef 100644
  464. --- a/elf/loadtest.c
  465. +++ b/elf/loadtest.c
  466. @@ -70,7 +70,7 @@ static const struct
  467. #include <include/link.h>
  468. -#define MAPS ((struct link_map *) _r_debug.r_map)
  469. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  470. #define OUT \
  471. for (map = MAPS; map != NULL; map = map->l_next) \
  472. diff --git a/elf/neededtest.c b/elf/neededtest.c
  473. index 3cea499..e098d48 100644
  474. --- a/elf/neededtest.c
  475. +++ b/elf/neededtest.c
  476. @@ -5,7 +5,7 @@
  477. #include <stdlib.h>
  478. #include <string.h>
  479. -#define MAPS ((struct link_map *) _r_debug.r_map)
  480. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  481. static int
  482. check_loaded_objects (const char **loaded)
  483. diff --git a/elf/neededtest2.c b/elf/neededtest2.c
  484. index 17c75f2..5a73a95 100644
  485. --- a/elf/neededtest2.c
  486. +++ b/elf/neededtest2.c
  487. @@ -5,7 +5,7 @@
  488. #include <stdlib.h>
  489. #include <string.h>
  490. -#define MAPS ((struct link_map *) _r_debug.r_map)
  491. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  492. static int
  493. check_loaded_objects (const char **loaded)
  494. diff --git a/elf/neededtest3.c b/elf/neededtest3.c
  495. index 41970cf..5126615 100644
  496. --- a/elf/neededtest3.c
  497. +++ b/elf/neededtest3.c
  498. @@ -5,7 +5,7 @@
  499. #include <stdlib.h>
  500. #include <string.h>
  501. -#define MAPS ((struct link_map *) _r_debug.r_map)
  502. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  503. static int
  504. check_loaded_objects (const char **loaded)
  505. diff --git a/elf/neededtest4.c b/elf/neededtest4.c
  506. index 0ae0b7f..f883910 100644
  507. --- a/elf/neededtest4.c
  508. +++ b/elf/neededtest4.c
  509. @@ -5,7 +5,7 @@
  510. #include <stdlib.h>
  511. #include <string.h>
  512. -#define MAPS ((struct link_map *) _r_debug.r_map)
  513. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  514. static int
  515. check_loaded_objects (const char **loaded)
  516. diff --git a/elf/rtld.c b/elf/rtld.c
  517. index 6dcbabc..431120a 100644
  518. --- a/elf/rtld.c
  519. +++ b/elf/rtld.c
  520. @@ -356,6 +356,23 @@ _dl_start_final (void *arg, struct dl_start_final_info *info)
  521. return start_addr;
  522. }
  523. +/* For graphene, check if glibc version match to the compatible SHIM
  524. + library. If not, tell the user to update glibc. */
  525. +#include "glibc-version.h"
  526. +
  527. +volatile const int glibc_vers_2_17 __attribute__((weak)) = GLIBC_VERSION_2_17;
  528. +
  529. +static void __attribute__((noinline,optimize("-O0")))
  530. +check_glibc_version (void)
  531. +{
  532. + if (glibc_vers_2_17 != GLIBC_VERSION_2_17)
  533. + {
  534. + _dl_fatal_printf ("Warning from Graphene: "
  535. + "Glibc version is incorrect. Please rebuild Glibc.\n");
  536. + _exit (1);
  537. + }
  538. +}
  539. +
  540. static ElfW(Addr) __attribute_used__ internal_function
  541. _dl_start (void *arg)
  542. {
  543. @@ -546,6 +563,9 @@ _dl_start (void *arg)
  544. therefore need not test whether we have to allocate the array
  545. for the relocation results (as done in dl-reloc.c). */
  546. + /* For Graphene, check if the glibc version is correct. */
  547. + check_glibc_version();
  548. +
  549. /* Now life is sane; we can call functions and access global data.
  550. Set up to use the operating system facilities, and find out from
  551. the operating system's program loader where to find the program
  552. @@ -1233,9 +1253,20 @@ of this helper program; chances are you did not intend to run this program.\n\
  553. main_map->l_map_end = allocend;
  554. if ((ph->p_flags & PF_X) && allocend > main_map->l_text_end)
  555. main_map->l_text_end = allocend;
  556. +
  557. +#if 0
  558. + ElfW(Addr) mapend = (allocend + GLRO(dl_pagesize) - 1)
  559. + & ~(GLRO(dl_pagesize) - 1);
  560. + int prot = ((ph->p_flags & PF_R) ? PROT_READ : 0)|
  561. + ((ph->p_flags & PF_W) ? PROT_WRITE : 0)|
  562. + ((ph->p_flags & PF_X) ? PROT_EXEC : 0);
  563. + __mmap ((void *) mapstart, mapend - mapstart,
  564. + prot,
  565. + MAP_ANON|MAP_PRIVATE|MAP_FIXED|0x20000000,
  566. + -1, 0);
  567. +#endif
  568. }
  569. break;
  570. -
  571. case PT_TLS:
  572. if (ph->p_memsz > 0)
  573. {
  574. @@ -1381,13 +1412,31 @@ of this helper program; chances are you did not intend to run this program.\n\
  575. /* PT_GNU_RELRO is usually the last phdr. */
  576. size_t cnt = rtld_ehdr->e_phnum;
  577. while (cnt-- > 0)
  578. + {
  579. if (rtld_phdr[cnt].p_type == PT_GNU_RELRO)
  580. {
  581. GL(dl_rtld_map).l_relro_addr = rtld_phdr[cnt].p_vaddr;
  582. GL(dl_rtld_map).l_relro_size = rtld_phdr[cnt].p_memsz;
  583. - break;
  584. }
  585. +#if 0
  586. + if (rtld_phdr[cnt].p_type == PT_LOAD)
  587. + {
  588. + ElfW(Addr) mapstart = rtld_phdr[cnt].p_vaddr & ~(GLRO(dl_pagesize) - 1);
  589. + ElfW(Addr) mapend = (rtld_phdr[cnt].p_vaddr + rtld_phdr[cnt].p_memsz
  590. + + GLRO(dl_pagesize) - 1)
  591. + & ~(GLRO(dl_pagesize) - 1);
  592. + int prot = ((rtld_phdr[cnt].p_flags & PF_R) ? PROT_READ : 0)|
  593. + ((rtld_phdr[cnt].p_flags & PF_W) ? PROT_WRITE : 0)|
  594. + ((rtld_phdr[cnt].p_flags & PF_X) ? PROT_EXEC : 0);
  595. + __mmap ((void *) mapstart, mapend - mapstart,
  596. + prot,
  597. + MAP_ANON|MAP_PRIVATE|MAP_FIXED|0x20000000,
  598. + -1, 0);
  599. + }
  600. +#endif
  601. + }
  602. +
  603. /* Add the dynamic linker to the TLS list if it also uses TLS. */
  604. if (GL(dl_rtld_map).l_tls_blocksize != 0)
  605. /* Assign a module ID. Do this before loading any audit modules. */
  606. @@ -1588,7 +1637,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
  607. /* We start adding objects. */
  608. r->r_state = RT_ADD;
  609. - _dl_debug_state ();
  610. + __libc_dl_debug_state ();
  611. LIBC_PROBE (init_start, 2, LM_ID_BASE, r);
  612. /* Auditing checkpoint: we are ready to signal that the initial map
  613. @@ -2301,7 +2350,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
  614. the address since by now the variable might be in another object. */
  615. r = _dl_debug_initialize (0, LM_ID_BASE);
  616. r->r_state = RT_CONSISTENT;
  617. - _dl_debug_state ();
  618. + __libc_dl_debug_state ();
  619. LIBC_PROBE (init_complete, 2, LM_ID_BASE, r);
  620. #if defined USE_LDCONFIG && !defined MAP_COPY
  621. diff --git a/elf/unload.c b/elf/unload.c
  622. index 4566f22..73046de 100644
  623. --- a/elf/unload.c
  624. +++ b/elf/unload.c
  625. @@ -9,7 +9,7 @@
  626. #include <stdio.h>
  627. #include <stdlib.h>
  628. -#define MAPS ((struct link_map *) _r_debug.r_map)
  629. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  630. #define OUT \
  631. for (map = MAPS; map != NULL; map = map->l_next) \
  632. diff --git a/elf/unload2.c b/elf/unload2.c
  633. index eef2bfd..a21d2ac 100644
  634. --- a/elf/unload2.c
  635. +++ b/elf/unload2.c
  636. @@ -6,7 +6,7 @@
  637. #include <stdio.h>
  638. #include <stdlib.h>
  639. -#define MAPS ((struct link_map *) _r_debug.r_map)
  640. +#define MAPS ((struct link_map *) __libc_r_debug.r_map)
  641. #define OUT \
  642. for (map = MAPS; map != NULL; map = map->l_next) \
  643. diff --git a/malloc/arena.c b/malloc/arena.c
  644. index 5088a25..33a3879 100644
  645. --- a/malloc/arena.c
  646. +++ b/malloc/arena.c
  647. @@ -21,6 +21,27 @@
  648. /* Compile-time constants. */
  649. +#ifndef HEAP_MAX_SIZE
  650. +# ifdef DEFAULT_MMAP_THRESHOLD_MAX
  651. +# define DEFAULT_HEAP_MAX_SIZE (2 * DEFAULT_MMAP_THRESHOLD_MAX)
  652. +# else
  653. +# define DEFAULT_HEAP_MAX_SIZE (1024 * 1024) /* must be a power of two */
  654. +# endif
  655. +# include <sysdep.h>
  656. +static long int heap_max_size = 0;
  657. +# define HEAP_MAX_SIZE \
  658. + ({ \
  659. + if (!heap_max_size) { \
  660. + long int size = glibc_option("heap_size"); \
  661. + if (size > 0) \
  662. + heap_max_size = size; \
  663. + else \
  664. + heap_max_size = DEFAULT_HEAP_MAX_SIZE; \
  665. + } \
  666. + heap_max_size; \
  667. + })
  668. +#endif
  669. +
  670. #define HEAP_MIN_SIZE (32 * 1024)
  671. #ifndef HEAP_MAX_SIZE
  672. # ifdef DEFAULT_MMAP_THRESHOLD_MAX
  673. @@ -545,17 +566,6 @@ new_heap (size_t size, size_t top_pad)
  674. mapping (on Linux, this is the case for all non-writable mappings
  675. anyway). */
  676. p2 = MAP_FAILED;
  677. - if (aligned_heap_area)
  678. - {
  679. - p2 = (char *) MMAP (aligned_heap_area, HEAP_MAX_SIZE, PROT_NONE,
  680. - MAP_NORESERVE);
  681. - aligned_heap_area = NULL;
  682. - if (p2 != MAP_FAILED && ((unsigned long) p2 & (HEAP_MAX_SIZE - 1)))
  683. - {
  684. - __munmap (p2, HEAP_MAX_SIZE);
  685. - p2 = MAP_FAILED;
  686. - }
  687. - }
  688. if (p2 == MAP_FAILED)
  689. {
  690. p1 = (char *) MMAP (0, HEAP_MAX_SIZE << 1, PROT_NONE, MAP_NORESERVE);
  691. @@ -566,8 +576,6 @@ new_heap (size_t size, size_t top_pad)
  692. ul = p2 - p1;
  693. if (ul)
  694. __munmap (p1, ul);
  695. - else
  696. - aligned_heap_area = p2 + HEAP_MAX_SIZE;
  697. __munmap (p2 + HEAP_MAX_SIZE, HEAP_MAX_SIZE - ul);
  698. }
  699. else
  700. diff --git a/nptl/Makefile b/nptl/Makefile
  701. index 57cc8c6..81f1bf4 100644
  702. --- a/nptl/Makefile
  703. +++ b/nptl/Makefile
  704. @@ -20,7 +20,7 @@
  705. #
  706. subdir := nptl
  707. -headers := pthread.h semaphore.h bits/semaphore.h
  708. +headers := pthread.h semaphore.h bits/semaphore.h syscalldb.h
  709. extra-libs := libpthread
  710. extra-libs-others := $(extra-libs)
  711. diff --git a/nptl/Versions b/nptl/Versions
  712. index bb11277..354149a 100644
  713. --- a/nptl/Versions
  714. +++ b/nptl/Versions
  715. @@ -31,6 +31,9 @@ libc {
  716. # Internal libc interface to libpthread
  717. __libc_dl_error_tsd;
  718. }
  719. + SHIM {
  720. + syscalldb; glibc_option;
  721. + }
  722. }
  723. libpthread {
  724. @@ -262,4 +265,8 @@ libpthread {
  725. __pthread_clock_gettime; __pthread_clock_settime;
  726. __pthread_unwind; __pthread_get_minstack;
  727. }
  728. +
  729. + SHIM {
  730. + syscalldb; glibc_option;
  731. + }
  732. }
  733. diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
  734. index 9d7f52f..72d50ae 100644
  735. --- a/nptl/pthread_create.c
  736. +++ b/nptl/pthread_create.c
  737. @@ -405,8 +405,11 @@ start_thread (void *arg)
  738. # error "to do"
  739. #endif
  740. assert (freesize < pd->stackblock_size);
  741. + /* XXX: may not be necessary */
  742. +#if 0
  743. if (freesize > PTHREAD_STACK_MIN)
  744. __madvise (pd->stackblock, freesize - PTHREAD_STACK_MIN, MADV_DONTNEED);
  745. +#endif
  746. /* If the thread is detached free the TCB. */
  747. if (IS_DETACHED (pd))
  748. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S b/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S
  749. index 89fda5e..594dd72 100644
  750. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S
  751. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S
  752. @@ -111,7 +111,8 @@ ENTRY(__pthread_disable_asynccancel)
  753. xorq %r10, %r10
  754. addq $CANCELHANDLING, %rdi
  755. LOAD_PRIVATE_FUTEX_WAIT (%esi)
  756. - syscall
  757. + SYSCALL
  758. +
  759. movl %fs:CANCELHANDLING, %eax
  760. jmp 3b
  761. END(__pthread_disable_asynccancel)
  762. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/fork.c b/nptl/sysdeps/unix/sysv/linux/x86_64/fork.c
  763. index a036b92..40a1eaf 100644
  764. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/fork.c
  765. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/fork.c
  766. @@ -21,10 +21,20 @@
  767. #include <sysdep.h>
  768. #include <tls.h>
  769. -
  770. -#define ARCH_FORK() \
  771. +/* In Graphene, we prefer to call fork system call directly than clone */
  772. +#if USE_clone_FOR_fork
  773. +# define ARCH_FORK() \
  774. INLINE_SYSCALL (clone, 4, \
  775. CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD, 0, \
  776. NULL, &THREAD_SELF->tid)
  777. +#else
  778. +# define ARCH_FORK() \
  779. + ({ unsigned long ret = INLINE_SYSCALL (fork, 0); \
  780. + if (!ret) { \
  781. + pid_t pid = INLINE_SYSCALL (getpid, 0); \
  782. + THREAD_SETMEM (THREAD_SELF, pid, pid); \
  783. + THREAD_SETMEM (THREAD_SELF, tid, pid); \
  784. + } ret; })
  785. +#endif
  786. #include "../fork.c"
  787. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
  788. index f2dca07..e5b3f2f 100644
  789. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
  790. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
  791. @@ -90,7 +90,7 @@ __lll_lock_wait_private:
  792. 1: LIBC_PROBE (lll_lock_wait_private, 1, %rdi)
  793. movl $SYS_futex, %eax
  794. - syscall
  795. + SYSCALL
  796. 2: movl %edx, %eax
  797. xchgl %eax, (%rdi) /* NB: lock is implied */
  798. @@ -130,7 +130,7 @@ __lll_lock_wait:
  799. 1: LIBC_PROBE (lll_lock_wait, 2, %rdi, %rsi)
  800. movl $SYS_futex, %eax
  801. - syscall
  802. + SYSCALL
  803. 2: movl %edx, %eax
  804. xchgl %eax, (%rdi) /* NB: lock is implied */
  805. @@ -185,7 +185,7 @@ __lll_timedlock_wait:
  806. 1: movl $SYS_futex, %eax
  807. movl $2, %edx
  808. - syscall
  809. + SYSCALL
  810. 2: xchgl %edx, (%rdi) /* NB: lock is implied */
  811. @@ -279,7 +279,7 @@ __lll_timedlock_wait:
  812. LOAD_FUTEX_WAIT (%esi)
  813. movq %r12, %rdi
  814. movl $SYS_futex, %eax
  815. - syscall
  816. + SYSCALL
  817. /* NB: %edx == 2 */
  818. xchgl %edx, (%r12)
  819. @@ -336,7 +336,7 @@ __lll_unlock_wake_private:
  820. LOAD_PRIVATE_FUTEX_WAKE (%esi)
  821. movl $1, %edx /* Wake one thread. */
  822. movl $SYS_futex, %eax
  823. - syscall
  824. + SYSCALL
  825. popq %rdx
  826. cfi_adjust_cfa_offset(-8)
  827. @@ -366,7 +366,7 @@ __lll_unlock_wake:
  828. LOAD_FUTEX_WAKE (%esi)
  829. movl $1, %edx /* Wake one thread. */
  830. movl $SYS_futex, %eax
  831. - syscall
  832. + SYSCALL
  833. popq %rdx
  834. cfi_adjust_cfa_offset(-8)
  835. @@ -435,7 +435,7 @@ __lll_timedwait_tid:
  836. #endif
  837. movq %r12, %rdi
  838. movl $SYS_futex, %eax
  839. - syscall
  840. + SYSCALL
  841. cmpl $0, (%rdi)
  842. jne 1f
  843. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
  844. index 0a26739..8aae14a 100644
  845. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
  846. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
  847. @@ -214,7 +214,7 @@ LLL_STUB_UNWIND_INFO_END
  848. register const struct timespec *__to __asm ("r10") = timeout; \
  849. int __status; \
  850. register __typeof (val) _val __asm ("edx") = (val); \
  851. - __asm __volatile ("syscall" \
  852. + __asm __volatile (SYSCALLDB \
  853. : "=a" (__status) \
  854. : "0" (SYS_futex), "D" (futex), \
  855. "S" (__lll_private_flag (FUTEX_WAIT, private)), \
  856. @@ -229,7 +229,7 @@ LLL_STUB_UNWIND_INFO_END
  857. int __status; \
  858. register __typeof (nr) _nr __asm ("edx") = (nr); \
  859. LIBC_PROBE (lll_futex_wake, 3, futex, nr, private); \
  860. - __asm __volatile ("syscall" \
  861. + __asm __volatile (SYSCALLDB \
  862. : "=a" (__status) \
  863. : "0" (SYS_futex), "D" (futex), \
  864. "S" (__lll_private_flag (FUTEX_WAKE, private)), \
  865. @@ -540,7 +540,7 @@ extern int __lll_timedlock_elision (int *futex, short *adapt_count,
  866. { \
  867. int ignore; \
  868. __asm __volatile (LOCK_INSTR "orl %3, (%2)\n\t" \
  869. - "syscall" \
  870. + SYSCALLDB \
  871. : "=m" (futex), "=a" (ignore) \
  872. : "D" (&(futex)), "i" (FUTEX_OWNER_DIED), \
  873. "S" (__lll_private_flag (FUTEX_WAKE, private)), \
  874. @@ -555,7 +555,7 @@ extern int __lll_timedlock_elision (int *futex, short *adapt_count,
  875. register int __nr_move __asm ("r10") = nr_move; \
  876. register void *__mutex __asm ("r8") = mutex; \
  877. register int __val __asm ("r9") = val; \
  878. - __asm __volatile ("syscall" \
  879. + __asm __volatile (SYSCALLDB \
  880. : "=a" (__res) \
  881. : "0" (__NR_futex), "D" ((void *) ftx), \
  882. "S" (__lll_private_flag (FUTEX_CMP_REQUEUE, \
  883. @@ -581,7 +581,7 @@ extern int __lll_timedlock_elision (int *futex, short *adapt_count,
  884. if (_tid != 0) \
  885. __asm __volatile ("xorq %%r10, %%r10\n\t" \
  886. "1:\tmovq %2, %%rax\n\t" \
  887. - "syscall\n\t" \
  888. + SYSCALLDB \
  889. "cmpl $0, (%%rdi)\n\t" \
  890. "jne 1b" \
  891. : "=&a" (__ignore) \
  892. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
  893. index 990b6f9..89dbe32 100644
  894. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
  895. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
  896. @@ -80,7 +80,7 @@ __lll_robust_lock_wait:
  897. jnz 2f
  898. 1: movl $SYS_futex, %eax
  899. - syscall
  900. + SYSCALL
  901. movl (%rdi), %eax
  902. @@ -145,7 +145,7 @@ __lll_robust_timedlock_wait:
  903. jnz 6f
  904. 5: movl $SYS_futex, %eax
  905. - syscall
  906. + SYSCALL
  907. movl %eax, %ecx
  908. movl (%rdi), %eax
  909. @@ -257,7 +257,7 @@ __lll_robust_timedlock_wait:
  910. LOAD_FUTEX_WAIT (%esi)
  911. movq %r12, %rdi
  912. movl $SYS_futex, %eax
  913. - syscall
  914. + SYSCALL
  915. movq %rax, %rcx
  916. movl (%r12), %eax
  917. 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
  918. index eec17f2..4472960 100644
  919. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S
  920. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_barrier_wait.S
  921. @@ -62,7 +62,7 @@ pthread_barrier_wait:
  922. #endif
  923. xorq %r10, %r10
  924. 8: movl $SYS_futex, %eax
  925. - syscall
  926. + SYSCALL
  927. /* Don't return on spurious wakeups. The syscall does not change
  928. any register except %eax so there is no need to reload any of
  929. @@ -109,7 +109,7 @@ pthread_barrier_wait:
  930. movl $FUTEX_WAKE, %esi
  931. orl PRIVATE(%rdi), %esi
  932. movl $SYS_futex, %eax
  933. - syscall
  934. + SYSCALL
  935. /* Increment LEFT. If this brings the count back to the
  936. initial count unlock the object. */
  937. 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
  938. index 985e0f1..f180ab1 100644
  939. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
  940. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S
  941. @@ -90,7 +90,7 @@ __pthread_cond_broadcast:
  942. movl $SYS_futex, %eax
  943. movl $1, %edx
  944. movl $0x7fffffff, %r10d
  945. - syscall
  946. + SYSCALL
  947. /* For any kind of error, which mainly is EAGAIN, we try again
  948. with WAKE. The general test also covers running on old
  949. @@ -106,7 +106,7 @@ __pthread_cond_broadcast:
  950. movl $SYS_futex, %eax
  951. movl $1, %edx
  952. movl $0x7fffffff, %r10d
  953. - syscall
  954. + SYSCALL
  955. /* For any kind of error, which mainly is EAGAIN, we try again
  956. with WAKE. The general test also covers running on old
  957. @@ -172,7 +172,7 @@ __pthread_cond_broadcast:
  958. orl $FUTEX_WAKE, %esi
  959. #endif
  960. movl $SYS_futex, %eax
  961. - syscall
  962. + SYSCALL
  963. jmp 10b
  964. .size __pthread_cond_broadcast, .-__pthread_cond_broadcast
  965. versioned_symbol (libpthread, __pthread_cond_broadcast, pthread_cond_broadcast,
  966. 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
  967. index 53d65b6..8724325 100644
  968. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
  969. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S
  970. @@ -82,7 +82,7 @@ __pthread_cond_signal:
  971. addq $cond_lock, %r8
  972. #endif
  973. movl $FUTEX_OP_CLEAR_WAKE_IF_GT_ONE, %r9d
  974. - syscall
  975. + SYSCALL
  976. #if cond_lock != 0
  977. subq $cond_lock, %r8
  978. #endif
  979. @@ -99,7 +99,7 @@ __pthread_cond_signal:
  980. movq %rcx, %r8
  981. xorq %r10, %r10
  982. movl (%rdi), %r9d // XXX Can this be right?
  983. - syscall
  984. + SYSCALL
  985. leaq -cond_futex(%rdi), %r8
  986. @@ -118,7 +118,7 @@ __pthread_cond_signal:
  987. movl $SYS_futex, %eax
  988. /* %rdx should be 1 already from $FUTEX_WAKE_OP syscall.
  989. movl $1, %edx */
  990. - syscall
  991. + SYSCALL
  992. /* Unlock. */
  993. 4: LOCK
  994. 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
  995. index 0dc2340..cac13bf 100644
  996. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
  997. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
  998. @@ -188,7 +188,7 @@ __pthread_cond_timedwait:
  999. movq %r12, %rdx
  1000. addq $cond_futex, %rdi
  1001. movl $SYS_futex, %eax
  1002. - syscall
  1003. + SYSCALL
  1004. cmpl $0, %eax
  1005. sete %r15b
  1006. @@ -234,7 +234,7 @@ __pthread_cond_timedwait:
  1007. movq %r12, %rdx
  1008. addq $cond_futex, %rdi
  1009. movl $SYS_futex, %eax
  1010. - syscall
  1011. + SYSCALL
  1012. 62: movq %rax, %r14
  1013. movl (%rsp), %edi
  1014. @@ -321,7 +321,7 @@ __pthread_cond_timedwait:
  1015. orl $FUTEX_WAKE, %esi
  1016. #endif
  1017. movl $SYS_futex, %eax
  1018. - syscall
  1019. + SYSCALL
  1020. subq $cond_nwaiters, %rdi
  1021. 55: LOCK
  1022. @@ -485,15 +485,8 @@ __pthread_cond_timedwait:
  1023. /* Only clocks 0 and 1 are allowed so far. Both are handled in the
  1024. kernel. */
  1025. leaq 32(%rsp), %rsi
  1026. -# ifdef SHARED
  1027. - mov __vdso_clock_gettime@GOTPCREL(%rip), %RAX_LP
  1028. - mov (%rax), %RAX_LP
  1029. - PTR_DEMANGLE (%RAX_LP)
  1030. - call *%rax
  1031. -# else
  1032. movl $__NR_clock_gettime, %eax
  1033. - syscall
  1034. -# endif
  1035. + SYSCALL
  1036. /* Compute relative timeout. */
  1037. movq (%r13), %rcx
  1038. @@ -560,7 +553,7 @@ __pthread_cond_timedwait:
  1039. # endif
  1040. addq $cond_futex, %rdi
  1041. movl $SYS_futex, %eax
  1042. - syscall
  1043. + SYSCALL
  1044. movq %rax, %r14
  1045. movl (%rsp), %edi
  1046. @@ -732,7 +725,7 @@ __condvar_cleanup2:
  1047. orl $FUTEX_WAKE, %esi
  1048. #endif
  1049. movl $SYS_futex, %eax
  1050. - syscall
  1051. + SYSCALL
  1052. subq $cond_nwaiters, %rdi
  1053. movl $1, %r12d
  1054. @@ -769,7 +762,7 @@ __condvar_cleanup2:
  1055. orl $FUTEX_WAKE, %esi
  1056. #endif
  1057. movl $SYS_futex, %eax
  1058. - syscall
  1059. + SYSCALL
  1060. /* Lock the mutex only if we don't own it already. This only happens
  1061. in case of PI mutexes, if we got cancelled after a successful
  1062. 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
  1063. index 0e61d0a..60e104b 100644
  1064. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
  1065. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S
  1066. @@ -138,7 +138,7 @@ __pthread_cond_wait:
  1067. movl $(FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %esi
  1068. movl $SYS_futex, %eax
  1069. - syscall
  1070. + SYSCALL
  1071. cmpl $0, %eax
  1072. sete %r8b
  1073. @@ -180,7 +180,7 @@ __pthread_cond_wait:
  1074. #endif
  1075. 60: xorb %r8b, %r8b
  1076. movl $SYS_futex, %eax
  1077. - syscall
  1078. + SYSCALL
  1079. 62: movl (%rsp), %edi
  1080. callq __pthread_disable_asynccancel
  1081. @@ -239,7 +239,7 @@ __pthread_cond_wait:
  1082. orl $FUTEX_WAKE, %esi
  1083. #endif
  1084. movl $SYS_futex, %eax
  1085. - syscall
  1086. + SYSCALL
  1087. subq $cond_nwaiters, %rdi
  1088. 17: LOCK
  1089. @@ -455,7 +455,7 @@ __condvar_cleanup1:
  1090. orl $FUTEX_WAKE, %esi
  1091. #endif
  1092. movl $SYS_futex, %eax
  1093. - syscall
  1094. + SYSCALL
  1095. subq $cond_nwaiters, %rdi
  1096. movl $1, %ecx
  1097. @@ -493,7 +493,7 @@ __condvar_cleanup1:
  1098. orl $FUTEX_WAKE, %esi
  1099. #endif
  1100. movl $SYS_futex, %eax
  1101. - syscall
  1102. + SYSCALL
  1103. /* Lock the mutex only if we don't own it already. This only happens
  1104. in case of PI mutexes, if we got cancelled after a successful
  1105. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
  1106. index 2cbe2fa..d4e229a 100644
  1107. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
  1108. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
  1109. @@ -90,7 +90,7 @@ __pthread_once:
  1110. # endif
  1111. #endif
  1112. movl $SYS_futex, %eax
  1113. - syscall
  1114. + SYSCALL
  1115. jmp 6b
  1116. /* Preserve the pointer to the control variable. */
  1117. @@ -123,7 +123,7 @@ __pthread_once:
  1118. orl %fs:PRIVATE_FUTEX, %esi
  1119. #endif
  1120. movl $SYS_futex, %eax
  1121. - syscall
  1122. + SYSCALL
  1123. 4: addq $8, %rsp
  1124. cfi_adjust_cfa_offset(-8)
  1125. @@ -152,7 +152,7 @@ clear_once_control:
  1126. orl %fs:PRIVATE_FUTEX, %esi
  1127. #endif
  1128. movl $SYS_futex, %eax
  1129. - syscall
  1130. + SYSCALL
  1131. movq %r8, %rdi
  1132. .LcallUR:
  1133. 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
  1134. index 3bbb4c7..8ebf317 100644
  1135. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
  1136. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
  1137. @@ -82,7 +82,7 @@ __pthread_rwlock_rdlock:
  1138. #endif
  1139. addq $READERS_WAKEUP, %rdi
  1140. movl $SYS_futex, %eax
  1141. - syscall
  1142. + SYSCALL
  1143. subq $READERS_WAKEUP, %rdi
  1144. 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
  1145. index 40bcc04..d6c9c82 100644
  1146. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
  1147. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
  1148. @@ -109,7 +109,7 @@ pthread_rwlock_timedrdlock:
  1149. #endif
  1150. 21: leaq READERS_WAKEUP(%r12), %rdi
  1151. movl $SYS_futex, %eax
  1152. - syscall
  1153. + SYSCALL
  1154. movq %rax, %rdx
  1155. #ifndef __ASSUME_FUTEX_CLOCK_REALTIME
  1156. 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
  1157. index f57ef52..78a2655 100644
  1158. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
  1159. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
  1160. @@ -106,7 +106,7 @@ pthread_rwlock_timedwrlock:
  1161. #endif
  1162. 21: leaq WRITERS_WAKEUP(%r12), %rdi
  1163. movl $SYS_futex, %eax
  1164. - syscall
  1165. + SYSCALL
  1166. movq %rax, %rdx
  1167. #ifndef __ASSUME_FUTEX_CLOCK_REALTIME
  1168. 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
  1169. index d779f7b..4dec0c0 100644
  1170. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
  1171. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S
  1172. @@ -79,7 +79,7 @@ __pthread_rwlock_unlock:
  1173. #endif
  1174. movl $SYS_futex, %eax
  1175. movq %r10, %rdi
  1176. - syscall
  1177. + SYSCALL
  1178. xorl %eax, %eax
  1179. retq
  1180. 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
  1181. index e444def..ba31821 100644
  1182. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
  1183. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_wrlock.S
  1184. @@ -80,7 +80,7 @@ __pthread_rwlock_wrlock:
  1185. #endif
  1186. addq $WRITERS_WAKEUP, %rdi
  1187. movl $SYS_futex, %eax
  1188. - syscall
  1189. + SYSCALL
  1190. subq $WRITERS_WAKEUP, %rdi
  1191. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
  1192. index 1c11600..d276efa 100644
  1193. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
  1194. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_post.S
  1195. @@ -52,7 +52,7 @@ sem_post:
  1196. movl $FUTEX_WAKE, %esi
  1197. orl PRIVATE(%rdi), %esi
  1198. movl $1, %edx
  1199. - syscall
  1200. + SYSCALL
  1201. testq %rax, %rax
  1202. js 1f
  1203. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
  1204. index 880610e..06fd57c 100644
  1205. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
  1206. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
  1207. @@ -97,7 +97,7 @@ sem_timedwait:
  1208. orl PRIVATE(%rdi), %esi
  1209. movl $SYS_futex, %eax
  1210. xorl %edx, %edx
  1211. - syscall
  1212. + SYSCALL
  1213. movq %rax, %r9
  1214. #if VALUE != 0
  1215. leaq -VALUE(%rdi), %rdi
  1216. @@ -233,7 +233,7 @@ sem_timedwait:
  1217. # endif
  1218. movl $SYS_futex, %eax
  1219. xorl %edx, %edx
  1220. - syscall
  1221. + SYSCALL
  1222. movq %rax, %r14
  1223. movl 16(%rsp), %edi
  1224. diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
  1225. index 8f4d068..d9b49e4 100644
  1226. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
  1227. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S
  1228. @@ -81,7 +81,7 @@ sem_wait:
  1229. orl PRIVATE(%rdi), %esi
  1230. #endif
  1231. xorl %edx, %edx
  1232. - syscall
  1233. + SYSCALL
  1234. movq %rax, %rcx
  1235. xchgq %r8, %rdi
  1236. diff --git a/nptl/sysdeps/x86_64/pthreaddef.h b/nptl/sysdeps/x86_64/pthreaddef.h
  1237. index 18a15a1..ac3d6d3 100644
  1238. --- a/nptl/sysdeps/x86_64/pthreaddef.h
  1239. +++ b/nptl/sysdeps/x86_64/pthreaddef.h
  1240. @@ -48,4 +48,5 @@
  1241. /* While there is no such syscall. */
  1242. #define __exit_thread_inline(val) \
  1243. - asm volatile ("syscall" :: "a" (__NR_exit), "D" (val))
  1244. + asm volatile ("pushq %%rbx\n\tmovq syscalldb@GOTPCREL(%%rip), %%rbx\n\t" \
  1245. + "call %%rbx\n\t" :: "a" (__NR_exit), "D" (val) : "bx" )
  1246. diff --git a/nptl/sysdeps/x86_64/tls.h b/nptl/sysdeps/x86_64/tls.h
  1247. index cbb5e9e..19b18ef 100644
  1248. --- a/nptl/sysdeps/x86_64/tls.h
  1249. +++ b/nptl/sysdeps/x86_64/tls.h
  1250. @@ -28,6 +28,7 @@
  1251. # include <sysdep.h>
  1252. # include <libc-internal.h>
  1253. # include <kernel-features.h>
  1254. +# include <shim_tls.h>
  1255. /* Replacement type for __m128 since this file is included by ld.so,
  1256. which is compiled with -mno-sse. It must not change the alignment
  1257. @@ -67,6 +68,10 @@ typedef struct
  1258. # else
  1259. int __glibc_reserved1;
  1260. # endif
  1261. +
  1262. + shim_tcb_t shim_tcb; /* For graphene, we allocate a shim_tcb
  1263. + in the real tcb. */
  1264. +
  1265. int rtld_must_xmm_save;
  1266. /* Reservation of some values for the TM ABI. */
  1267. void *__private_tm[4];
  1268. @@ -137,6 +142,12 @@ typedef struct
  1269. # define GET_DTV(descr) \
  1270. (((tcbhead_t *) (descr))->dtv)
  1271. +/* For Graphene */
  1272. +#define SYSCALLDB \
  1273. + "pushq %%rbx\n\t" \
  1274. + "movq syscalldb@GOTPCREL(%%rip), %%rbx\n\t" \
  1275. + "callq *%%rbx\n\t" \
  1276. + "popq %%rbx\n\t"
  1277. /* Code to initially initialize the thread pointer. This might need
  1278. special attention since 'errno' is not yet available and if the
  1279. @@ -154,7 +165,7 @@ typedef struct
  1280. _head->self = _thrdescr; \
  1281. \
  1282. /* It is a simple syscall to set the %fs value for the thread. */ \
  1283. - asm volatile ("syscall" \
  1284. + asm volatile (SYSCALLDB \
  1285. : "=a" (_result) \
  1286. : "0" ((unsigned long int) __NR_arch_prctl), \
  1287. "D" ((unsigned long int) ARCH_SET_FS), \
  1288. diff --git a/scripts/mkinstalldirs b/scripts/mkinstalldirs
  1289. index 55d537f..57bf12b 100755
  1290. --- a/scripts/mkinstalldirs
  1291. +++ b/scripts/mkinstalldirs
  1292. @@ -126,9 +126,9 @@ do
  1293. esac
  1294. if test ! -d "$pathcomp"; then
  1295. - echo "mkdir $pathcomp"
  1296. + echo "mkdir -p $pathcomp"
  1297. - mkdir "$pathcomp" || lasterr=$?
  1298. + mkdir -p "$pathcomp" || lasterr=$?
  1299. if test ! -d "$pathcomp"; then
  1300. errstatus=$lasterr
  1301. diff --git a/shlib-versions b/shlib-versions
  1302. index 78b0ad7..5c3dcf2 100644
  1303. --- a/shlib-versions
  1304. +++ b/shlib-versions
  1305. @@ -108,3 +108,5 @@ sparc64.*-.*-.* libBrokenLocale=1 GLIBC_2.2
  1306. # This defines the libgcc soname version this glibc is to load for
  1307. # asynchronous cancellation to work correctly.
  1308. .*-.*-.* libgcc_s=1
  1309. +
  1310. +.*-.*-.* liblibos=1
  1311. diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
  1312. index ffeb093..7a9fbcb 100644
  1313. --- a/sysdeps/generic/ldsodefs.h
  1314. +++ b/sysdeps/generic/ldsodefs.h
  1315. @@ -881,8 +881,7 @@ extern void _dl_sort_fini (struct link_map **maps, size_t nmaps, char *used,
  1316. any shared object mappings. The `r_state' member of `struct r_debug'
  1317. says what change is taking place. This function's address is
  1318. the value of the `r_brk' member. */
  1319. -extern void _dl_debug_state (void);
  1320. -rtld_hidden_proto (_dl_debug_state)
  1321. +extern void __libc_dl_debug_state (void) __attribute__((weak));
  1322. /* Initialize `struct r_debug' if it has not already been done. The
  1323. argument is the run-time load address of the dynamic linker, to be put
  1324. diff --git a/sysdeps/unix/sysv/linux/_exit.c b/sysdeps/unix/sysv/linux/_exit.c
  1325. index 2468228..a9f1cd6 100644
  1326. --- a/sysdeps/unix/sysv/linux/_exit.c
  1327. +++ b/sysdeps/unix/sysv/linux/_exit.c
  1328. @@ -29,9 +29,9 @@ _exit (status)
  1329. while (1)
  1330. {
  1331. #ifdef __NR_exit_group
  1332. - INLINE_SYSCALL (exit_group, 1, status);
  1333. + INLINE_SYSCALL_ASM (exit_group, 1, status);
  1334. #endif
  1335. - INLINE_SYSCALL (exit, 1, status);
  1336. + INLINE_SYSCALL_ASM (exit, 1, status);
  1337. #ifdef ABORT_INSTRUCTION
  1338. ABORT_INSTRUCTION;
  1339. diff --git a/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S b/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
  1340. index 49f0384..ee59c00 100644
  1341. --- a/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
  1342. +++ b/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
  1343. @@ -84,7 +84,8 @@ ENTRY(____longjmp_chk)
  1344. xorl %edi, %edi
  1345. lea -sizeSS(%rsp), %RSI_LP
  1346. movl $__NR_sigaltstack, %eax
  1347. - syscall
  1348. + SYSCALL
  1349. +
  1350. /* Without working sigaltstack we cannot perform the test. */
  1351. testl %eax, %eax
  1352. jne .Lok2
  1353. diff --git a/sysdeps/unix/sysv/linux/x86_64/clock_gettime.c b/sysdeps/unix/sysv/linux/x86_64/clock_gettime.c
  1354. index f712110..f6bad14 100644
  1355. --- a/sysdeps/unix/sysv/linux/x86_64/clock_gettime.c
  1356. +++ b/sysdeps/unix/sysv/linux/x86_64/clock_gettime.c
  1357. @@ -1,5 +1,6 @@
  1358. #include "bits/libc-vdso.h"
  1359. +#if 0 /* in Graphene, disallow VDSO calls */
  1360. #ifdef SHARED
  1361. # define SYSCALL_GETTIME(id, tp) \
  1362. ({ long int (*f) (clockid_t, struct timespec *) = __vdso_clock_gettime; \
  1363. @@ -16,5 +17,6 @@
  1364. PTR_DEMANGLE (f); \
  1365. f (id, tp); })
  1366. #endif
  1367. +#endif
  1368. #include "../clock_gettime.c"
  1369. diff --git a/sysdeps/unix/sysv/linux/x86_64/clone.S b/sysdeps/unix/sysv/linux/x86_64/clone.S
  1370. index 0508730..c011e7a 100644
  1371. --- a/sysdeps/unix/sysv/linux/x86_64/clone.S
  1372. +++ b/sysdeps/unix/sysv/linux/x86_64/clone.S
  1373. @@ -59,11 +59,15 @@ ENTRY (__clone)
  1374. jz SYSCALL_ERROR_LABEL
  1375. /* Insert the argument onto the new stack. */
  1376. - subq $16,%rsi
  1377. - movq %rcx,8(%rsi)
  1378. + subq $24,%rsi
  1379. + movq %rcx,16(%rsi)
  1380. /* Save the function pointer. It will be popped off in the
  1381. child in the ebx frobbing below. */
  1382. + movq %rdi,8(%rsi)
  1383. +
  1384. + /* Push an additional pointer as return address into the stack */
  1385. + leaq L(clone_return)(%rip),%rdi
  1386. movq %rdi,0(%rsi)
  1387. /* Do the system call. */
  1388. @@ -76,8 +80,9 @@ ENTRY (__clone)
  1389. /* End FDE now, because in the child the unwind info will be
  1390. wrong. */
  1391. cfi_endproc;
  1392. - syscall
  1393. + SYSCALL
  1394. +L(clone_return):
  1395. testq %rax,%rax
  1396. jl SYSCALL_ERROR_LABEL
  1397. jz L(thread_start)
  1398. @@ -99,13 +104,14 @@ L(thread_start):
  1399. movl $-1, %eax
  1400. jne 2f
  1401. movl $SYS_ify(getpid), %eax
  1402. - syscall
  1403. + SYSCALL
  1404. 2: movl %eax, %fs:PID
  1405. movl %eax, %fs:TID
  1406. 1:
  1407. #endif
  1408. /* Set up arguments for the function call. */
  1409. + addq $8,%rsp /* Skip the return address */
  1410. popq %rax /* Function to call. */
  1411. popq %rdi /* Argument. */
  1412. call *%rax
  1413. diff --git a/sysdeps/unix/sysv/linux/x86_64/getcontext.S b/sysdeps/unix/sysv/linux/x86_64/getcontext.S
  1414. index 140db03..870fb02 100644
  1415. --- a/sysdeps/unix/sysv/linux/x86_64/getcontext.S
  1416. +++ b/sysdeps/unix/sysv/linux/x86_64/getcontext.S
  1417. @@ -75,7 +75,7 @@ ENTRY(__getcontext)
  1418. #endif
  1419. movl $_NSIG8,%r10d
  1420. movl $__NR_rt_sigprocmask, %eax
  1421. - syscall
  1422. + SYSCALL
  1423. cmpq $-4095, %rax /* Check %rax for error. */
  1424. jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
  1425. diff --git a/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c b/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c
  1426. index 440ca7f..571125d 100644
  1427. --- a/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c
  1428. +++ b/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c
  1429. @@ -17,6 +17,7 @@
  1430. #include <sys/time.h>
  1431. +#if 0 /* In graphene, do not use vsyscall or VDSO call */
  1432. #ifdef SHARED
  1433. # include <dl-vdso.h>
  1434. @@ -42,7 +43,8 @@ asm (".type __gettimeofday, %gnu_indirect_function");
  1435. asm (".globl __GI___gettimeofday\n"
  1436. "__GI___gettimeofday = __gettimeofday");
  1437. -#else
  1438. +#endif
  1439. +#endif
  1440. # include <sysdep.h>
  1441. # include <errno.h>
  1442. @@ -54,6 +56,5 @@ __gettimeofday (struct timeval *tv, struct timezone *tz)
  1443. }
  1444. libc_hidden_def (__gettimeofday)
  1445. -#endif
  1446. weak_alias (__gettimeofday, gettimeofday)
  1447. libc_hidden_weak (gettimeofday)
  1448. diff --git a/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S b/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
  1449. index 0fd47f2..0247e2f 100644
  1450. --- a/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
  1451. +++ b/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S
  1452. @@ -30,6 +30,7 @@ ENTRY (sched_getcpu)
  1453. sub $0x8, %rsp
  1454. cfi_adjust_cfa_offset(8)
  1455. +#if 0 /* for Graphene, never do VDSO calls */
  1456. movq %rsp, %rdi
  1457. xorl %esi, %esi
  1458. movl $VGETCPU_CACHE_OFFSET, %edx
  1459. @@ -39,16 +40,19 @@ ENTRY (sched_getcpu)
  1460. movq __vdso_getcpu(%rip), %rax
  1461. PTR_DEMANGLE (%rax)
  1462. callq *%rax
  1463. -#else
  1464. -# ifdef __NR_getcpu
  1465. +#endif
  1466. +#endif
  1467. +
  1468. +#ifdef __NR_getcpu
  1469. movl $__NR_getcpu, %eax
  1470. - syscall
  1471. -# ifndef __ASSUME_GETCPU_SYSCALL
  1472. + SYSCALL
  1473. +#endif
  1474. +
  1475. +#if 0 /* for Graphene, never do vsyscall */
  1476. +# ifndef __ASSUME_GETCPU_SYSCALL
  1477. cmpq $-ENOSYS, %rax
  1478. jne 1f
  1479. -# endif
  1480. -# endif
  1481. -# ifndef __ASSUME_GETCPU_SYSCALL
  1482. +
  1483. movq $VSYSCALL_ADDR_vgetcpu, %rax
  1484. callq *%rax
  1485. 1:
  1486. diff --git a/sysdeps/unix/sysv/linux/x86_64/setcontext.S b/sysdeps/unix/sysv/linux/x86_64/setcontext.S
  1487. index b726fa0..96bf0ec 100644
  1488. --- a/sysdeps/unix/sysv/linux/x86_64/setcontext.S
  1489. +++ b/sysdeps/unix/sysv/linux/x86_64/setcontext.S
  1490. @@ -43,7 +43,7 @@ ENTRY(__setcontext)
  1491. movl $SIG_SETMASK, %edi
  1492. movl $_NSIG8,%r10d
  1493. movl $__NR_rt_sigprocmask, %eax
  1494. - syscall
  1495. + SYSCALL
  1496. popq %rdi /* Reload %rdi, adjust stack. */
  1497. cfi_adjust_cfa_offset(-8)
  1498. cmpq $-4095, %rax /* Check %rax for error. */
  1499. diff --git a/sysdeps/unix/sysv/linux/x86_64/sigaction.c b/sysdeps/unix/sysv/linux/x86_64/sigaction.c
  1500. index ab23985..39d0bdc 100644
  1501. --- a/sysdeps/unix/sysv/linux/x86_64/sigaction.c
  1502. +++ b/sysdeps/unix/sysv/linux/x86_64/sigaction.c
  1503. @@ -129,7 +129,8 @@ asm \
  1504. " .type __" #name ",@function\n" \
  1505. "__" #name ":\n" \
  1506. " movq $" #syscall ", %rax\n" \
  1507. - " syscall\n" \
  1508. + " movq syscalldb@GOTPCREL(%rip), %rbx\n" \
  1509. + " call *%rbx\n" \
  1510. ".LEND_" #name ":\n" \
  1511. ".section .eh_frame,\"a\",@progbits\n" \
  1512. ".LSTARTFRAME_" #name ":\n" \
  1513. diff --git a/sysdeps/unix/sysv/linux/x86_64/swapcontext.S b/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
  1514. index b3854fa..fd42f66 100644
  1515. --- a/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
  1516. +++ b/sysdeps/unix/sysv/linux/x86_64/swapcontext.S
  1517. @@ -75,7 +75,7 @@ ENTRY(__swapcontext)
  1518. movl $SIG_SETMASK, %edi
  1519. movl $_NSIG8,%r10d
  1520. movl $__NR_rt_sigprocmask, %eax
  1521. - syscall
  1522. + SYSCALL
  1523. cmpq $-4095, %rax /* Check %rax for error. */
  1524. jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
  1525. diff --git a/sysdeps/unix/sysv/linux/x86_64/syscall.S b/sysdeps/unix/sysv/linux/x86_64/syscall.S
  1526. index 92c2f5b..7b7ee12 100644
  1527. --- a/sysdeps/unix/sysv/linux/x86_64/syscall.S
  1528. +++ b/sysdeps/unix/sysv/linux/x86_64/syscall.S
  1529. @@ -34,7 +34,7 @@ ENTRY (syscall)
  1530. movq %r8, %r10
  1531. movq %r9, %r8
  1532. movq 8(%rsp),%r9 /* arg6 is on the stack. */
  1533. - syscall /* Do the system call. */
  1534. + SYSCALL /* Do the system call. */
  1535. cmpq $-4095, %rax /* Check %rax for error. */
  1536. jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
  1537. ret /* Return to caller. */
  1538. diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  1539. index 4a9a9d9..3b7434d 100644
  1540. --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  1541. +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  1542. @@ -21,6 +21,7 @@
  1543. /* There is some commonality. */
  1544. #include <sysdeps/unix/x86_64/sysdep.h>
  1545. #include <tls.h>
  1546. +#include "syscalldb.h"
  1547. #ifdef IS_IN_rtld
  1548. # include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
  1549. @@ -172,11 +173,18 @@
  1550. Syscalls of more than 6 arguments are not supported. */
  1551. +# undef SYSCALL
  1552. +# define SYSCALL \
  1553. + pushq %rbx; \
  1554. + movq syscalldb@GOTPCREL(%rip), %rbx; \
  1555. + call *%rbx; \
  1556. + popq %rbx;
  1557. +
  1558. # undef DO_CALL
  1559. # define DO_CALL(syscall_name, args) \
  1560. DOARGS_##args \
  1561. movl $SYS_ify (syscall_name), %eax; \
  1562. - syscall;
  1563. + SYSCALL
  1564. # define DOARGS_0 /* nothing */
  1565. # define DOARGS_1 /* nothing */
  1566. @@ -190,9 +198,20 @@
  1567. /* Define a macro which expands inline into the wrapper code for a system
  1568. call. */
  1569. # undef INLINE_SYSCALL
  1570. -# define INLINE_SYSCALL(name, nr, args...) \
  1571. +# define INLINE_SYSCALL(name, nr_args...) \
  1572. + ({ \
  1573. + unsigned long int resultvar = INTERNAL_SYSCALL (name, , ##nr_args); \
  1574. + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
  1575. + { \
  1576. + __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
  1577. + resultvar = (unsigned long int) -1; \
  1578. + } \
  1579. + (long int) resultvar; })
  1580. +
  1581. +# undef INLINE_SYSCALL_ASM
  1582. +# define INLINE_SYSCALL_ASM(name, nr_args...) \
  1583. ({ \
  1584. - unsigned long int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
  1585. + unsigned long int resultvar = INTERNAL_SYSCALL_ASM (name, , ##nr_args); \
  1586. if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
  1587. { \
  1588. __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
  1589. @@ -204,9 +223,9 @@
  1590. into the wrapper code for a system call. It should be used when size
  1591. of any argument > size of long int. */
  1592. # undef INLINE_SYSCALL_TYPES
  1593. -# define INLINE_SYSCALL_TYPES(name, nr, args...) \
  1594. +# define INLINE_SYSCALL_TYPES(name, nr_args...) \
  1595. ({ \
  1596. - unsigned long int resultvar = INTERNAL_SYSCALL_TYPES (name, , nr, args); \
  1597. + unsigned long int resultvar = INTERNAL_SYSCALL_TYPES (name, , ##nr_args); \
  1598. if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
  1599. { \
  1600. __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
  1601. @@ -223,13 +242,20 @@
  1602. LOAD_ARGS_##nr (args) \
  1603. LOAD_REGS_##nr \
  1604. asm volatile ( \
  1605. - "syscall\n\t" \
  1606. + "movq syscalldb@GOTPCREL(%%rip), %%rbx\n\t" \
  1607. + "call *%%rbx\n\t" \
  1608. : "=a" (resultvar) \
  1609. - : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx"); \
  1610. + : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx", "bx"); \
  1611. (long int) resultvar; })
  1612. +# define INTERNAL_SYSCALL_NCS_ASM INTERNAL_SYSCALL_NCS
  1613. +
  1614. # undef INTERNAL_SYSCALL
  1615. -# define INTERNAL_SYSCALL(name, err, nr, args...) \
  1616. - INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
  1617. +# define INTERNAL_SYSCALL(name, err, nr_args...) \
  1618. + INTERNAL_SYSCALL_NCS (__NR_##name, err, ##nr_args)
  1619. +
  1620. +# undef INTERNAL_SYSCALL_ASM
  1621. +# define INTERNAL_SYSCALL_ASM(name, err, nr_args...) \
  1622. + INTERNAL_SYSCALL_NCS_ASM (__NR_##name, err, ##nr_args)
  1623. # define INTERNAL_SYSCALL_NCS_TYPES(name, err, nr, args...) \
  1624. ({ \
  1625. @@ -237,9 +263,10 @@
  1626. LOAD_ARGS_TYPES_##nr (args) \
  1627. LOAD_REGS_TYPES_##nr (args) \
  1628. asm volatile ( \
  1629. - "syscall\n\t" \
  1630. + "movq syscalldb@GOTPCREL(%%rip), %%rbx\n\t" \
  1631. + "call *%%rbx\n\t" \
  1632. : "=a" (resultvar) \
  1633. - : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx"); \
  1634. + : "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx", "bx"); \
  1635. (long int) resultvar; })
  1636. # undef INTERNAL_SYSCALL_TYPES
  1637. # define INTERNAL_SYSCALL_TYPES(name, err, nr, args...) \
  1638. @@ -252,6 +279,7 @@
  1639. # undef INTERNAL_SYSCALL_ERRNO
  1640. # define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
  1641. +# if 0 /* for Graphene, never do vsyscall */
  1642. # ifdef SHARED
  1643. # define INLINE_VSYSCALL(name, nr, args...) \
  1644. ({ \
  1645. @@ -300,12 +328,13 @@
  1646. v_ret; \
  1647. })
  1648. -# else
  1649. -# define INLINE_VSYSCALL(name, nr, args...) \
  1650. - INLINE_SYSCALL (name, nr, ##args)
  1651. -# define INTERNAL_VSYSCALL(name, err, nr, args...) \
  1652. - INTERNAL_SYSCALL (name, err, nr, ##args)
  1653. # endif
  1654. +# endif
  1655. +
  1656. +# define INLINE_VSYSCALL(name, nr_args...) \
  1657. + INLINE_SYSCALL (name, ##nr_args)
  1658. +# define INTERNAL_VSYSCALL(name, err, nr_args...) \
  1659. + INTERNAL_SYSCALL (name, err, ##nr_args)
  1660. # define LOAD_ARGS_0()
  1661. # define LOAD_REGS_0
  1662. diff --git a/sysdeps/unix/sysv/linux/x86_64/time.c b/sysdeps/unix/sysv/linux/x86_64/time.c
  1663. deleted file mode 100644
  1664. index 79f1fab..0000000
  1665. --- a/sysdeps/unix/sysv/linux/x86_64/time.c
  1666. +++ /dev/null
  1667. @@ -1,60 +0,0 @@
  1668. -/* Copyright (C) 2001-2014 Free Software Foundation, Inc.
  1669. - This file is part of the GNU C Library.
  1670. -
  1671. - The GNU C Library is free software; you can redistribute it and/or
  1672. - modify it under the terms of the GNU Lesser General Public
  1673. - License as published by the Free Software Foundation; either
  1674. - version 2.1 of the License, or (at your option) any later version.
  1675. -
  1676. - The GNU C Library is distributed in the hope that it will be useful,
  1677. - but WITHOUT ANY WARRANTY; without even the implied warranty of
  1678. - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  1679. - Lesser General Public License for more details.
  1680. -
  1681. - You should have received a copy of the GNU Lesser General Public
  1682. - License along with the GNU C Library; if not, see
  1683. - <http://www.gnu.org/licenses/>. */
  1684. -
  1685. -#ifdef SHARED
  1686. -/* Redefine time so that the compiler won't complain about the type
  1687. - mismatch with the IFUNC selector in strong_alias, below. */
  1688. -#undef time
  1689. -#define time __redirect_time
  1690. -#include <time.h>
  1691. -
  1692. -#include <dl-vdso.h>
  1693. -
  1694. -#define VSYSCALL_ADDR_vtime 0xffffffffff600400
  1695. -
  1696. -/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
  1697. - ifunc symbol properly. */
  1698. -extern __typeof (__redirect_time) __libc_time;
  1699. -void *time_ifunc (void) __asm__ ("__libc_time");
  1700. -
  1701. -void *
  1702. -time_ifunc (void)
  1703. -{
  1704. - PREPARE_VERSION (linux26, "LINUX_2.6", 61765110);
  1705. -
  1706. - /* If the vDSO is not available we fall back on the old vsyscall. */
  1707. - return _dl_vdso_vsym ("__vdso_time", &linux26) ?: (void *) VSYSCALL_ADDR_vtime;
  1708. -}
  1709. -__asm (".type __libc_time, %gnu_indirect_function");
  1710. -
  1711. -#undef time
  1712. -strong_alias (__libc_time, time)
  1713. -libc_hidden_ver (__libc_time, time)
  1714. -
  1715. -#else
  1716. -
  1717. -# include <time.h>
  1718. -# include <sysdep.h>
  1719. -
  1720. -time_t
  1721. -time (time_t *t)
  1722. -{
  1723. - INTERNAL_SYSCALL_DECL (err);
  1724. - return INTERNAL_SYSCALL (time, err, 1, t);
  1725. -}
  1726. -
  1727. -#endif
  1728. diff --git a/sysdeps/unix/sysv/linux/x86_64/vfork.S b/sysdeps/unix/sysv/linux/x86_64/vfork.S
  1729. index d3b450a..76bda33 100644
  1730. --- a/sysdeps/unix/sysv/linux/x86_64/vfork.S
  1731. +++ b/sysdeps/unix/sysv/linux/x86_64/vfork.S
  1732. @@ -38,7 +38,7 @@ ENTRY (__vfork)
  1733. /* Stuff the syscall number in RAX and enter into the kernel. */
  1734. movl $SYS_ify (vfork), %eax
  1735. - syscall
  1736. + SYSCALL
  1737. /* Push back the return PC. */
  1738. pushq %rdi
  1739. diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
  1740. index 504c95f..dcfc259 100644
  1741. --- a/sysdeps/x86_64/dl-machine.h
  1742. +++ b/sysdeps/x86_64/dl-machine.h
  1743. @@ -529,7 +529,8 @@ elf_machine_lazy_rel (struct link_map *map,
  1744. value = ((ElfW(Addr) (*) (void)) value) ();
  1745. *reloc_addr = value;
  1746. }
  1747. - else
  1748. + /* for graphene, get around R_X86_64_NONE */
  1749. + else if (__builtin_expect (r_type != R_X86_64_NONE, 1))
  1750. _dl_reloc_bad_type (map, r_type, 1);
  1751. }