0003-Fix-compilation-with-fno-common.patch 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. From 29e17d8d2ccbca07c423e3089a6d5ae8a1c9cb6e Mon Sep 17 00:00:00 2001
  2. From: Yichao Yu <yyc1992@gmail.com>
  3. Date: Tue, 31 Mar 2020 00:43:32 -0400
  4. Subject: [PATCH] Fix compilation with -fno-common.
  5. Making all other archs consistent with IA64 which should not have this problem.
  6. Also move the FIXME to the correct place.
  7. Also add some minimum comments about this...
  8. [Retrieved from:
  9. https://github.com/libunwind/libunwind/commit/29e17d8d2ccbca07c423e3089a6d5ae8a1c9cb6e]
  10. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  11. ---
  12. src/aarch64/Ginit.c | 15 +++++++--------
  13. src/arm/Ginit.c | 15 +++++++--------
  14. src/coredump/_UPT_get_dyn_info_list_addr.c | 5 +++++
  15. src/hppa/Ginit.c | 15 +++++++--------
  16. src/ia64/Ginit.c | 1 +
  17. src/mi/Gfind_dynamic_proc_info.c | 1 +
  18. src/mips/Ginit.c | 15 +++++++--------
  19. src/ppc32/Ginit.c | 11 +++++++----
  20. src/ppc64/Ginit.c | 11 +++++++----
  21. src/ptrace/_UPT_get_dyn_info_list_addr.c | 5 +++++
  22. src/s390x/Ginit.c | 15 +++++++--------
  23. src/sh/Ginit.c | 15 +++++++--------
  24. src/tilegx/Ginit.c | 15 +++++++--------
  25. src/x86/Ginit.c | 15 +++++++--------
  26. src/x86_64/Ginit.c | 15 +++++++--------
  27. 15 files changed, 89 insertions(+), 80 deletions(-)
  28. diff --git a/src/aarch64/Ginit.c b/src/aarch64/Ginit.c
  29. index dec235c82..35389762f 100644
  30. --- a/src/aarch64/Ginit.c
  31. +++ b/src/aarch64/Ginit.c
  32. @@ -61,13 +61,6 @@ tdep_uc_addr (unw_tdep_context_t *uc, int reg)
  33. # endif /* UNW_LOCAL_ONLY */
  34. -HIDDEN unw_dyn_info_list_t _U_dyn_info_list;
  35. -
  36. -/* XXX fix me: there is currently no way to locate the dyn-info list
  37. - by a remote unwinder. On ia64, this is done via a special
  38. - unwind-table entry. Perhaps something similar can be done with
  39. - DWARF2 unwind info. */
  40. -
  41. static void
  42. put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg)
  43. {
  44. @@ -78,7 +71,13 @@ static int
  45. get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
  46. void *arg)
  47. {
  48. - *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list;
  49. +#ifndef UNW_LOCAL_ONLY
  50. +# pragma weak _U_dyn_info_list_addr
  51. + if (!_U_dyn_info_list_addr)
  52. + return -UNW_ENOINFO;
  53. +#endif
  54. + // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
  55. + *dyn_info_list_addr = _U_dyn_info_list_addr ();
  56. return 0;
  57. }
  58. diff --git a/src/arm/Ginit.c b/src/arm/Ginit.c
  59. index 2720d063a..0bac0d72d 100644
  60. --- a/src/arm/Ginit.c
  61. +++ b/src/arm/Ginit.c
  62. @@ -57,18 +57,17 @@ tdep_uc_addr (unw_tdep_context_t *uc, int reg)
  63. # endif /* UNW_LOCAL_ONLY */
  64. -HIDDEN unw_dyn_info_list_t _U_dyn_info_list;
  65. -
  66. -/* XXX fix me: there is currently no way to locate the dyn-info list
  67. - by a remote unwinder. On ia64, this is done via a special
  68. - unwind-table entry. Perhaps something similar can be done with
  69. - DWARF2 unwind info. */
  70. -
  71. static int
  72. get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
  73. void *arg)
  74. {
  75. - *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list;
  76. +#ifndef UNW_LOCAL_ONLY
  77. +# pragma weak _U_dyn_info_list_addr
  78. + if (!_U_dyn_info_list_addr)
  79. + return -UNW_ENOINFO;
  80. +#endif
  81. + // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
  82. + *dyn_info_list_addr = _U_dyn_info_list_addr ();
  83. return 0;
  84. }
  85. diff --git a/src/coredump/_UPT_get_dyn_info_list_addr.c b/src/coredump/_UPT_get_dyn_info_list_addr.c
  86. index 0d1190556..739ed0569 100644
  87. --- a/src/coredump/_UPT_get_dyn_info_list_addr.c
  88. +++ b/src/coredump/_UPT_get_dyn_info_list_addr.c
  89. @@ -74,6 +74,11 @@ get_list_addr (unw_addr_space_t as, unw_word_t *dil_addr, void *arg,
  90. #else
  91. +/* XXX fix me: there is currently no way to locate the dyn-info list
  92. + by a remote unwinder. On ia64, this is done via a special
  93. + unwind-table entry. Perhaps something similar can be done with
  94. + DWARF2 unwind info. */
  95. +
  96. static inline int
  97. get_list_addr (unw_addr_space_t as, unw_word_t *dil_addr, void *arg,
  98. int *countp)
  99. diff --git a/src/hppa/Ginit.c b/src/hppa/Ginit.c
  100. index 461e4b93d..265455a68 100644
  101. --- a/src/hppa/Ginit.c
  102. +++ b/src/hppa/Ginit.c
  103. @@ -64,13 +64,6 @@ _Uhppa_uc_addr (ucontext_t *uc, int reg)
  104. # endif /* UNW_LOCAL_ONLY */
  105. -HIDDEN unw_dyn_info_list_t _U_dyn_info_list;
  106. -
  107. -/* XXX fix me: there is currently no way to locate the dyn-info list
  108. - by a remote unwinder. On ia64, this is done via a special
  109. - unwind-table entry. Perhaps something similar can be done with
  110. - DWARF2 unwind info. */
  111. -
  112. static void
  113. put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg)
  114. {
  115. @@ -81,7 +74,13 @@ static int
  116. get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
  117. void *arg)
  118. {
  119. - *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list;
  120. +#ifndef UNW_LOCAL_ONLY
  121. +# pragma weak _U_dyn_info_list_addr
  122. + if (!_U_dyn_info_list_addr)
  123. + return -UNW_ENOINFO;
  124. +#endif
  125. + // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
  126. + *dyn_info_list_addr = _U_dyn_info_list_addr ();
  127. return 0;
  128. }
  129. diff --git a/src/ia64/Ginit.c b/src/ia64/Ginit.c
  130. index b09a2ad57..8601bb3ca 100644
  131. --- a/src/ia64/Ginit.c
  132. +++ b/src/ia64/Ginit.c
  133. @@ -68,6 +68,7 @@ get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
  134. if (!_U_dyn_info_list_addr)
  135. return -UNW_ENOINFO;
  136. #endif
  137. + // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
  138. *dyn_info_list_addr = _U_dyn_info_list_addr ();
  139. return 0;
  140. }
  141. diff --git a/src/mi/Gfind_dynamic_proc_info.c b/src/mi/Gfind_dynamic_proc_info.c
  142. index 98d350128..2e7c62e5e 100644
  143. --- a/src/mi/Gfind_dynamic_proc_info.c
  144. +++ b/src/mi/Gfind_dynamic_proc_info.c
  145. @@ -49,6 +49,7 @@ local_find_proc_info (unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
  146. return -UNW_ENOINFO;
  147. #endif
  148. + // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
  149. list = (unw_dyn_info_list_t *) (uintptr_t) _U_dyn_info_list_addr ();
  150. for (di = list->first; di; di = di->next)
  151. if (ip >= di->start_ip && ip < di->end_ip)
  152. diff --git a/src/mips/Ginit.c b/src/mips/Ginit.c
  153. index 3df170c75..bf7a8f5a8 100644
  154. --- a/src/mips/Ginit.c
  155. +++ b/src/mips/Ginit.c
  156. @@ -69,13 +69,6 @@ tdep_uc_addr (ucontext_t *uc, int reg)
  157. # endif /* UNW_LOCAL_ONLY */
  158. -HIDDEN unw_dyn_info_list_t _U_dyn_info_list;
  159. -
  160. -/* XXX fix me: there is currently no way to locate the dyn-info list
  161. - by a remote unwinder. On ia64, this is done via a special
  162. - unwind-table entry. Perhaps something similar can be done with
  163. - DWARF2 unwind info. */
  164. -
  165. static void
  166. put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg)
  167. {
  168. @@ -86,7 +79,13 @@ static int
  169. get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
  170. void *arg)
  171. {
  172. - *dyn_info_list_addr = (unw_word_t) (intptr_t) &_U_dyn_info_list;
  173. +#ifndef UNW_LOCAL_ONLY
  174. +# pragma weak _U_dyn_info_list_addr
  175. + if (!_U_dyn_info_list_addr)
  176. + return -UNW_ENOINFO;
  177. +#endif
  178. + // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
  179. + *dyn_info_list_addr = _U_dyn_info_list_addr ();
  180. return 0;
  181. }
  182. diff --git a/src/ppc32/Ginit.c b/src/ppc32/Ginit.c
  183. index ba302448a..7b4545580 100644
  184. --- a/src/ppc32/Ginit.c
  185. +++ b/src/ppc32/Ginit.c
  186. @@ -91,9 +91,6 @@ tdep_uc_addr (ucontext_t *uc, int reg)
  187. # endif /* UNW_LOCAL_ONLY */
  188. -HIDDEN unw_dyn_info_list_t _U_dyn_info_list;
  189. -
  190. -
  191. static void
  192. put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg)
  193. {
  194. @@ -104,7 +101,13 @@ static int
  195. get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
  196. void *arg)
  197. {
  198. - *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list;
  199. +#ifndef UNW_LOCAL_ONLY
  200. +# pragma weak _U_dyn_info_list_addr
  201. + if (!_U_dyn_info_list_addr)
  202. + return -UNW_ENOINFO;
  203. +#endif
  204. + // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
  205. + *dyn_info_list_addr = _U_dyn_info_list_addr ();
  206. return 0;
  207. }
  208. diff --git a/src/ppc64/Ginit.c b/src/ppc64/Ginit.c
  209. index 4c88cd6e7..7bfb395a7 100644
  210. --- a/src/ppc64/Ginit.c
  211. +++ b/src/ppc64/Ginit.c
  212. @@ -95,9 +95,6 @@ tdep_uc_addr (ucontext_t *uc, int reg)
  213. # endif /* UNW_LOCAL_ONLY */
  214. -HIDDEN unw_dyn_info_list_t _U_dyn_info_list;
  215. -
  216. -
  217. static void
  218. put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg)
  219. {
  220. @@ -108,7 +105,13 @@ static int
  221. get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
  222. void *arg)
  223. {
  224. - *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list;
  225. +#ifndef UNW_LOCAL_ONLY
  226. +# pragma weak _U_dyn_info_list_addr
  227. + if (!_U_dyn_info_list_addr)
  228. + return -UNW_ENOINFO;
  229. +#endif
  230. + // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
  231. + *dyn_info_list_addr = _U_dyn_info_list_addr ();
  232. return 0;
  233. }
  234. diff --git a/src/ptrace/_UPT_get_dyn_info_list_addr.c b/src/ptrace/_UPT_get_dyn_info_list_addr.c
  235. index cc5ed0441..16671d453 100644
  236. --- a/src/ptrace/_UPT_get_dyn_info_list_addr.c
  237. +++ b/src/ptrace/_UPT_get_dyn_info_list_addr.c
  238. @@ -71,6 +71,11 @@ get_list_addr (unw_addr_space_t as, unw_word_t *dil_addr, void *arg,
  239. #else
  240. +/* XXX fix me: there is currently no way to locate the dyn-info list
  241. + by a remote unwinder. On ia64, this is done via a special
  242. + unwind-table entry. Perhaps something similar can be done with
  243. + DWARF2 unwind info. */
  244. +
  245. static inline int
  246. get_list_addr (unw_addr_space_t as, unw_word_t *dil_addr, void *arg,
  247. int *countp)
  248. diff --git a/src/s390x/Ginit.c b/src/s390x/Ginit.c
  249. index f0886ac93..db01743c0 100644
  250. --- a/src/s390x/Ginit.c
  251. +++ b/src/s390x/Ginit.c
  252. @@ -50,8 +50,6 @@ static struct unw_addr_space local_addr_space;
  253. unw_addr_space_t unw_local_addr_space = &local_addr_space;
  254. -HIDDEN unw_dyn_info_list_t _U_dyn_info_list;
  255. -
  256. static inline void *
  257. uc_addr (ucontext_t *uc, int reg)
  258. {
  259. @@ -75,11 +73,6 @@ tdep_uc_addr (ucontext_t *uc, int reg)
  260. # endif /* UNW_LOCAL_ONLY */
  261. -/* XXX fix me: there is currently no way to locate the dyn-info list
  262. - by a remote unwinder. On ia64, this is done via a special
  263. - unwind-table entry. Perhaps something similar can be done with
  264. - DWARF2 unwind info. */
  265. -
  266. static void
  267. put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg)
  268. {
  269. @@ -90,7 +83,13 @@ static int
  270. get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
  271. void *arg)
  272. {
  273. - *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list;
  274. +#ifndef UNW_LOCAL_ONLY
  275. +# pragma weak _U_dyn_info_list_addr
  276. + if (!_U_dyn_info_list_addr)
  277. + return -UNW_ENOINFO;
  278. +#endif
  279. + // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
  280. + *dyn_info_list_addr = _U_dyn_info_list_addr ();
  281. return 0;
  282. }
  283. diff --git a/src/sh/Ginit.c b/src/sh/Ginit.c
  284. index 52988a721..9fe96d2bd 100644
  285. --- a/src/sh/Ginit.c
  286. +++ b/src/sh/Ginit.c
  287. @@ -58,13 +58,6 @@ tdep_uc_addr (ucontext_t *uc, int reg)
  288. # endif /* UNW_LOCAL_ONLY */
  289. -HIDDEN unw_dyn_info_list_t _U_dyn_info_list;
  290. -
  291. -/* XXX fix me: there is currently no way to locate the dyn-info list
  292. - by a remote unwinder. On ia64, this is done via a special
  293. - unwind-table entry. Perhaps something similar can be done with
  294. - DWARF2 unwind info. */
  295. -
  296. static void
  297. put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg)
  298. {
  299. @@ -75,7 +68,13 @@ static int
  300. get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
  301. void *arg)
  302. {
  303. - *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list;
  304. +#ifndef UNW_LOCAL_ONLY
  305. +# pragma weak _U_dyn_info_list_addr
  306. + if (!_U_dyn_info_list_addr)
  307. + return -UNW_ENOINFO;
  308. +#endif
  309. + // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
  310. + *dyn_info_list_addr = _U_dyn_info_list_addr ();
  311. return 0;
  312. }
  313. diff --git a/src/tilegx/Ginit.c b/src/tilegx/Ginit.c
  314. index 7564a558b..925e64132 100644
  315. --- a/src/tilegx/Ginit.c
  316. +++ b/src/tilegx/Ginit.c
  317. @@ -64,13 +64,6 @@ tdep_uc_addr (ucontext_t *uc, int reg)
  318. # endif /* UNW_LOCAL_ONLY */
  319. -HIDDEN unw_dyn_info_list_t _U_dyn_info_list;
  320. -
  321. -/* XXX fix me: there is currently no way to locate the dyn-info list
  322. - by a remote unwinder. On ia64, this is done via a special
  323. - unwind-table entry. Perhaps something similar can be done with
  324. - DWARF2 unwind info. */
  325. -
  326. static void
  327. put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg)
  328. {
  329. @@ -81,7 +74,13 @@ static int
  330. get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
  331. void *arg)
  332. {
  333. - *dyn_info_list_addr = (unw_word_t) (intptr_t) &_U_dyn_info_list;
  334. +#ifndef UNW_LOCAL_ONLY
  335. +# pragma weak _U_dyn_info_list_addr
  336. + if (!_U_dyn_info_list_addr)
  337. + return -UNW_ENOINFO;
  338. +#endif
  339. + // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
  340. + *dyn_info_list_addr = _U_dyn_info_list_addr ();
  341. return 0;
  342. }
  343. diff --git a/src/x86/Ginit.c b/src/x86/Ginit.c
  344. index f6b8dc27d..3cec74a21 100644
  345. --- a/src/x86/Ginit.c
  346. +++ b/src/x86/Ginit.c
  347. @@ -54,13 +54,6 @@ tdep_uc_addr (ucontext_t *uc, int reg)
  348. # endif /* UNW_LOCAL_ONLY */
  349. -HIDDEN unw_dyn_info_list_t _U_dyn_info_list;
  350. -
  351. -/* XXX fix me: there is currently no way to locate the dyn-info list
  352. - by a remote unwinder. On ia64, this is done via a special
  353. - unwind-table entry. Perhaps something similar can be done with
  354. - DWARF2 unwind info. */
  355. -
  356. static void
  357. put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg)
  358. {
  359. @@ -71,7 +64,13 @@ static int
  360. get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
  361. void *arg)
  362. {
  363. - *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list;
  364. +#ifndef UNW_LOCAL_ONLY
  365. +# pragma weak _U_dyn_info_list_addr
  366. + if (!_U_dyn_info_list_addr)
  367. + return -UNW_ENOINFO;
  368. +#endif
  369. + // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
  370. + *dyn_info_list_addr = _U_dyn_info_list_addr ();
  371. return 0;
  372. }
  373. diff --git a/src/x86_64/Ginit.c b/src/x86_64/Ginit.c
  374. index a865d3385..fd8d418b1 100644
  375. --- a/src/x86_64/Ginit.c
  376. +++ b/src/x86_64/Ginit.c
  377. @@ -49,13 +49,6 @@ static struct unw_addr_space local_addr_space;
  378. unw_addr_space_t unw_local_addr_space = &local_addr_space;
  379. -HIDDEN unw_dyn_info_list_t _U_dyn_info_list;
  380. -
  381. -/* XXX fix me: there is currently no way to locate the dyn-info list
  382. - by a remote unwinder. On ia64, this is done via a special
  383. - unwind-table entry. Perhaps something similar can be done with
  384. - DWARF2 unwind info. */
  385. -
  386. static void
  387. put_unwind_info (unw_addr_space_t as, unw_proc_info_t *proc_info, void *arg)
  388. {
  389. @@ -66,7 +59,13 @@ static int
  390. get_dyn_info_list_addr (unw_addr_space_t as, unw_word_t *dyn_info_list_addr,
  391. void *arg)
  392. {
  393. - *dyn_info_list_addr = (unw_word_t) &_U_dyn_info_list;
  394. +#ifndef UNW_LOCAL_ONLY
  395. +# pragma weak _U_dyn_info_list_addr
  396. + if (!_U_dyn_info_list_addr)
  397. + return -UNW_ENOINFO;
  398. +#endif
  399. + // Access the `_U_dyn_info_list` from `LOCAL_ONLY` library, i.e. libunwind.so.
  400. + *dyn_info_list_addr = _U_dyn_info_list_addr ();
  401. return 0;
  402. }