100-portability.patch 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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. @@ -635,6 +639,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. @@ -59,14 +59,19 @@
  33. # define once(once_control, init_routine) init_routine()
  34. #endif /* USE_LOCKS */
  35. -#include <libintl.h>
  36. +#include <gettext.h>
  37. /* gettext helper macros. */
  38. #define N_(Str) Str
  39. #define _(Str) dgettext ("elfutils", Str)
  40. /* Compiler-specific definitions. */
  41. +#define __PRAGMA(str) _Pragma (#str)
  42. +#ifdef __APPLE__
  43. +#define strong_alias(name, aliasname) __PRAGMA(weak aliasname = name)
  44. +#else
  45. #define strong_alias(name, aliasname) \
  46. extern __typeof (name) aliasname __attribute__ ((alias (#name)));
  47. +#endif
  48. #ifdef __i386__
  49. # define internal_function __attribute__ ((regparm (3), stdcall))
  50. @@ -77,7 +82,7 @@
  51. #define internal_strong_alias(name, aliasname) \
  52. extern __typeof (name) aliasname __attribute__ ((alias (#name))) internal_function;
  53. -#ifdef HAVE_VISIBILITY
  54. +#if defined(HAVE_VISIBILITY) && !defined(__APPLE__)
  55. #define attribute_hidden \
  56. __attribute__ ((visibility ("hidden")))
  57. #else
  58. @@ -166,7 +171,7 @@ asm (".section predict_data, \"aw\"; .pr
  59. #endif
  60. /* Avoid PLT entries. */
  61. -#ifdef PIC
  62. +#if defined(PIC) && !defined(__APPLE__)
  63. # define INTUSE(name) _INTUSE(name)
  64. # define _INTUSE(name) __##name##_internal
  65. # define INTDEF(name) _INTDEF(name)
  66. --- a/backends/i386_auxv.c
  67. +++ b/backends/i386_auxv.c
  68. @@ -48,5 +48,4 @@ EBLHOOK(auxv_info) (GElf_Xword a_type, c
  69. return 1;
  70. }
  71. -__typeof (i386_auxv_info) x86_64_auxv_info
  72. - __attribute__ ((alias ("i386_auxv_info")));
  73. +auxv_info_alias(x86_64)
  74. --- a/backends/ppc_regs.c
  75. +++ b/backends/ppc_regs.c
  76. @@ -204,5 +204,11 @@ ppc_register_info (Ebl *ebl __attribute_
  77. return namelen;
  78. }
  79. -__typeof (ppc_register_info)
  80. - ppc64_register_info __attribute__ ((alias ("ppc_register_info")));
  81. +ssize_t
  82. +ppc64_register_info (Ebl *ebl,
  83. + int regno, char *name, size_t namelen,
  84. + const char **prefix, const char **setname,
  85. + int *bits, int *type)
  86. +{
  87. + return ppc_register_info(ebl, regno, name, namelen, prefix, setname, bits, type);
  88. +}
  89. --- a/backends/libebl_CPU.h
  90. +++ b/backends/libebl_CPU.h
  91. @@ -97,4 +97,10 @@ dwarf_is_pointer (int tag)
  92. case DW_TAG_reference_type: \
  93. case DW_TAG_rvalue_reference_type
  94. +#define auxv_info_alias(arch) \
  95. + int EBLHOOK_1(arch ## _, auxv_info) (GElf_Xword a_type, const char **name, const char **format) \
  96. + { \
  97. + return EBLHOOK(auxv_info)(a_type, name, format); \
  98. + }
  99. +
  100. #endif /* libebl_CPU.h */
  101. --- a/backends/ppc_auxv.c
  102. +++ b/backends/ppc_auxv.c
  103. @@ -51,5 +51,4 @@ EBLHOOK(auxv_info) (GElf_Xword a_type, c
  104. return 1;
  105. }
  106. -__typeof (ppc_auxv_info) ppc64_auxv_info
  107. - __attribute__ ((alias ("ppc_auxv_info")));
  108. +auxv_info_alias(ppc64)
  109. --- a/backends/ppc_cfi.c
  110. +++ b/backends/ppc_cfi.c
  111. @@ -72,6 +72,7 @@ ppc_abi_cfi (Ebl *ebl __attribute__ ((un
  112. return 0;
  113. }
  114. -__typeof (ppc_abi_cfi)
  115. - ppc64_abi_cfi
  116. - __attribute__ ((alias ("ppc_abi_cfi")));
  117. +int ppc64_abi_cfi(Ebl *ebl, Dwarf_CIE *abi_info)
  118. +{
  119. + return ppc_abi_cfi(ebl, abi_info);
  120. +}
  121. --- a/backends/ppc_initreg.c
  122. +++ b/backends/ppc_initreg.c
  123. @@ -68,9 +68,10 @@ ppc_dwarf_to_regno (Ebl *ebl __attribute
  124. abort ();
  125. }
  126. -__typeof (ppc_dwarf_to_regno)
  127. - ppc64_dwarf_to_regno
  128. - __attribute__ ((alias ("ppc_dwarf_to_regno")));
  129. +bool ppc64_dwarf_to_regno (Ebl *ebl, unsigned *regno)
  130. +{
  131. + return ppc_dwarf_to_regno(ebl, regno);
  132. +}
  133. bool
  134. ppc_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
  135. @@ -127,6 +128,7 @@ ppc_set_initial_registers_tid (pid_t tid
  136. #endif /* __powerpc__ */
  137. }
  138. -__typeof (ppc_set_initial_registers_tid)
  139. - ppc64_set_initial_registers_tid
  140. - __attribute__ ((alias ("ppc_set_initial_registers_tid")));
  141. +bool ppc64_set_initial_registers_tid(pid_t tid, ebl_tid_registers_t *setfunc, void *arg)
  142. +{
  143. + return ppc_set_initial_registers_tid(tid, setfunc, arg);
  144. +}
  145. --- a/backends/ppc_attrs.c
  146. +++ b/backends/ppc_attrs.c
  147. @@ -81,6 +81,9 @@ ppc_check_object_attribute (Ebl *ebl __a
  148. return false;
  149. }
  150. -__typeof (ppc_check_object_attribute)
  151. - ppc64_check_object_attribute
  152. - __attribute__ ((alias ("ppc_check_object_attribute")));
  153. +bool ppc64_check_object_attribute(Ebl *ebl,
  154. + const char *vendor, int tag, uint64_t value,
  155. + const char **tag_name, const char **value_name)
  156. +{
  157. + return ppc_check_object_attribute(ebl, vendor, tag, value, tag_name, value_name);
  158. +}
  159. --- a/libdwfl/libdwflP.h
  160. +++ b/libdwfl/libdwflP.h
  161. @@ -31,6 +31,7 @@
  162. #include <libdwfl.h>
  163. #include <libebl.h>
  164. +#include <libeu.h>
  165. #include <assert.h>
  166. #include <dirent.h>
  167. #include <errno.h>
  168. --- /dev/null
  169. +++ b/lib/stdio_ext.h
  170. @@ -0,0 +1,6 @@
  171. +#include <stdio.h>
  172. +#ifndef __APPLE__
  173. +#include_next <stdio_ext.h>
  174. +#else
  175. +#define __fsetlocking(...) 0
  176. +#endif
  177. --- a/libdw/libdwP.h
  178. +++ b/libdw/libdwP.h
  179. @@ -32,6 +32,7 @@
  180. #include <stdbool.h>
  181. #include <pthread.h>
  182. +#include <libeu.h>
  183. #include <libdw.h>
  184. #include <dwarf.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/lib/next_prime.c
  212. +++ b/lib/next_prime.c
  213. @@ -27,6 +27,7 @@
  214. the GNU Lesser General Public License along with this program. If
  215. not, see <http://www.gnu.org/licenses/>. */
  216. +#include <config.h>
  217. #include <stddef.h>
  218. --- a/libebl/eblopenbackend.c
  219. +++ b/libebl/eblopenbackend.c
  220. @@ -200,8 +200,6 @@ static bool default_object_note (const c
  221. uint32_t descsz, const char *desc);
  222. static bool default_debugscn_p (const char *name);
  223. static bool default_copy_reloc_p (int reloc);
  224. -static bool default_none_reloc_p (int reloc);
  225. -static bool default_relative_reloc_p (int reloc);
  226. static bool default_check_special_symbol (Elf *elf,
  227. const GElf_Sym *sym,
  228. const char *name,
  229. @@ -253,8 +251,8 @@ fill_defaults (Ebl *result)
  230. result->object_note = default_object_note;
  231. result->debugscn_p = default_debugscn_p;
  232. result->copy_reloc_p = default_copy_reloc_p;
  233. - result->none_reloc_p = default_none_reloc_p;
  234. - result->relative_reloc_p = default_relative_reloc_p;
  235. + result->none_reloc_p = default_copy_reloc_p;
  236. + result->relative_reloc_p = default_copy_reloc_p;
  237. result->check_special_symbol = default_check_special_symbol;
  238. result->data_marker_symbol = default_data_marker_symbol;
  239. result->check_st_other_bits = default_check_st_other_bits;
  240. @@ -636,8 +634,6 @@ default_copy_reloc_p (int reloc __attrib
  241. {
  242. return false;
  243. }
  244. -strong_alias (default_copy_reloc_p, default_none_reloc_p)
  245. -strong_alias (default_copy_reloc_p, default_relative_reloc_p)
  246. static bool
  247. default_check_special_symbol (Elf *elf __attribute__ ((unused)),
  248. --- a/src/srcfiles.cxx
  249. +++ b/src/srcfiles.cxx
  250. @@ -78,7 +78,9 @@ ARGP_PROGRAM_VERSION_HOOK_DEF = print_ve
  251. /* Bug report address. */
  252. ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT;
  253. +#ifdef HAVE_LIBARCHIVE
  254. constexpr size_t BUFFER_SIZE = 8192;
  255. +#endif
  256. /* Definitions of arguments for argp functions. */
  257. static const struct argp_option options[] =
  258. --- a/src/Makefile.am
  259. +++ b/src/Makefile.am
  260. @@ -92,6 +92,7 @@ strings_LDADD = $(libelf) $(libeu) $(arg
  261. ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS)
  262. unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
  263. stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(demanglelib)
  264. +EXTRA_stack_DEPENDENCIES = $(if $(findstring srcfiles,$(bin_PROGRAMS)),$(srcfiles_OBJECTS))
  265. elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
  266. elfclassify_LDADD = $(libelf) $(libdw) $(libeu) $(argp_LDADD)
  267. srcfiles_SOURCES = srcfiles.cxx