1
0

sh4-trap.patch 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. commit db3d848e154b00071f4a5e729d5884efad410109
  2. Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
  3. Date: Wed Mar 15 15:44:59 2017 -0300
  4. Build divdi3 only for architecture that required it
  5. As noted in [1], divdi3 object is only exported in a handful ABIs
  6. (i386, m68k, powerpc32, s390-32, and ia64), however it is built
  7. for all current architectures regardless.
  8. This patch refact the make rules for this object to so only the
  9. aforementioned architectures that actually require it builds it.
  10. Also, to avoid internal PLT calls to the exported symbol from the
  11. module, glibc uses an internal header (symbol-hacks.h) which is
  12. unrequired (and in fact breaks the build for architectures that
  13. intend to get symbol definitions from libgcc.a). The patch also
  14. changes it to create its own header (divdi3-symbol-hacks.h) and
  15. adjust the architectures that require it accordingly.
  16. I checked the build/check (with run-built-tests=no) on the
  17. following architectures (which I think must cover all supported
  18. ABI/builds) using GCC 6.3:
  19. aarch64-linux-gnu
  20. alpha-linux-gnu
  21. arm-linux-gnueabihf
  22. hppa-linux-gnu
  23. ia64-linux-gnu
  24. m68k-linux-gnu
  25. microblaze-linux-gnu
  26. mips64-n32-linux-gnu
  27. mips-linux-gnu
  28. mips64-linux-gnu
  29. nios2-linux-gnu
  30. powerpc-linux-gnu
  31. powerpc-linux-gnu-power4
  32. powerpc64-linux-gnu
  33. powerpc64le-linux-gnu
  34. s390x-linux-gnu
  35. s390-linux-gnu
  36. sh4-linux-gnu
  37. sh4-linux-gnu-soft
  38. sparc64-linux-gnu
  39. sparcv9-linux-gnu
  40. tilegx-linux-gnu
  41. tilegx-linux-gnu-32
  42. tilepro-linux-gnu
  43. x86_64-linux-gnu
  44. x86_64-linux-gnu-x32
  45. i686-linux-gnu
  46. I only saw one regression on sparcv9-linux-gnu (extra PLT call to
  47. .udiv) which I address in next patch in the set. It also correctly
  48. build SH with GCC 7.0.1 (without any regression from c89721e25d).
  49. [1] https://sourceware.org/ml/libc-alpha/2017-03/msg00243.html
  50. * sysdeps/i386/symbol-hacks.h: New file.
  51. * sysdeps/m68k/symbol-hacks.h: New file.
  52. * sysdeps/powerpc/powerpc32/symbol-hacks.h: New file.
  53. * sysdeps/s390/s390-32/symbol-hacks.h: New file.
  54. * sysdeps/unix/sysv/linux/i386/Makefile
  55. [$(subdir) = csu] (sysdep_routines): New rule: divdi3 object.
  56. [$(subdir) = csu] (sysdep-only-routines): Likewise.
  57. [$(subdir) = csu] (CFLAGS-divdi3.c): Likewise.
  58. * sysdeps/unix/sysv/linux/m68k/Makefile
  59. [$(subdir) = csu] (sysdep_routines): Likewise.
  60. [$(subdir) = csu] (sysdep-only-routines): Likewise.
  61. [$(subdir) = csu] (CFLAGS-divdi3.c): Likewise.
  62. * sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile
  63. [$(subdir) = csu] (sysdep_routines): Likewise.
  64. [$(subdir) = csu] (sysdep-only-routines): Likewise.
  65. [$(subdir) = csu] (CFLAGS-divdi3.c): Likewise.
  66. * sysdeps/unix/sysv/linux/s390/s390-32/Makefile
  67. [$(subdir) = csu] (sysdep_routines): Likewise.
  68. [$(subdir) = csu] (sysdep-only-routines): Likewise.
  69. [$(subdir) = csu] (CFLAGS-divdi3.c): Likewise.
  70. * sysdeps/wordsize-32/Makefile: Remove file.
  71. * sysdeps/wordsize-32/symbol-hacks.h: Definitions move to ...
  72. * sysdeps/wordsize-32/divdi3-symbol-hacks.h: ... here.
  73. diff --git a/sysdeps/i386/symbol-hacks.h b/sysdeps/i386/symbol-hacks.h
  74. new file mode 100644
  75. index 0000000000..36a13c83f7
  76. --- /dev/null
  77. +++ b/sysdeps/i386/symbol-hacks.h
  78. @@ -0,0 +1,21 @@
  79. +/* Hacks needed for symbol manipulation. i386 version.
  80. + Copyright (C) 2017 Free Software Foundation, Inc.
  81. + This file is part of the GNU C Library.
  82. +
  83. + The GNU C Library is free software; you can redistribute it and/or
  84. + modify it under the terms of the GNU Lesser General Public
  85. + License as published by the Free Software Foundation; either
  86. + version 2.1 of the License, or (at your option) any later version.
  87. +
  88. + The GNU C Library is distributed in the hope that it will be useful,
  89. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  90. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  91. + Lesser General Public License for more details.
  92. +
  93. + You should have received a copy of the GNU Lesser General Public
  94. + License along with the GNU C Library; if not, see
  95. + <http://www.gnu.org/licenses/>. */
  96. +
  97. +#include <sysdeps/wordsize-32/divdi3-symbol-hacks.h>
  98. +
  99. +#include_next "symbol-hacks.h"
  100. diff --git a/sysdeps/m68k/symbol-hacks.h b/sysdeps/m68k/symbol-hacks.h
  101. new file mode 100644
  102. index 0000000000..e449d29810
  103. --- /dev/null
  104. +++ b/sysdeps/m68k/symbol-hacks.h
  105. @@ -0,0 +1,21 @@
  106. +/* Hacks needed for symbol manipulation. m68k version.
  107. + Copyright (C) 2017 Free Software Foundation, Inc.
  108. + This file is part of the GNU C Library.
  109. +
  110. + The GNU C Library is free software; you can redistribute it and/or
  111. + modify it under the terms of the GNU Lesser General Public
  112. + License as published by the Free Software Foundation; either
  113. + version 2.1 of the License, or (at your option) any later version.
  114. +
  115. + The GNU C Library is distributed in the hope that it will be useful,
  116. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  117. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  118. + Lesser General Public License for more details.
  119. +
  120. + You should have received a copy of the GNU Lesser General Public
  121. + License along with the GNU C Library; if not, see
  122. + <http://www.gnu.org/licenses/>. */
  123. +
  124. +#include <sysdeps/wordsize-32/divdi3-symbol-hacks.h>
  125. +
  126. +#include_next "symbol-hacks.h"
  127. diff --git a/sysdeps/powerpc/powerpc32/symbol-hacks.h b/sysdeps/powerpc/powerpc32/symbol-hacks.h
  128. new file mode 100644
  129. index 0000000000..dbb3141621
  130. --- /dev/null
  131. +++ b/sysdeps/powerpc/powerpc32/symbol-hacks.h
  132. @@ -0,0 +1,21 @@
  133. +/* Hacks needed for symbol manipulation. powerpc version.
  134. + Copyright (C) 2017 Free Software Foundation, Inc.
  135. + This file is part of the GNU C Library.
  136. +
  137. + The GNU C Library is free software; you can redistribute it and/or
  138. + modify it under the terms of the GNU Lesser General Public
  139. + License as published by the Free Software Foundation; either
  140. + version 2.1 of the License, or (at your option) any later version.
  141. +
  142. + The GNU C Library is distributed in the hope that it will be useful,
  143. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  144. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  145. + Lesser General Public License for more details.
  146. +
  147. + You should have received a copy of the GNU Lesser General Public
  148. + License along with the GNU C Library; if not, see
  149. + <http://www.gnu.org/licenses/>. */
  150. +
  151. +#include <sysdeps/wordsize-32/divdi3-symbol-hacks.h>
  152. +
  153. +#include_next "symbol-hacks.h"
  154. diff --git a/sysdeps/s390/s390-32/symbol-hacks.h b/sysdeps/s390/s390-32/symbol-hacks.h
  155. new file mode 100644
  156. index 0000000000..585c42365a
  157. --- /dev/null
  158. +++ b/sysdeps/s390/s390-32/symbol-hacks.h
  159. @@ -0,0 +1,21 @@
  160. +/* Hacks needed for symbol manipulation. s390 version.
  161. + Copyright (C) 2017 Free Software Foundation, Inc.
  162. + This file is part of the GNU C Library.
  163. +
  164. + The GNU C Library is free software; you can redistribute it and/or
  165. + modify it under the terms of the GNU Lesser General Public
  166. + License as published by the Free Software Foundation; either
  167. + version 2.1 of the License, or (at your option) any later version.
  168. +
  169. + The GNU C Library is distributed in the hope that it will be useful,
  170. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  171. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  172. + Lesser General Public License for more details.
  173. +
  174. + You should have received a copy of the GNU Lesser General Public
  175. + License along with the GNU C Library; if not, see
  176. + <http://www.gnu.org/licenses/>. */
  177. +
  178. +#include <sysdeps/wordsize-32/divdi3-symbol-hacks.h>
  179. +
  180. +#include_next "symbol-hacks.h"
  181. diff --git a/sysdeps/unix/sysv/linux/i386/Makefile b/sysdeps/unix/sysv/linux/i386/Makefile
  182. index 6aac0dfe15..4080b8c966 100644
  183. --- a/sysdeps/unix/sysv/linux/i386/Makefile
  184. +++ b/sysdeps/unix/sysv/linux/i386/Makefile
  185. @@ -26,6 +26,11 @@ endif
  186. ifeq ($(subdir),csu)
  187. sysdep-dl-routines += sysdep
  188. +ifeq (yes,$(build-shared))
  189. +sysdep_routines += divdi3
  190. +shared-only-routines += divdi3
  191. +CPPFLAGS-divdi3.c = -Din_divdi3_c
  192. +endif
  193. endif
  194. ifeq ($(subdir),nptl)
  195. diff --git a/sysdeps/unix/sysv/linux/m68k/Makefile b/sysdeps/unix/sysv/linux/m68k/Makefile
  196. index 5c50ce6927..ce1f696a6f 100644
  197. --- a/sysdeps/unix/sysv/linux/m68k/Makefile
  198. +++ b/sysdeps/unix/sysv/linux/m68k/Makefile
  199. @@ -4,6 +4,11 @@ m68k-syntax-flag = -DMOTOROLA_SYNTAX
  200. ifeq ($(subdir),csu)
  201. sysdep_routines += m68k-helpers
  202. +ifeq (yes,$(build-shared))
  203. +sysdep_routines += divdi3
  204. +shared-only-routines += divdi3
  205. +CPPFLAGS-divdi3.c = -Din_divdi3_c
  206. +endif
  207. endif
  208. ifeq ($(subdir),misc)
  209. diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile b/sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile
  210. index 3d6c150582..1f45659ed1 100644
  211. --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile
  212. +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile
  213. @@ -1,2 +1,10 @@
  214. # See Makeconfig regarding the use of default-abi.
  215. default-abi := 32
  216. +
  217. +ifeq ($(subdir),csu)
  218. +ifeq (yes,$(build-shared))
  219. +sysdep_routines += divdi3
  220. +shared-only-routines += divdi3
  221. +CPPFLAGS-divdi3.c = -Din_divdi3_c
  222. +endif
  223. +endif
  224. diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/Makefile b/sysdeps/unix/sysv/linux/s390/s390-32/Makefile
  225. index da3b3c76b4..fd8cf92633 100644
  226. --- a/sysdeps/unix/sysv/linux/s390/s390-32/Makefile
  227. +++ b/sysdeps/unix/sysv/linux/s390/s390-32/Makefile
  228. @@ -21,3 +21,11 @@ endif
  229. ifeq ($(subdir),stdlib)
  230. sysdep_routines += __makecontext_ret
  231. endif
  232. +
  233. +ifeq ($(subdir),csu)
  234. +ifeq (yes,$(build-shared))
  235. +sysdep_routines += divdi3
  236. +shared-only-routines += divdi3
  237. +CPPFLAGS-divdi3.c = -Din_divdi3_c
  238. +endif
  239. +endif
  240. diff --git a/sysdeps/wordsize-32/Makefile b/sysdeps/wordsize-32/Makefile
  241. deleted file mode 100644
  242. index 82beac44ed..0000000000
  243. --- a/sysdeps/wordsize-32/Makefile
  244. +++ /dev/null
  245. @@ -1,7 +0,0 @@
  246. -ifeq ($(subdir),csu)
  247. -ifeq (yes,$(build-shared))
  248. -sysdep_routines += divdi3
  249. -shared-only-routines += divdi3
  250. -CPPFLAGS-divdi3.c = -Din_divdi3_c
  251. -endif
  252. -endif
  253. diff --git a/sysdeps/wordsize-32/divdi3-symbol-hacks.h b/sysdeps/wordsize-32/divdi3-symbol-hacks.h
  254. new file mode 100644
  255. index 0000000000..6c90cb796d
  256. --- /dev/null
  257. +++ b/sysdeps/wordsize-32/divdi3-symbol-hacks.h
  258. @@ -0,0 +1,31 @@
  259. +/* Hacks needed for divdi3 symbol manipulation.
  260. + Copyright (C) 2004-2017 Free Software Foundation, Inc.
  261. + This file is part of the GNU C Library.
  262. +
  263. + The GNU C Library is free software; you can redistribute it and/or
  264. + modify it under the terms of the GNU Lesser General Public
  265. + License as published by the Free Software Foundation; either
  266. + version 2.1 of the License, or (at your option) any later version.
  267. +
  268. + The GNU C Library is distributed in the hope that it will be useful,
  269. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  270. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  271. + Lesser General Public License for more details.
  272. +
  273. + You should have received a copy of the GNU Lesser General Public
  274. + License along with the GNU C Library; if not, see
  275. + <http://www.gnu.org/licenses/>. */
  276. +
  277. +/* A very dirty trick: gcc emits references to __divdi3, __udivdi3,
  278. + __moddi3, and __umoddi3. These functions are exported and
  279. + therefore we get PLTs. Unnecessarily so. Changing gcc is a big
  280. + task which might not be worth it so we play tricks with the
  281. + assembler.
  282. + Note: in_divdi3_c is only used to avoid symbol alias on divdi3
  283. + build itself. */
  284. +#if !defined __ASSEMBLER__ && !defined in_divdi3_c && IS_IN (libc) && defined SHARED
  285. +asm ("__divdi3 = __divdi3_internal");
  286. +asm ("__udivdi3 = __udivdi3_internal");
  287. +asm ("__moddi3 = __moddi3_internal");
  288. +asm ("__umoddi3 = __umoddi3_internal");
  289. +#endif
  290. diff --git a/sysdeps/wordsize-32/symbol-hacks.h b/sysdeps/wordsize-32/symbol-hacks.h
  291. deleted file mode 100644
  292. index 0aec1e0b97..0000000000
  293. --- a/sysdeps/wordsize-32/symbol-hacks.h
  294. +++ /dev/null
  295. @@ -1,31 +0,0 @@
  296. -/* Hacks needed for symbol manipulation.
  297. - Copyright (C) 2004-2017 Free Software Foundation, Inc.
  298. - This file is part of the GNU C Library.
  299. -
  300. - The GNU C Library is free software; you can redistribute it and/or
  301. - modify it under the terms of the GNU Lesser General Public
  302. - License as published by the Free Software Foundation; either
  303. - version 2.1 of the License, or (at your option) any later version.
  304. -
  305. - The GNU C Library is distributed in the hope that it will be useful,
  306. - but WITHOUT ANY WARRANTY; without even the implied warranty of
  307. - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  308. - Lesser General Public License for more details.
  309. -
  310. - You should have received a copy of the GNU Lesser General Public
  311. - License along with the GNU C Library; if not, see
  312. - <http://www.gnu.org/licenses/>. */
  313. -
  314. -#include_next "symbol-hacks.h"
  315. -
  316. -/* A very dirty trick: gcc emits references to __divdi3, __udivdi3,
  317. - __moddi3, and __umoddi3. These functions are exported and
  318. - therefore we get PLTs. Unnecessarily so. Changing gcc is a big
  319. - task which might not be worth it so we play tricks with the
  320. - assembler. */
  321. -#if !defined __ASSEMBLER__ && !defined in_divdi3_c && IS_IN (libc) && defined SHARED
  322. -asm ("__divdi3 = __divdi3_internal");
  323. -asm ("__udivdi3 = __udivdi3_internal");
  324. -asm ("__moddi3 = __moddi3_internal");
  325. -asm ("__umoddi3 = __umoddi3_internal");
  326. -#endif