100-portability.patch 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. --- a/configure.ac
  2. +++ b/configure.ac
  3. @@ -44,6 +44,7 @@ fi
  4. AC_CONFIG_AUX_DIR([config])
  5. AC_CONFIG_FILES([config/Makefile])
  6. +AC_CONFIG_FILES([libgnu/Makefile])
  7. AC_COPYRIGHT([Copyright (C) 1996-2024 The elfutils developers.])
  8. AC_PREREQ(2.63) dnl Minimum Autoconf version required.
  9. @@ -88,11 +89,14 @@ AS_IF([test "$use_locks" = yes],
  10. AH_TEMPLATE([USE_LOCKS], [Defined if libraries should be thread-safe.])
  11. +AC_USE_SYSTEM_EXTENSIONS()
  12. +
  13. m4_version_prereq([2.70], [AC_PROG_CC], [AC_PROG_CC_C99])
  14. AC_PROG_CXX
  15. AC_PROG_RANLIB
  16. AC_PROG_YACC
  17. AC_PROG_LEX([noyywrap])
  18. +gl_EARLY
  19. # Only available since automake 1.12
  20. m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
  21. AC_CHECK_TOOL([READELF], [readelf])
  22. @@ -646,6 +650,8 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],
  23. CFLAGS="$old_CFLAGS"])
  24. AS_IF([test "x$ac_cv_fno_addrsig" = "xyes"], CFLAGS="$CFLAGS -fno-addrsig")
  25. +gl_INIT
  26. +
  27. saved_LIBS="$LIBS"
  28. AC_SEARCH_LIBS([argp_parse], [argp])
  29. LIBS="$saved_LIBS"
  30. --- a/lib/eu-config.h
  31. +++ b/lib/eu-config.h
  32. @@ -31,14 +31,19 @@
  33. #include "locks.h"
  34. -#include <libintl.h>
  35. +#include <gettext.h>
  36. /* gettext helper macros. */
  37. #define N_(Str) Str
  38. #define _(Str) dgettext ("elfutils", Str)
  39. /* Compiler-specific definitions. */
  40. +#define __PRAGMA(str) _Pragma (#str)
  41. +#ifdef __APPLE__
  42. +#define strong_alias(name, aliasname) __PRAGMA(weak aliasname = name)
  43. +#else
  44. #define strong_alias(name, aliasname) \
  45. extern __typeof (name) aliasname __attribute__ ((alias (#name)));
  46. +#endif
  47. #ifdef __i386__
  48. # define internal_function __attribute__ ((regparm (3), stdcall))
  49. @@ -49,7 +54,7 @@
  50. #define internal_strong_alias(name, aliasname) \
  51. extern __typeof (name) aliasname __attribute__ ((alias (#name))) internal_function;
  52. -#ifdef HAVE_VISIBILITY
  53. +#if defined(HAVE_VISIBILITY) && !defined(__APPLE__)
  54. #define attribute_hidden \
  55. __attribute__ ((visibility ("hidden")))
  56. #else
  57. @@ -138,7 +143,7 @@ asm (".section predict_data, \"aw\"; .pr
  58. #endif
  59. /* Avoid PLT entries. */
  60. -#ifdef PIC
  61. +#if defined(PIC) && !defined(__APPLE__)
  62. # define INTUSE(name) _INTUSE(name)
  63. # define _INTUSE(name) __##name##_internal
  64. # define INTDEF(name) _INTDEF(name)
  65. --- a/backends/i386_auxv.c
  66. +++ b/backends/i386_auxv.c
  67. @@ -48,5 +48,4 @@ EBLHOOK(auxv_info) (GElf_Xword a_type, c
  68. return 1;
  69. }
  70. -__typeof (i386_auxv_info) x86_64_auxv_info
  71. - __attribute__ ((alias ("i386_auxv_info")));
  72. +auxv_info_alias(x86_64)
  73. --- a/backends/ppc_regs.c
  74. +++ b/backends/ppc_regs.c
  75. @@ -204,5 +204,11 @@ ppc_register_info (Ebl *ebl __attribute_
  76. return namelen;
  77. }
  78. -__typeof (ppc_register_info)
  79. - ppc64_register_info __attribute__ ((alias ("ppc_register_info")));
  80. +ssize_t
  81. +ppc64_register_info (Ebl *ebl,
  82. + int regno, char *name, size_t namelen,
  83. + const char **prefix, const char **setname,
  84. + int *bits, int *type)
  85. +{
  86. + return ppc_register_info(ebl, regno, name, namelen, prefix, setname, bits, type);
  87. +}
  88. --- a/backends/libebl_CPU.h
  89. +++ b/backends/libebl_CPU.h
  90. @@ -97,4 +97,10 @@ dwarf_is_pointer (int tag)
  91. case DW_TAG_reference_type: \
  92. case DW_TAG_rvalue_reference_type
  93. +#define auxv_info_alias(arch) \
  94. + int EBLHOOK_1(arch ## _, auxv_info) (GElf_Xword a_type, const char **name, const char **format) \
  95. + { \
  96. + return EBLHOOK(auxv_info)(a_type, name, format); \
  97. + }
  98. +
  99. #endif /* libebl_CPU.h */
  100. --- a/backends/ppc_auxv.c
  101. +++ b/backends/ppc_auxv.c
  102. @@ -51,5 +51,4 @@ EBLHOOK(auxv_info) (GElf_Xword a_type, c
  103. return 1;
  104. }
  105. -__typeof (ppc_auxv_info) ppc64_auxv_info
  106. - __attribute__ ((alias ("ppc_auxv_info")));
  107. +auxv_info_alias(ppc64)
  108. --- a/backends/ppc_cfi.c
  109. +++ b/backends/ppc_cfi.c
  110. @@ -72,6 +72,7 @@ ppc_abi_cfi (Ebl *ebl __attribute__ ((un
  111. return 0;
  112. }
  113. -__typeof (ppc_abi_cfi)
  114. - ppc64_abi_cfi
  115. - __attribute__ ((alias ("ppc_abi_cfi")));
  116. +int ppc64_abi_cfi(Ebl *ebl, Dwarf_CIE *abi_info)
  117. +{
  118. + return ppc_abi_cfi(ebl, abi_info);
  119. +}
  120. --- a/backends/ppc_initreg.c
  121. +++ b/backends/ppc_initreg.c
  122. @@ -68,9 +68,10 @@ ppc_dwarf_to_regno (Ebl *ebl __attribute
  123. abort ();
  124. }
  125. -__typeof (ppc_dwarf_to_regno)
  126. - ppc64_dwarf_to_regno
  127. - __attribute__ ((alias ("ppc_dwarf_to_regno")));
  128. +bool ppc64_dwarf_to_regno (Ebl *ebl, unsigned *regno)
  129. +{
  130. + return ppc_dwarf_to_regno(ebl, regno);
  131. +}
  132. bool
  133. ppc_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
  134. @@ -127,6 +128,7 @@ ppc_set_initial_registers_tid (pid_t tid
  135. #endif /* __powerpc__ */
  136. }
  137. -__typeof (ppc_set_initial_registers_tid)
  138. - ppc64_set_initial_registers_tid
  139. - __attribute__ ((alias ("ppc_set_initial_registers_tid")));
  140. +bool ppc64_set_initial_registers_tid(pid_t tid, ebl_tid_registers_t *setfunc, void *arg)
  141. +{
  142. + return ppc_set_initial_registers_tid(tid, setfunc, arg);
  143. +}
  144. --- a/backends/ppc_attrs.c
  145. +++ b/backends/ppc_attrs.c
  146. @@ -81,6 +81,9 @@ ppc_check_object_attribute (Ebl *ebl __a
  147. return false;
  148. }
  149. -__typeof (ppc_check_object_attribute)
  150. - ppc64_check_object_attribute
  151. - __attribute__ ((alias ("ppc_check_object_attribute")));
  152. +bool ppc64_check_object_attribute(Ebl *ebl,
  153. + const char *vendor, int tag, uint64_t value,
  154. + const char **tag_name, const char **value_name)
  155. +{
  156. + return ppc_check_object_attribute(ebl, vendor, tag, value, tag_name, value_name);
  157. +}
  158. --- a/libdwfl/libdwflP.h
  159. +++ b/libdwfl/libdwflP.h
  160. @@ -31,6 +31,7 @@
  161. #include <libdwfl.h>
  162. #include <libebl.h>
  163. +#include <libeu.h>
  164. #include <assert.h>
  165. #include <dirent.h>
  166. #include <errno.h>
  167. --- /dev/null
  168. +++ b/lib/stdio_ext.h
  169. @@ -0,0 +1,6 @@
  170. +#include <stdio.h>
  171. +#ifndef __APPLE__
  172. +#include_next <stdio_ext.h>
  173. +#else
  174. +#define __fsetlocking(...) 0
  175. +#endif
  176. --- a/libdw/libdwP.h
  177. +++ b/libdw/libdwP.h
  178. @@ -32,6 +32,7 @@
  179. #include <stdbool.h>
  180. #include <pthread.h>
  181. +#include <libeu.h>
  182. #include <libdw.h>
  183. #include <dwarf.h>
  184. #include "eu-search.h"
  185. --- a/config/libdebuginfod.pc.in
  186. +++ b/config/libdebuginfod.pc.in
  187. @@ -8,5 +8,5 @@ Description: elfutils library to query d
  188. Version: @VERSION@
  189. URL: http://elfutils.org/
  190. -Libs: -L${libdir} -ldebuginfod
  191. +Libs: -L${libdir} -ldebuginfod -lpthread
  192. Cflags: -I${includedir}
  193. --- a/config/libdw.pc.in
  194. +++ b/config/libdw.pc.in
  195. @@ -8,7 +8,7 @@ Description: elfutils library for DWARF
  196. Version: @VERSION@
  197. URL: http://elfutils.org/
  198. -Libs: -L${libdir} -ldw
  199. +Libs: -L${libdir} -ldw -lz -lelf -lz -ldl -lpthread
  200. Cflags: -I${includedir}
  201. # We need the exact matching elfutils libelf version since internal data
  202. --- a/config/libelf.pc.in
  203. +++ b/config/libelf.pc.in
  204. @@ -8,7 +8,7 @@ Description: elfutils libelf library to
  205. Version: @VERSION@
  206. URL: http://elfutils.org/
  207. -Libs: -L${libdir} -lelf
  208. +Libs: -L${libdir} -lelf -lz
  209. Cflags: -I${includedir}
  210. Requires.private: zlib @LIBZSTD@
  211. --- a/libebl/eblopenbackend.c
  212. +++ b/libebl/eblopenbackend.c
  213. @@ -202,8 +202,6 @@ static bool default_object_note (const c
  214. uint32_t descsz, const char *desc);
  215. static bool default_debugscn_p (const char *name);
  216. static bool default_copy_reloc_p (int reloc);
  217. -static bool default_none_reloc_p (int reloc);
  218. -static bool default_relative_reloc_p (int reloc);
  219. static bool default_check_special_symbol (Elf *elf,
  220. const GElf_Sym *sym,
  221. const char *name,
  222. @@ -255,8 +253,8 @@ fill_defaults (Ebl *result)
  223. result->object_note = default_object_note;
  224. result->debugscn_p = default_debugscn_p;
  225. result->copy_reloc_p = default_copy_reloc_p;
  226. - result->none_reloc_p = default_none_reloc_p;
  227. - result->relative_reloc_p = default_relative_reloc_p;
  228. + result->none_reloc_p = default_copy_reloc_p;
  229. + result->relative_reloc_p = default_copy_reloc_p;
  230. result->check_special_symbol = default_check_special_symbol;
  231. result->data_marker_symbol = default_data_marker_symbol;
  232. result->check_st_other_bits = default_check_st_other_bits;
  233. @@ -638,8 +636,6 @@ default_copy_reloc_p (int reloc __attrib
  234. {
  235. return false;
  236. }
  237. -strong_alias (default_copy_reloc_p, default_none_reloc_p)
  238. -strong_alias (default_copy_reloc_p, default_relative_reloc_p)
  239. static bool
  240. default_check_special_symbol (Elf *elf __attribute__ ((unused)),