From 4f00495eabbda387487a7246238d27b6545302e0 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 11 Jun 2020 19:18:03 +0200 Subject: [PATCH 01/15] 0.180-1 - New upstream release. --- .gitignore | 1 + elfutils-0.179-debug-client-alt-link.patch | 60 ---------------------- elfutils.spec | 13 +++-- sources | 2 +- 4 files changed, 12 insertions(+), 64 deletions(-) delete mode 100644 elfutils-0.179-debug-client-alt-link.patch diff --git a/.gitignore b/.gitignore index 9f77f37..d198cb4 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ /elfutils-0.177.tar.bz2 /elfutils-0.178.tar.bz2 /elfutils-0.179.tar.bz2 +/elfutils-0.180.tar.bz2 diff --git a/elfutils-0.179-debug-client-alt-link.patch b/elfutils-0.179-debug-client-alt-link.patch deleted file mode 100644 index bb84954..0000000 --- a/elfutils-0.179-debug-client-alt-link.patch +++ /dev/null @@ -1,60 +0,0 @@ -From b1d2404cc6ca0d9ce786e229a87c24db49163cfe Mon Sep 17 00:00:00 2001 -From: Mark Wielaard -Date: Thu, 30 Apr 2020 23:57:26 +0200 -Subject: [PATCH] libdwfl: Handle debugaltlink in dwfl_standard_find_debuginfo. - -When we fall back to the debuginfod client then we need to do the -same trick we do for local lookups in dwfl_build_id_find_debuginfo. -If the debug file (dw) is already set, then we must be looking for -the altfile. But we cannot use the actual file/path name given as -hint. We'll have to lookup the alt file "build-id". Because the -debuginfod client only handles build-ids. - -Previously we would use the build-id of the main file which meant -the debuginfod client would give us another copy of the debug file, -which would then be set as its own altfile. This caused lots of -confusion... - -Signed-off-by: Mark Wielaard ---- - libdwfl/ChangeLog | 5 +++++ - libdwfl/find-debuginfo.c | 23 +++++++++++++++++++++-- - 2 files changed, 26 insertions(+), 2 deletions(-) - -diff --git a/libdwfl/find-debuginfo.c b/libdwfl/find-debuginfo.c -index 2dd11c48..4cfd0b8b 100644 ---- a/libdwfl/find-debuginfo.c -+++ b/libdwfl/find-debuginfo.c -@@ -398,8 +398,27 @@ dwfl_standard_find_debuginfo (Dwfl_Module *mod, - free (canon); - } - -- if (fd < 0 && bits_len > 0) -- fd = __libdwfl_debuginfod_find_debuginfo (mod->dwfl, bits, bits_len); -+ /* Still nothing? Try if we can use the debuginfod client. -+ But note that we might be looking for the alt file. -+ We use the same trick as dwfl_build_id_find_debuginfo. -+ If the debug file (dw) is already set, then we must be -+ looking for the altfile. But we cannot use the actual -+ file/path name given as hint. We'll have to lookup the -+ alt file "build-id". Because the debuginfod client only -+ handles build-ids. */ -+ if (fd < 0) -+ { -+ if (mod->dw != NULL) -+ { -+ const char *altname; -+ bits_len = INTUSE(dwelf_dwarf_gnu_debugaltlink) (mod->dw, &altname, -+ (const void **) -+ &bits); -+ } -+ -+ if (bits_len > 0) -+ fd = __libdwfl_debuginfod_find_debuginfo (mod->dwfl, bits, bits_len); -+ } - - return fd; - } --- -2.18.2 - diff --git a/elfutils.spec b/elfutils.spec index aed7cf2..c146d11 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -1,5 +1,5 @@ Name: elfutils -Version: 0.179 +Version: 0.180 %global baserelease 2 Release: %{baserelease}%{?dist} URL: http://elfutils.org/ @@ -55,7 +55,6 @@ BuildRequires: curl %endif # Patches -Patch1: elfutils-0.179-debug-client-alt-link.patch %description Elfutils is a collection of utilities, including stack (to show @@ -247,7 +246,6 @@ such servers to download those files on demand. %setup -q # Apply patches -%patch1 -p1 -b .debug-client-alt # In case the above patches added any new test scripts, make sure they # are executable. @@ -425,6 +423,15 @@ exit 0 %systemd_postun_with_restart debuginfod.service %changelog +* Thu Jun 11 2020 Mark Wielaard - 0.180-1 +- New upstream release. + elflint: Allow SHF_EXCLUDE as generic section flag when --gnu is given. + libdw, readelf: Handle GCC LTO .gnu.debuglto_ prefix. + libdw: Use correct CU to resolve file names in dwarf_decl_file. + libdwfl: Handle debugaltlink in dwfl_standard_find_debuginfo. + size: Also obey radix printing for bsd format. + nm: Explicitly print weak 'V' or 'T' and common 'C' symbols. + * Thu Apr 30 2020 Mark Wielaard - 0.179-2 - Add elfutils-0.179-debug-client-alt-link.patch diff --git a/sources b/sources index 43f3cfa..186b1cd 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (elfutils-0.179.tar.bz2) = ff2d96ad1db08e3a2ddaa60bd5a05e9b61ffa71d646f889cebb6bef51322e874930809c6dd0a257ced8c6e8de4b59ecf13ca6741dc68f9400293208278a0c052 +SHA512 (elfutils-0.180.tar.bz2) = 62e96035ccfe8928baca2285decbe8b8703a2daa956df81ece18fecf643272fb68955806b3e807a514141a7a9bf44520bf09461672aa580bd6807485fb604d25 From 969b34d0b461854cac3e73fd55ede36564789166 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Wed, 1 Jul 2020 12:22:05 -0600 Subject: [PATCH 02/15] Disable LTO --- elfutils.spec | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/elfutils.spec b/elfutils.spec index c146d11..2831705 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -1,6 +1,6 @@ Name: elfutils Version: 0.180 -%global baserelease 2 +%global baserelease 3 Release: %{baserelease}%{?dist} URL: http://elfutils.org/ %global source_url ftp://sourceware.org/pub/elfutils/%{version}/ @@ -252,6 +252,14 @@ such servers to download those files on demand. find . -name \*.sh ! -perm -0100 -print | xargs chmod +x %build +# This package uses top level ASM constructs which are incompatible with LTO. +# Top level ASMs are often used to implement symbol versioning. gcc-10 +# introduces a new mechanism for symbol versioning which works with LTO. +# Converting packages to use that mechanism instead of toplevel ASMs is +# recommended. +# Disable LTO +%define _lto_cflags %{nil} + # Remove -Wall from default flags. The makefiles enable enough warnings # themselves, and they use -Werror. Appending -Wall defeats the cases where # the makefiles disable some specific warnings for specific code. @@ -423,6 +431,9 @@ exit 0 %systemd_postun_with_restart debuginfod.service %changelog +* Wed Jul 1 2020 Jeff Law - 0.180-2 +- Disable LTO + * Thu Jun 11 2020 Mark Wielaard - 0.180-1 - New upstream release. elflint: Allow SHF_EXCLUDE as generic section flag when --gnu is given. From a63a2aaaa20ed97bcd31ef3d574a3a99d33d3f80 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 3 Jul 2020 23:46:19 +0200 Subject: [PATCH 03/15] 0.180-3 - Add elfutils-0.180-mhd-result.patch --- elfutils-0.180-mhd-result.patch | 67 +++++++++++++++++++++++++++++++++ elfutils.spec | 5 +++ 2 files changed, 72 insertions(+) create mode 100644 elfutils-0.180-mhd-result.patch diff --git a/elfutils-0.180-mhd-result.patch b/elfutils-0.180-mhd-result.patch new file mode 100644 index 0000000..3a67a93 --- /dev/null +++ b/elfutils-0.180-mhd-result.patch @@ -0,0 +1,67 @@ +commit acb453851c9e6c46531b70fda7396885c0e7e1db +Author: Frank Ch. Eigler +Date: Thu Jul 2 14:52:48 2020 +0000 + + PR26195: adapt debuginfod to API change in libmicrohttpd-0.9.71 + + To make our code build with -Werror as well as against older libmicrohttpd, + we must conditionalize the data type (int vs. enum) returned by callbacks + and some mhd functions. + + Signed-off-by: Frank Ch. Eigler + +diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx +index 76f1fa52..56210302 100644 +--- a/debuginfod/debuginfod.cxx ++++ b/debuginfod/debuginfod.cxx +@@ -92,6 +92,14 @@ using namespace std; + #include + + #include ++ ++#if MHD_VERSION >= 0x00097002 ++// libmicrohttpd 0.9.71 broke API ++#define MHD_RESULT enum MHD_Result ++#else ++#define MHD_RESULT int ++#endif ++ + #include + #include + #include +@@ -519,12 +527,12 @@ struct reportable_exception + + void report(ostream& o) const; // defined under obatched() class below + +- int mhd_send_response(MHD_Connection* c) const { ++ MHD_RESULT mhd_send_response(MHD_Connection* c) const { + MHD_Response* r = MHD_create_response_from_buffer (message.size(), + (void*) message.c_str(), + MHD_RESPMEM_MUST_COPY); + MHD_add_response_header (r, "Content-Type", "text/plain"); +- int rc = MHD_queue_response (c, code, r); ++ MHD_RESULT rc = MHD_queue_response (c, code, r); + MHD_destroy_response (r); + return rc; + } +@@ -1723,7 +1731,7 @@ handle_metrics (off_t* size) + + + /* libmicrohttpd callback */ +-static int ++static MHD_RESULT + handler_cb (void * /*cls*/, + struct MHD_Connection *connection, + const char *url, +@@ -1736,7 +1744,11 @@ handler_cb (void * /*cls*/, + struct MHD_Response *r = NULL; + string url_copy = url; + ++#if MHD_VERSION >= 0x00097002 ++ enum MHD_Result rc; ++#else + int rc = MHD_NO; // mhd ++#endif + int http_code = 500; + off_t http_size = -1; + struct timeval tv_start, tv_end; diff --git a/elfutils.spec b/elfutils.spec index 2831705..ad078f2 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -55,6 +55,7 @@ BuildRequires: curl %endif # Patches +Patch1: elfutils-0.180-mhd-result.patch %description Elfutils is a collection of utilities, including stack (to show @@ -246,6 +247,7 @@ such servers to download those files on demand. %setup -q # Apply patches +%patch1 -p1 -b .mhd_result # In case the above patches added any new test scripts, make sure they # are executable. @@ -431,6 +433,9 @@ exit 0 %systemd_postun_with_restart debuginfod.service %changelog +* Fri Jul 3 2020 Mark Wielaard - 0.180-3 +- Add elfutils-0.180-mhd-result.patch + * Wed Jul 1 2020 Jeff Law - 0.180-2 - Disable LTO From 199b97a9a916f8762d894f37b49fadbe52c18048 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Mon, 13 Jul 2020 19:22:41 +0000 Subject: [PATCH 04/15] Use make macros https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro --- elfutils.spec | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/elfutils.spec b/elfutils.spec index ad078f2..f7cf13b 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -1,6 +1,6 @@ Name: elfutils Version: 0.180 -%global baserelease 3 +%global baserelease 4 Release: %{baserelease}%{?dist} URL: http://elfutils.org/ %global source_url ftp://sourceware.org/pub/elfutils/%{version}/ @@ -274,11 +274,11 @@ RPM_OPT_FLAGS="${RPM_OPT_FLAGS} -Wformat" trap 'cat config.log' EXIT %configure CFLAGS="$RPM_OPT_FLAGS -fexceptions" trap '' EXIT -make -s %{?_smp_mflags} +%make_build -s %install rm -rf ${RPM_BUILD_ROOT} -make -s install DESTDIR=${RPM_BUILD_ROOT} +%make_install -s chmod +x ${RPM_BUILD_ROOT}%{_prefix}/%{_lib}/lib*.so* @@ -297,7 +297,7 @@ touch ${RPM_BUILD_ROOT}%{_localstatedir}/cache/debuginfod/debuginfod.sqlite # Record some build root versions in build.log uname -r; rpm -q binutils gcc glibc -make -s %{?_smp_mflags} check || (cat tests/test-suite.log; false) +%make_build -s check || (cat tests/test-suite.log; false) # Only the latest Fedora and EPEL have these scriptlets, # older Fedora and plain RHEL don't. @@ -433,6 +433,10 @@ exit 0 %systemd_postun_with_restart debuginfod.service %changelog +* Mon Jul 13 2020 Tom Stellard - 0.180-4 +- Use make macros +- https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro + * Fri Jul 3 2020 Mark Wielaard - 0.180-3 - Add elfutils-0.180-mhd-result.patch From 9f5a314b5026c6da5b8fbb4a29a9df864977da25 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sat, 18 Jul 2020 01:41:00 +0200 Subject: [PATCH 05/15] Properly escape %%check in spec comment. --- elfutils.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elfutils.spec b/elfutils.spec index f7cf13b..6d0734e 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -40,7 +40,7 @@ BuildRequires: pkgconfig(libarchive) >= 3.1.2 # For tests need to bunzip2 test files. BuildRequires: bzip2 -# For the run-debuginfod-find.sh test case in %check for /usr/sbin/ss +# For the run-debuginfod-find.sh test case in %%check for /usr/sbin/ss BuildRequires: iproute BuildRequires: bsdtar BuildRequires: curl From aff444d022537cb2570f5c617aecb28d3dbefe81 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 23 Jul 2020 01:17:05 +0200 Subject: [PATCH 06/15] Remove duplicate listing of sysconfig/debuginfod (config) file. --- elfutils.spec | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/elfutils.spec b/elfutils.spec index 6d0734e..ce301d0 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -413,7 +413,6 @@ fi %{_bindir}/debuginfod %config(noreplace) %verify(not md5 size mtime) %{_sysconfdir}/sysconfig/debuginfod %{_unitdir}/debuginfod.service -%{_sysconfdir}/sysconfig/debuginfod %{_mandir}/man8/debuginfod.8* %dir %attr(0700,debuginfod,debuginfod) %{_localstatedir}/cache/debuginfod @@ -433,6 +432,9 @@ exit 0 %systemd_postun_with_restart debuginfod.service %changelog +* Wed Jul 22 2020 Mark Wielaard - 0.180-5 +- Remove duplicate listing of sysconfig/debuginfod (config) file. + * Mon Jul 13 2020 Tom Stellard - 0.180-4 - Use make macros - https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro From 510fcad8b0159f71e83037e1d85a6efa90fdf8f1 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 26 Aug 2020 00:11:50 +0200 Subject: [PATCH 07/15] 0.180-7 - Add elfutils-0.180-shf-compressed.patch --- elfutils-0.180-shf-compressed.patch | 68 +++++++++++++++++++++++++++++ elfutils.spec | 7 ++- 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 elfutils-0.180-shf-compressed.patch diff --git a/elfutils-0.180-shf-compressed.patch b/elfutils-0.180-shf-compressed.patch new file mode 100644 index 0000000..1a91d98 --- /dev/null +++ b/elfutils-0.180-shf-compressed.patch @@ -0,0 +1,68 @@ +commit 55c5c9a568ed707bcea1388bf3a525212d8cf4b8 +Author: Mark Wielaard +Date: Wed Aug 19 23:41:24 2020 +0200 + + libelf: Fixup SHF_COMPRESSED sh_addralign in elf_update if necessary. + + In elf_getdata.c we have the following to compensate for possibly + bad sh_addralign values of compressed sections: + + /* Compressed data has a header, but then compressed data. + Make sure to set the alignment of the header explicitly, + don't trust the file alignment for the section, it is + often wrong. */ + if ((flags & SHF_COMPRESSED) != 0) + { + entsize = 1; + align = __libelf_type_align (elf->class, ELF_T_CHDR); + } + + Which makes sure the d_data alignment is correct for the Chdr struct + at the start of the compressed section. + + But this means that if a user just reads such a compressed section + without changing it, and then tries to write it out again using + elf_update they get an error message about d_align and sh_addralign + being out of sync. + + We already correct obviously incorrect sh_entsize fields. + Do the same for the sh_addralign field of a SHF_COMPRESSED section. + + Signed-off-by: Mark Wielaard + +diff --git a/libelf/ChangeLog b/libelf/ChangeLog +index 8f6d2d2d..77044c1c 100644 +--- a/libelf/ChangeLog ++++ b/libelf/ChangeLog +@@ -1,3 +1,8 @@ ++2020-08-19 Mark Wielaard ++ ++ * elf32_updatenull.c (updatenull_wrlock): Fixup the sh_addralign ++ of an SHF_COMPRESSED section if necessary. ++ + 2020-06-04 Mark Wielaard + + * elf.h: Update from glibc. +diff --git a/libelf/elf32_updatenull.c b/libelf/elf32_updatenull.c +index 5f3cdbf6..d0d4d1eb 100644 +--- a/libelf/elf32_updatenull.c ++++ b/libelf/elf32_updatenull.c +@@ -267,6 +267,18 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int *change_bop, size_t shnum) + update_if_changed (shdr->sh_entsize, sh_entsize, + scn->shdr_flags); + ++ /* Likewise for the alignment of a compressed section. ++ For a SHF_COMPRESSED section set the correct ++ sh_addralign value, which must match the d_align of ++ the data (see __libelf_set_rawdata in elf_getdata.c). */ ++ if ((shdr->sh_flags & SHF_COMPRESSED) != 0) ++ { ++ sh_align = __libelf_type_align (ELFW(ELFCLASS,LIBELFBITS), ++ ELF_T_CHDR); ++ update_if_changed (shdr->sh_addralign, sh_align, ++ scn->shdr_flags); ++ } ++ + if (scn->data_read == 0 + && __libelf_set_rawdata_wrlock (scn) != 0) + /* Something went wrong. The error value is already set. */ diff --git a/elfutils.spec b/elfutils.spec index ce301d0..1a9aa78 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -1,6 +1,6 @@ Name: elfutils Version: 0.180 -%global baserelease 4 +%global baserelease 7 Release: %{baserelease}%{?dist} URL: http://elfutils.org/ %global source_url ftp://sourceware.org/pub/elfutils/%{version}/ @@ -56,6 +56,7 @@ BuildRequires: curl # Patches Patch1: elfutils-0.180-mhd-result.patch +Patch2: elfutils-0.180-shf-compressed.patch %description Elfutils is a collection of utilities, including stack (to show @@ -248,6 +249,7 @@ such servers to download those files on demand. # Apply patches %patch1 -p1 -b .mhd_result +%patch2 -p1 -b .shf_compressed # In case the above patches added any new test scripts, make sure they # are executable. @@ -432,6 +434,9 @@ exit 0 %systemd_postun_with_restart debuginfod.service %changelog +* Tue Aug 25 2020 Mark Wielaard - 0.180-7 +- Add elfutils-0.180-shf-compressed.patch + * Wed Jul 22 2020 Mark Wielaard - 0.180-5 - Remove duplicate listing of sysconfig/debuginfod (config) file. From 3940f0f0ffd2843b2ca80ddbfeecd8cb7465778c Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 8 Sep 2020 15:12:34 +0200 Subject: [PATCH 08/15] 0.181-1 - Upgrade to upstream 0.181 --- .gitignore | 1 + elfutils-0.180-mhd-result.patch | 67 ---------------------------- elfutils-0.180-shf-compressed.patch | 68 ----------------------------- elfutils.spec | 22 +++++++--- sources | 2 +- 5 files changed, 18 insertions(+), 142 deletions(-) delete mode 100644 elfutils-0.180-mhd-result.patch delete mode 100644 elfutils-0.180-shf-compressed.patch diff --git a/.gitignore b/.gitignore index d198cb4..f7d1f6e 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ /elfutils-0.178.tar.bz2 /elfutils-0.179.tar.bz2 /elfutils-0.180.tar.bz2 +/elfutils-0.181.tar.bz2 diff --git a/elfutils-0.180-mhd-result.patch b/elfutils-0.180-mhd-result.patch deleted file mode 100644 index 3a67a93..0000000 --- a/elfutils-0.180-mhd-result.patch +++ /dev/null @@ -1,67 +0,0 @@ -commit acb453851c9e6c46531b70fda7396885c0e7e1db -Author: Frank Ch. Eigler -Date: Thu Jul 2 14:52:48 2020 +0000 - - PR26195: adapt debuginfod to API change in libmicrohttpd-0.9.71 - - To make our code build with -Werror as well as against older libmicrohttpd, - we must conditionalize the data type (int vs. enum) returned by callbacks - and some mhd functions. - - Signed-off-by: Frank Ch. Eigler - -diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx -index 76f1fa52..56210302 100644 ---- a/debuginfod/debuginfod.cxx -+++ b/debuginfod/debuginfod.cxx -@@ -92,6 +92,14 @@ using namespace std; - #include - - #include -+ -+#if MHD_VERSION >= 0x00097002 -+// libmicrohttpd 0.9.71 broke API -+#define MHD_RESULT enum MHD_Result -+#else -+#define MHD_RESULT int -+#endif -+ - #include - #include - #include -@@ -519,12 +527,12 @@ struct reportable_exception - - void report(ostream& o) const; // defined under obatched() class below - -- int mhd_send_response(MHD_Connection* c) const { -+ MHD_RESULT mhd_send_response(MHD_Connection* c) const { - MHD_Response* r = MHD_create_response_from_buffer (message.size(), - (void*) message.c_str(), - MHD_RESPMEM_MUST_COPY); - MHD_add_response_header (r, "Content-Type", "text/plain"); -- int rc = MHD_queue_response (c, code, r); -+ MHD_RESULT rc = MHD_queue_response (c, code, r); - MHD_destroy_response (r); - return rc; - } -@@ -1723,7 +1731,7 @@ handle_metrics (off_t* size) - - - /* libmicrohttpd callback */ --static int -+static MHD_RESULT - handler_cb (void * /*cls*/, - struct MHD_Connection *connection, - const char *url, -@@ -1736,7 +1744,11 @@ handler_cb (void * /*cls*/, - struct MHD_Response *r = NULL; - string url_copy = url; - -+#if MHD_VERSION >= 0x00097002 -+ enum MHD_Result rc; -+#else - int rc = MHD_NO; // mhd -+#endif - int http_code = 500; - off_t http_size = -1; - struct timeval tv_start, tv_end; diff --git a/elfutils-0.180-shf-compressed.patch b/elfutils-0.180-shf-compressed.patch deleted file mode 100644 index 1a91d98..0000000 --- a/elfutils-0.180-shf-compressed.patch +++ /dev/null @@ -1,68 +0,0 @@ -commit 55c5c9a568ed707bcea1388bf3a525212d8cf4b8 -Author: Mark Wielaard -Date: Wed Aug 19 23:41:24 2020 +0200 - - libelf: Fixup SHF_COMPRESSED sh_addralign in elf_update if necessary. - - In elf_getdata.c we have the following to compensate for possibly - bad sh_addralign values of compressed sections: - - /* Compressed data has a header, but then compressed data. - Make sure to set the alignment of the header explicitly, - don't trust the file alignment for the section, it is - often wrong. */ - if ((flags & SHF_COMPRESSED) != 0) - { - entsize = 1; - align = __libelf_type_align (elf->class, ELF_T_CHDR); - } - - Which makes sure the d_data alignment is correct for the Chdr struct - at the start of the compressed section. - - But this means that if a user just reads such a compressed section - without changing it, and then tries to write it out again using - elf_update they get an error message about d_align and sh_addralign - being out of sync. - - We already correct obviously incorrect sh_entsize fields. - Do the same for the sh_addralign field of a SHF_COMPRESSED section. - - Signed-off-by: Mark Wielaard - -diff --git a/libelf/ChangeLog b/libelf/ChangeLog -index 8f6d2d2d..77044c1c 100644 ---- a/libelf/ChangeLog -+++ b/libelf/ChangeLog -@@ -1,3 +1,8 @@ -+2020-08-19 Mark Wielaard -+ -+ * elf32_updatenull.c (updatenull_wrlock): Fixup the sh_addralign -+ of an SHF_COMPRESSED section if necessary. -+ - 2020-06-04 Mark Wielaard - - * elf.h: Update from glibc. -diff --git a/libelf/elf32_updatenull.c b/libelf/elf32_updatenull.c -index 5f3cdbf6..d0d4d1eb 100644 ---- a/libelf/elf32_updatenull.c -+++ b/libelf/elf32_updatenull.c -@@ -267,6 +267,18 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int *change_bop, size_t shnum) - update_if_changed (shdr->sh_entsize, sh_entsize, - scn->shdr_flags); - -+ /* Likewise for the alignment of a compressed section. -+ For a SHF_COMPRESSED section set the correct -+ sh_addralign value, which must match the d_align of -+ the data (see __libelf_set_rawdata in elf_getdata.c). */ -+ if ((shdr->sh_flags & SHF_COMPRESSED) != 0) -+ { -+ sh_align = __libelf_type_align (ELFW(ELFCLASS,LIBELFBITS), -+ ELF_T_CHDR); -+ update_if_changed (shdr->sh_addralign, sh_align, -+ scn->shdr_flags); -+ } -+ - if (scn->data_read == 0 - && __libelf_set_rawdata_wrlock (scn) != 0) - /* Something went wrong. The error value is already set. */ diff --git a/elfutils.spec b/elfutils.spec index 1a9aa78..f5f3d40 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -1,6 +1,6 @@ Name: elfutils -Version: 0.180 -%global baserelease 7 +Version: 0.181 +%global baserelease 1 Release: %{baserelease}%{?dist} URL: http://elfutils.org/ %global source_url ftp://sourceware.org/pub/elfutils/%{version}/ @@ -55,8 +55,6 @@ BuildRequires: curl %endif # Patches -Patch1: elfutils-0.180-mhd-result.patch -Patch2: elfutils-0.180-shf-compressed.patch %description Elfutils is a collection of utilities, including stack (to show @@ -248,8 +246,6 @@ such servers to download those files on demand. %setup -q # Apply patches -%patch1 -p1 -b .mhd_result -%patch2 -p1 -b .shf_compressed # In case the above patches added any new test scripts, make sure they # are executable. @@ -434,6 +430,20 @@ exit 0 %systemd_postun_with_restart debuginfod.service %changelog +* Tue Sep 8 2020 Mark Wielaard - 0.181-1 +- Upgrade to upstream 0.181 + - libelf: elf_update now compensates (fixes up) a bad sh_addralign + for SHF_COMPRESSED sections. + - libdebuginfod: configure now takes --enable-libdebuginfod=dummy or + --disable-libdebuginfod for bootstrapping. + DEBUGINFOD_URLS now accepts "scheme-free" urls + (guessing at what the user meant, either http:// or file://) + - readelf, elflint: Handle aarch64 bti, pac bits in dynamic table and + gnu property notes. + - libdw, readelf: Recognize DW_CFA_AARCH64_negate_ra_state. Allows + unwinding on arm64 for code that is compiled for PAC + (Pointer Authentication Code) as long as it isn't enabled. + * Tue Aug 25 2020 Mark Wielaard - 0.180-7 - Add elfutils-0.180-shf-compressed.patch diff --git a/sources b/sources index 186b1cd..b0e26f0 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (elfutils-0.180.tar.bz2) = 62e96035ccfe8928baca2285decbe8b8703a2daa956df81ece18fecf643272fb68955806b3e807a514141a7a9bf44520bf09461672aa580bd6807485fb604d25 +SHA512 (elfutils-0.181.tar.bz2) = d565541d5817f409dc89ebb1ee593366f69c371a1531308eeb67ff934b14a0fab0c9009fd7c23240efbaa1b4e04edac5c425e47d80e3e66ba03dcaf000afea36 From c84a61da8fe6356a6b9665a22b9005ceb97bb4c8 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 18 Sep 2020 14:42:45 +0200 Subject: [PATCH 09/15] 0.181-2 - Add ZSTD support elfutils-0.181-zstd.patch. --- elfutils-0.181-zstd.patch | 348 ++++++++++++++++++++++++++++++++++++++ elfutils.spec | 14 +- 2 files changed, 361 insertions(+), 1 deletion(-) create mode 100644 elfutils-0.181-zstd.patch diff --git a/elfutils-0.181-zstd.patch b/elfutils-0.181-zstd.patch new file mode 100644 index 0000000..1b68989 --- /dev/null +++ b/elfutils-0.181-zstd.patch @@ -0,0 +1,348 @@ +commit c5b0a640f0f7d2a195b822bcd88bb379476dbb97 +Author: Mark Wielaard +Date: Fri Sep 18 12:49:29 2020 +0200 + + zstd support + +diff --git a/config/elfutils.spec.in b/config/elfutils.spec.in +index 95f63f5a..37af1b07 100644 +--- a/config/elfutils.spec.in ++++ b/config/elfutils.spec.in +@@ -24,6 +24,7 @@ BuildRequires: flex + BuildRequires: zlib-devel + BuildRequires: bzip2-devel + BuildRequires: xz-devel ++BuildRequires: libzstd-devel + + # For debuginfod + BuildRequires: pkgconfig(libmicrohttpd) >= 0.9.33 +@@ -33,6 +34,7 @@ BuildRequires: pkgconfig(libarchive) >= 3.1.2 + + # For tests need to bunzip2 test files. + BuildRequires: bzip2 ++BuildRequires: zstd + # For the run-debuginfod-find.sh test case in %check for /usr/sbin/ss + BuildRequires: iproute + BuildRequires: bsdtar +diff --git a/config/libdw.pc.in b/config/libdw.pc.in +index 3fc283db..2e83a432 100644 +--- a/config/libdw.pc.in ++++ b/config/libdw.pc.in +@@ -17,6 +17,6 @@ Requires: libelf = @VERSION@ + + # We support various compressed ELF images, but don't export any of the + # data structures or functions. zlib (gz) is always required, bzip2 (bz2) +-# and lzma (xz) are optional. But bzip2 doesn't have a pkg-config file. +-Requires.private: zlib @LIBLZMA@ ++# lzma (xz) and zstd () are optional. But bzip2 doesn't have a pkg-config file. ++Requires.private: zlib @LIBLZMA@ @LIBZSTD@ + Libs.private: @BZ2_LIB@ +diff --git a/configure.ac b/configure.ac +index bf833872..1b794df3 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -397,8 +397,8 @@ eu_ZIPLIB(zlib,ZLIB,z,gzdirect,gzip) + AS_IF([test "x$with_zlib" = xno], [AC_MSG_ERROR([zlib not found but is required])]) + LIBS="$save_LIBS" + +-dnl Test for bzlib and xz/lzma, gives BZLIB/LZMALIB .am +-dnl conditional and config.h USE_BZLIB/USE_LZMALIB #define. ++dnl Test for bzlib and xz/lzma/zstd, gives BZLIB/LZMALIB/ZSTD .am ++dnl conditional and config.h USE_BZLIB/USE_LZMALIB/USE_ZSTD #define. + save_LIBS="$LIBS" + LIBS= + eu_ZIPLIB(bzlib,BZLIB,bz2,BZ2_bzdopen,bzip2) +@@ -408,6 +408,9 @@ AC_SUBST([BZ2_LIB]) + eu_ZIPLIB(lzma,LZMA,lzma,lzma_auto_decoder,[LZMA (xz)]) + AS_IF([test "x$with_lzma" = xyes], [LIBLZMA="liblzma"], [LIBLZMA=""]) + AC_SUBST([LIBLZMA]) ++eu_ZIPLIB(zstd,ZSTD,zstd,ZSTD_decompress,[ZSTD (zst)]) ++AS_IF([test "x$with_zstd" = xyes], [LIBZSTD="libzstd"], [LIBLZSTD=""]) ++AC_SUBST([LIBZSTD]) + zip_LIBS="$LIBS" + LIBS="$save_LIBS" + AC_SUBST([zip_LIBS]) +@@ -677,6 +680,10 @@ if test "$HAVE_BUNZIP2" = "no"; then + AC_MSG_WARN([No bunzip2, needed to run make check]) + fi + ++# For tests that need to use zstd compression ++AC_CHECK_PROG(HAVE_ZSTD, zstd, yes, no) ++AM_CONDITIONAL([HAVE_ZSTD],[test "x$HAVE_ZSTD" = "xyes"]) ++ + # Look for libcurl for libdebuginfod minimum version as per rhel7. + AC_ARG_ENABLE([libdebuginfod],AC_HELP_STRING([--enable-libdebuginfod], [Build debuginfod client library (can be =dummy)])) + AS_IF([test "x$enable_libdebuginfod" != "xno"], [ +@@ -742,6 +749,7 @@ AC_MSG_NOTICE([ + gzip support : ${with_zlib} + bzip2 support : ${with_bzlib} + lzma/xz support : ${with_lzma} ++ zstd support : ${with_zstd} + libstdc++ demangle support : ${enable_demangler} + File textrel check : ${enable_textrelcheck} + Symbol versioning : ${enable_symbol_versioning} +@@ -759,6 +767,7 @@ AC_MSG_NOTICE([ + + EXTRA TEST FEATURES (used with make check) + have bunzip2 installed (required) : ${HAVE_BUNZIP2} ++ have zstd installed : ${HAVE_ZSTD} + debug branch prediction : ${use_debugpred} + gprof support : ${use_gprof} + gcov support : ${use_gcov} +diff --git a/libdwfl/Makefile.am b/libdwfl/Makefile.am +index 1de05492..a0013e41 100644 +--- a/libdwfl/Makefile.am ++++ b/libdwfl/Makefile.am +@@ -78,6 +78,9 @@ endif + if LZMA + libdwfl_a_SOURCES += lzma.c + endif ++if ZSTD ++libdwfl_a_SOURCES += zstd.c ++endif + if LIBDEBUGINFOD + libdwfl_a_SOURCES += debuginfod-client.c + endif +diff --git a/libdwfl/gzip.c b/libdwfl/gzip.c +index e9988cc2..ba8ecfba 100644 +--- a/libdwfl/gzip.c ++++ b/libdwfl/gzip.c +@@ -48,6 +48,12 @@ + # define inflateInit(z) lzma_auto_decoder (z, 1 << 30, 0) + # define do_inflate(z) lzma_code (z, LZMA_RUN) + # define inflateEnd(z) lzma_end (z) ++#elif defined ZSTD ++# define USE_INFLATE 1 ++# include ++# define unzip __libdw_unzstd ++# define DWFL_E_ZLIB DWFL_E_ZSTD ++# define MAGIC "\x28\xb5\x2f\xfd" + #elif defined BZLIB + # define USE_INFLATE 1 + # include +@@ -119,6 +125,7 @@ fail (struct unzip_state *state, Dwfl_Error failure) + return failure; + } + ++#ifndef ZSTD + static inline Dwfl_Error + zlib_fail (struct unzip_state *state, int result) + { +@@ -132,6 +139,7 @@ zlib_fail (struct unzip_state *state, int result) + return fail (state, DWFL_E_ZLIB); + } + } ++#endif + + #if !USE_INFLATE + static Dwfl_Error +@@ -197,7 +205,7 @@ unzip (int fd, off_t start_offset, + + ssize_t n = pread_retry (fd, state.input_buffer, READ_SIZE, start_offset); + if (unlikely (n < 0)) +- return zlib_fail (&state, Z (ERRNO)); ++ return fail (&state, DWFL_E_ERRNO); + + state.input_pos = n; + mapped = state.input_buffer; +@@ -223,7 +231,74 @@ unzip (int fd, off_t start_offset, + /* Not a compressed file. */ + return DWFL_E_BADELF; + +-#if USE_INFLATE ++#ifdef ZSTD ++ /* special case for libzstd since it is slightly different from the ++ API provided by bzlib and liblzma. */ ++ ++ void *next_in = mapped; ++ size_t avail_in = state.mapped_size; ++ void *next_out = NULL; ++ size_t avail_out = 0; ++ size_t total_out = 0; ++ ++ size_t result; ++ ZSTD_DCtx *dctx = ZSTD_createDCtx(); ++ if (dctx == NULL) ++ return fail (&state, DWFL_E_NOMEM); ++ ++ do ++ { ++ if (avail_in == 0 && state.input_buffer != NULL) ++ { ++ ssize_t n = pread_retry (fd, state.input_buffer, READ_SIZE, ++ start_offset + state.input_pos); ++ if (unlikely (n < 0)) ++ { ++ ZSTD_freeDCtx (dctx); ++ return fail (&state, DWFL_E_ERRNO); ++ } ++ next_in = state.input_buffer; ++ avail_in = n; ++ state.input_pos += n; ++ } ++ if (avail_out == 0) ++ { ++ ptrdiff_t pos = (void *) next_out - state.buffer; ++ if (!bigger_buffer (&state, avail_in)) ++ { ++ ZSTD_freeDCtx (dctx); ++ return fail (&state, DWFL_E_NOMEM); ++ } ++ next_out = state.buffer + pos; ++ avail_out = state.size - pos; ++ } ++ ++ ZSTD_inBuffer input = { next_in, avail_in, 0 }; ++ ZSTD_outBuffer output = { next_out, avail_out, 0 }; ++ result = ZSTD_decompressStream (dctx, &output, &input); ++ ++ if (! ZSTD_isError (result)) ++ { ++ total_out += output.pos; ++ next_out += output.pos; ++ avail_out -= output.pos; ++ next_in += input.pos; ++ avail_in -= input.pos; ++ } ++ ++ if (result == 0) ++ break; ++ } ++ while (avail_in > 0 && ! ZSTD_isError (result)); ++ ++ ZSTD_freeDCtx (dctx); ++ ++ if (ZSTD_isError (result)) ++ return fail (&state, DWFL_E_ZSTD); ++ ++ smaller_buffer (&state, total_out); ++ ++#elif USE_INFLATE + + /* This style actually only works with bzlib and liblzma. + The stupid zlib interface has nothing to grok the +diff --git a/libdwfl/libdwflP.h b/libdwfl/libdwflP.h +index ad6779ad..4c6fcb28 100644 +--- a/libdwfl/libdwflP.h ++++ b/libdwfl/libdwflP.h +@@ -61,6 +61,7 @@ typedef struct Dwfl_Process Dwfl_Process; + DWFL_ERROR (ZLIB, N_("gzip decompression failed")) \ + DWFL_ERROR (BZLIB, N_("bzip2 decompression failed")) \ + DWFL_ERROR (LZMA, N_("LZMA decompression failed")) \ ++ DWFL_ERROR (ZSTD, N_("zstd decompression failed")) \ + DWFL_ERROR (UNKNOWN_MACHINE, N_("no support library found for machine")) \ + DWFL_ERROR (NOREL, N_("Callbacks missing for ET_REL file")) \ + DWFL_ERROR (BADRELTYPE, N_("Unsupported relocation type")) \ +@@ -612,6 +613,10 @@ extern Dwfl_Error __libdw_unlzma (int fd, off_t start_offset, + void *mapped, size_t mapped_size, + void **whole, size_t *whole_size) + internal_function; ++extern Dwfl_Error __libdw_unzstd (int fd, off_t start_offset, ++ void *mapped, size_t mapped_size, ++ void **whole, size_t *whole_size) ++ internal_function; + + /* Skip the image header before a file image: updates *START_OFFSET. */ + extern Dwfl_Error __libdw_image_header (int fd, off_t *start_offset, +diff --git a/libdwfl/open.c b/libdwfl/open.c +index 35fc5283..77bd2bd9 100644 +--- a/libdwfl/open.c ++++ b/libdwfl/open.c +@@ -44,6 +44,10 @@ + # define __libdw_unlzma(...) DWFL_E_BADELF + #endif + ++#if !USE_ZSTD ++# define __libdw_unzstd(...) DWFL_E_BADELF ++#endif ++ + /* Consumes and replaces *ELF only on success. */ + static Dwfl_Error + decompress (int fd __attribute__ ((unused)), Elf **elf) +@@ -64,6 +68,8 @@ decompress (int fd __attribute__ ((unused)), Elf **elf) + error = __libdw_bunzip2 (fd, offset, mapped, mapped_size, &buffer, &size); + if (error == DWFL_E_BADELF) + error = __libdw_unlzma (fd, offset, mapped, mapped_size, &buffer, &size); ++ if (error == DWFL_E_BADELF) ++ error = __libdw_unzstd (fd, offset, mapped, mapped_size, &buffer, &size); + + if (error == DWFL_E_NOERROR) + { +diff --git a/libdwfl/zstd.c b/libdwfl/zstd.c +new file mode 100644 +index 00000000..dc4d5238 +--- /dev/null ++++ b/libdwfl/zstd.c +@@ -0,0 +1,4 @@ ++/* libzstd is pretty close to zlib and bzlib. */ ++ ++#define ZSTD ++#include "gzip.c" +diff --git a/tests/Makefile.am b/tests/Makefile.am +index 4629ce64..9d0707da 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -204,6 +204,10 @@ if LZMA + TESTS += run-readelf-s.sh run-dwflsyms.sh + endif + ++if HAVE_ZSTD ++TESTS += run-readelf-compressed-zstd.sh ++endif ++ + if HAVE_LIBASM + check_PROGRAMS += $(asm_TESTS) + TESTS += $(asm_TESTS) run-disasm-bpf.sh +@@ -256,6 +260,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \ + run-nm-syms.sh testfilesyms32.bz2 testfilesyms64.bz2 \ + run-nm-self.sh run-readelf-self.sh run-readelf-info-plus.sh \ + run-readelf-compressed.sh \ ++ run-readelf-compressed-zstd.sh \ + run-readelf-const-values.sh testfile-const-values.debug.bz2 \ + run-addrcfi.sh run-dwarfcfi.sh \ + testfile11-debugframe.bz2 testfile12-debugframe.bz2 \ +diff --git a/tests/run-readelf-compressed-zstd.sh b/tests/run-readelf-compressed-zstd.sh +new file mode 100755 +index 00000000..96208092 +--- /dev/null ++++ b/tests/run-readelf-compressed-zstd.sh +@@ -0,0 +1,39 @@ ++#! /bin/sh ++# Copyright (C) 2018 Red Hat, Inc. ++# This file is part of elfutils. ++# ++# This file is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# elfutils is distributed in the hope that it will be useful, but ++# WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++. $srcdir/test-subr.sh ++ ++if ! grep -q -F '#define USE_ZSTD' ${abs_top_builddir}/config.h; then ++ echo "elfutils built without zstd support" ++ exit 77 ++fi ++ ++# See run-strip-reloc.sh ++testfiles hello_i386.ko ++ ++tempfiles hello_i386.ko.zst readelf.out.1 readelf.out.2 ++ ++testrun ${abs_top_builddir}/src/readelf -a hello_i386.ko > readelf.out.1 ++zstd hello_i386.ko ++testrun ${abs_top_builddir}/src/readelf -a hello_i386.ko.zst > readelf.out.2 ++ ++diff -u readelf.out.1 readelf.out.2 ++if [ $? != 0 ]; then ++ exit 1; ++fi ++ ++exit 0 diff --git a/elfutils.spec b/elfutils.spec index f5f3d40..d3a6eae 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -1,6 +1,6 @@ Name: elfutils Version: 0.181 -%global baserelease 1 +%global baserelease 2 Release: %{baserelease}%{?dist} URL: http://elfutils.org/ %global source_url ftp://sourceware.org/pub/elfutils/%{version}/ @@ -31,6 +31,7 @@ BuildRequires: flex BuildRequires: zlib-devel BuildRequires: bzip2-devel BuildRequires: xz-devel +BuildRequires: libzstd-devel # For debuginfod BuildRequires: pkgconfig(libmicrohttpd) >= 0.9.33 @@ -40,11 +41,15 @@ BuildRequires: pkgconfig(libarchive) >= 3.1.2 # For tests need to bunzip2 test files. BuildRequires: bzip2 +BuildRequires: zstd # For the run-debuginfod-find.sh test case in %%check for /usr/sbin/ss BuildRequires: iproute BuildRequires: bsdtar BuildRequires: curl +BuildRequires: automake +BuildRequires: autoconf + %global _gnu %{nil} %global _program_prefix eu- @@ -55,6 +60,7 @@ BuildRequires: curl %endif # Patches +Patch1: elfutils-0.181-zstd.patch %description Elfutils is a collection of utilities, including stack (to show @@ -246,6 +252,9 @@ such servers to download those files on demand. %setup -q # Apply patches +%patch1 -p1 -b .zstd + +autoreconf -f -v -i # In case the above patches added any new test scripts, make sure they # are executable. @@ -430,6 +439,9 @@ exit 0 %systemd_postun_with_restart debuginfod.service %changelog +* Fri Sep 18 2020 Mark Wielaard - 0.181-2 +- Add ZSTD support elfutils-0.181-zstd.patch. + * Tue Sep 8 2020 Mark Wielaard - 0.181-1 - Upgrade to upstream 0.181 - libelf: elf_update now compensates (fixes up) a bad sh_addralign From 1860b7316df588368b62f332aef123fe3a4d01cd Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 19 Oct 2020 11:31:04 +0200 Subject: [PATCH 10/15] 0.181-3 - Add elfutils-0.181-array-param.patch. --- elfutils-0.181-array-param.patch | 472 +++++++++++++++++++++++++++++++ elfutils.spec | 7 +- 2 files changed, 478 insertions(+), 1 deletion(-) create mode 100644 elfutils-0.181-array-param.patch diff --git a/elfutils-0.181-array-param.patch b/elfutils-0.181-array-param.patch new file mode 100644 index 0000000..5099b1a --- /dev/null +++ b/elfutils-0.181-array-param.patch @@ -0,0 +1,472 @@ +commit 09b034419ef16cf39abcd7a2df9d0fe704176d13 +Author: Mark Wielaard +Date: Sat Oct 17 21:22:22 2020 +0200 + + libebl: Remove unused ebl_syscall_abi. + + GCC11 -Warray-parameter warned about ebl_syscall_abi being inconsistently + declared (once with a pointer to int, once with an array of 6 int elements). + Since ebl_syscall_abi isn't actually used and was only implemented for + 3 backends without any tests just remove it. + + Signed-off-by: Mark Wielaard + +diff --git a/backends/Makefile.am b/backends/Makefile.am +index f4052125..3849f457 100644 +--- a/backends/Makefile.am ++++ b/backends/Makefile.am +@@ -40,13 +40,13 @@ modules = i386 sh x86_64 ia64 alpha arm aarch64 sparc ppc ppc64 s390 \ + tilegx m68k bpf riscv csky + + i386_SRCS = i386_init.c i386_symbol.c i386_corenote.c i386_cfi.c \ +- i386_retval.c i386_regs.c i386_auxv.c i386_syscall.c \ ++ i386_retval.c i386_regs.c i386_auxv.c \ + i386_initreg.c i386_unwind.c + + sh_SRCS = sh_init.c sh_symbol.c sh_corenote.c sh_regs.c sh_retval.c + + x86_64_SRCS = x86_64_init.c x86_64_symbol.c x86_64_corenote.c x86_64_cfi.c \ +- x86_64_retval.c x86_64_regs.c x86_64_syscall.c x86_64_initreg.c \ ++ x86_64_retval.c x86_64_regs.c x86_64_initreg.c \ + x86_64_unwind.c x32_corenote.c + + +@@ -67,7 +67,7 @@ sparc_SRCS = sparc_init.c sparc_symbol.c sparc_regs.c sparc_retval.c \ + sparc_cfi.c sparc_initreg.c + + ppc_SRCS = ppc_init.c ppc_symbol.c ppc_retval.c ppc_regs.c \ +- ppc_corenote.c ppc_auxv.c ppc_attrs.c ppc_syscall.c \ ++ ppc_corenote.c ppc_auxv.c ppc_attrs.c \ + ppc_cfi.c ppc_initreg.c + + ppc64_SRCS = ppc64_init.c ppc64_symbol.c ppc64_retval.c ppc64_corenote.c \ +diff --git a/backends/i386_init.c b/backends/i386_init.c +index 3f6b9ed1..579e5fad 100644 +--- a/backends/i386_init.c ++++ b/backends/i386_init.c +@@ -52,7 +52,6 @@ i386_init (Elf *elf __attribute__ ((unused)), + HOOK (eh, debugscn_p); + HOOK (eh, return_value_location); + HOOK (eh, register_info); +- HOOK (eh, syscall_abi); + HOOK (eh, auxv_info); + HOOK (eh, disasm); + HOOK (eh, abi_cfi); +diff --git a/backends/i386_syscall.c b/backends/i386_syscall.c +deleted file mode 100644 +index 535dcd86..00000000 +--- a/backends/i386_syscall.c ++++ /dev/null +@@ -1,50 +0,0 @@ +-/* Linux/i386 system call ABI in DWARF register numbers. +- Copyright (C) 2008 Red Hat, Inc. +- This file is part of elfutils. +- +- This file is free software; you can redistribute it and/or modify +- it under the terms of either +- +- * the GNU Lesser General Public License as published by the Free +- Software Foundation; either version 3 of the License, or (at +- your option) any later version +- +- or +- +- * the GNU General Public License as published by the Free +- Software Foundation; either version 2 of the License, or (at +- your option) any later version +- +- or both in parallel, as here. +- +- elfutils is distributed in the hope that it will be useful, but +- WITHOUT ANY WARRANTY; without even the implied warranty of +- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- General Public License for more details. +- +- You should have received copies of the GNU General Public License and +- the GNU Lesser General Public License along with this program. If +- not, see . */ +- +-#ifdef HAVE_CONFIG_H +-# include +-#endif +- +-#define BACKEND i386_ +-#include "libebl_CPU.h" +- +-int +-i386_syscall_abi (Ebl *ebl __attribute__ ((unused)), +- int *sp, int *pc, int *callno, int args[6]) +-{ +- *sp = 4; /* %esp */ +- *pc = 8; /* %eip */ +- *callno = 0; /* %eax */ +- args[0] = 3; /* %ebx */ +- args[1] = 1; /* %ecx */ +- args[2] = 2; /* %edx */ +- args[3] = 6; /* %esi */ +- args[4] = 7; /* %edi */ +- args[5] = 5; /* %ebp */ +- return 0; +-} +diff --git a/backends/ppc64_init.c b/backends/ppc64_init.c +index f509aef6..ffc9842c 100644 +--- a/backends/ppc64_init.c ++++ b/backends/ppc64_init.c +@@ -58,7 +58,6 @@ ppc64_init (Elf *elf __attribute__ ((unused)), + HOOK (eh, bss_plt_p); + HOOK (eh, return_value_location); + HOOK (eh, register_info); +- HOOK (eh, syscall_abi); + HOOK (eh, core_note); + HOOK (eh, auxv_info); + HOOK (eh, check_object_attribute); +diff --git a/backends/ppc_init.c b/backends/ppc_init.c +index ac440ab2..08468f8f 100644 +--- a/backends/ppc_init.c ++++ b/backends/ppc_init.c +@@ -54,7 +54,6 @@ ppc_init (Elf *elf __attribute__ ((unused)), + HOOK (eh, bss_plt_p); + HOOK (eh, return_value_location); + HOOK (eh, register_info); +- HOOK (eh, syscall_abi); + HOOK (eh, core_note); + HOOK (eh, auxv_info); + HOOK (eh, check_object_attribute); +diff --git a/backends/ppc_syscall.c b/backends/ppc_syscall.c +deleted file mode 100644 +index b1b9c52b..00000000 +--- a/backends/ppc_syscall.c ++++ /dev/null +@@ -1,53 +0,0 @@ +-/* Linux/PPC system call ABI in DWARF register numbers. +- Copyright (C) 2008 Red Hat, Inc. +- This file is part of elfutils. +- +- This file is free software; you can redistribute it and/or modify +- it under the terms of either +- +- * the GNU Lesser General Public License as published by the Free +- Software Foundation; either version 3 of the License, or (at +- your option) any later version +- +- or +- +- * the GNU General Public License as published by the Free +- Software Foundation; either version 2 of the License, or (at +- your option) any later version +- +- or both in parallel, as here. +- +- elfutils is distributed in the hope that it will be useful, but +- WITHOUT ANY WARRANTY; without even the implied warranty of +- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- General Public License for more details. +- +- You should have received copies of the GNU General Public License and +- the GNU Lesser General Public License along with this program. If +- not, see . */ +- +-#ifdef HAVE_CONFIG_H +-# include +-#endif +- +-#define BACKEND ppc_ +-#include "libebl_CPU.h" +- +-int +-ppc_syscall_abi (Ebl *ebl __attribute__ ((unused)), +- int *sp, int *pc, int *callno, int args[6]) +-{ +- *sp = 1; +- *pc = -1; +- *callno = 0; +- args[0] = 3; +- args[1] = 4; +- args[2] = 5; +- args[3] = 6; +- args[4] = 7; +- args[5] = 8; +- return 0; +-} +- +-__typeof (ppc_syscall_abi) +-ppc64_syscall_abi __attribute__ ((alias ("ppc_syscall_abi"))); +diff --git a/backends/x86_64_init.c b/backends/x86_64_init.c +index 44c1ad28..8db9b643 100644 +--- a/backends/x86_64_init.c ++++ b/backends/x86_64_init.c +@@ -56,7 +56,6 @@ x86_64_init (Elf *elf __attribute__ ((unused)), + HOOK (eh, core_note); + HOOK (eh, return_value_location); + HOOK (eh, register_info); +- HOOK (eh, syscall_abi); + HOOK (eh, auxv_info); + HOOK (eh, disasm); + HOOK (eh, abi_cfi); +diff --git a/backends/x86_64_syscall.c b/backends/x86_64_syscall.c +deleted file mode 100644 +index 0deb8bad..00000000 +--- a/backends/x86_64_syscall.c ++++ /dev/null +@@ -1,50 +0,0 @@ +-/* Linux/x86-64 system call ABI in DWARF register numbers. +- Copyright (C) 2008 Red Hat, Inc. +- This file is part of elfutils. +- +- This file is free software; you can redistribute it and/or modify +- it under the terms of either +- +- * the GNU Lesser General Public License as published by the Free +- Software Foundation; either version 3 of the License, or (at +- your option) any later version +- +- or +- +- * the GNU General Public License as published by the Free +- Software Foundation; either version 2 of the License, or (at +- your option) any later version +- +- or both in parallel, as here. +- +- elfutils is distributed in the hope that it will be useful, but +- WITHOUT ANY WARRANTY; without even the implied warranty of +- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- General Public License for more details. +- +- You should have received copies of the GNU General Public License and +- the GNU Lesser General Public License along with this program. If +- not, see . */ +- +-#ifdef HAVE_CONFIG_H +-# include +-#endif +- +-#define BACKEND x86_64_ +-#include "libebl_CPU.h" +- +-int +-x86_64_syscall_abi (Ebl *ebl __attribute__ ((unused)), +- int *sp, int *pc, int *callno, int args[6]) +-{ +- *sp = 7; /* %rsp */ +- *pc = 16; /* %rip */ +- *callno = 0; /* %rax */ +- args[0] = 5; /* %rdi */ +- args[1] = 4; /* %rsi */ +- args[2] = 1; /* %rdx */ +- args[3] = 10; /* %r10 */ +- args[4] = 8; /* %r8 */ +- args[5] = 9; /* %r9 */ +- return 0; +-} +diff --git a/libebl/Makefile.am b/libebl/Makefile.am +index d0d475b8..d84e7ee2 100644 +--- a/libebl/Makefile.am ++++ b/libebl/Makefile.am +@@ -51,7 +51,7 @@ libebl_a_SOURCES = eblopenbackend.c eblclosebackend.c eblreloctypename.c \ + eblbsspltp.c eblretval.c eblreginfo.c eblnonerelocp.c \ + eblrelativerelocp.c eblsysvhashentrysize.c eblauxvinfo.c \ + eblcheckobjattr.c ebl_check_special_section.c \ +- ebl_syscall_abi.c eblabicfi.c eblstother.c eblinitreg.c \ ++ eblabicfi.c eblstother.c eblinitreg.c \ + ebldwarftoregno.c eblnormalizepc.c eblunwind.c \ + eblresolvesym.c eblcheckreloctargettype.c \ + ebl_data_marker_symbol.c +diff --git a/libebl/ebl-hooks.h b/libebl/ebl-hooks.h +index 1e7960b8..1214bb84 100644 +--- a/libebl/ebl-hooks.h ++++ b/libebl/ebl-hooks.h +@@ -142,10 +142,6 @@ ssize_t EBLHOOK(register_info) (Ebl *ebl, + const char **prefix, const char **setname, + int *bits, int *type); + +-/* Return system call ABI registers. */ +-int EBLHOOK(syscall_abi) (Ebl *ebl, int *sp, int *pc, +- int *callno, int args[6]); +- + /* Disassembler function. */ + int EBLHOOK(disasm) (Ebl *ebl, const uint8_t **startp, const uint8_t *end, + GElf_Addr addr, const char *fmt, DisasmOutputCB_t outcb, +diff --git a/libebl/ebl_syscall_abi.c b/libebl/ebl_syscall_abi.c +deleted file mode 100644 +index a25369d2..00000000 +--- a/libebl/ebl_syscall_abi.c ++++ /dev/null +@@ -1,40 +0,0 @@ +-/* Return system call ABI mapped to DWARF register numbers. +- Copyright (C) 2008 Red Hat, Inc. +- This file is part of elfutils. +- +- This file is free software; you can redistribute it and/or modify +- it under the terms of either +- +- * the GNU Lesser General Public License as published by the Free +- Software Foundation; either version 3 of the License, or (at +- your option) any later version +- +- or +- +- * the GNU General Public License as published by the Free +- Software Foundation; either version 2 of the License, or (at +- your option) any later version +- +- or both in parallel, as here. +- +- elfutils is distributed in the hope that it will be useful, but +- WITHOUT ANY WARRANTY; without even the implied warranty of +- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- General Public License for more details. +- +- You should have received copies of the GNU General Public License and +- the GNU Lesser General Public License along with this program. If +- not, see . */ +- +-#ifdef HAVE_CONFIG_H +-# include +-#endif +- +-#include +- +- +-int +-ebl_syscall_abi (Ebl *ebl, int *sp, int *pc, int *callno, int *args) +-{ +- return ebl != NULL ? ebl->syscall_abi (ebl, sp, pc, callno, args) : -1; +-} +diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c +index b3b6fc01..90a83f26 100644 +--- a/libebl/eblopenbackend.c ++++ b/libebl/eblopenbackend.c +@@ -214,8 +214,6 @@ static ssize_t default_register_info (Ebl *ebl, + const char **prefix, + const char **setname, + int *bits, int *type); +-static int default_syscall_abi (Ebl *ebl, int *sp, int *pc, +- int *callno, int args[6]); + static bool default_check_object_attribute (Ebl *ebl, const char *vendor, + int tag, uint64_t value, + const char **tag_name, +@@ -259,7 +257,6 @@ fill_defaults (Ebl *result) + result->bss_plt_p = default_bss_plt_p; + result->return_value_location = default_return_value_location; + result->register_info = default_register_info; +- result->syscall_abi = default_syscall_abi; + result->check_object_attribute = default_check_object_attribute; + result->check_reloc_target_type = default_check_reloc_target_type; + result->disasm = NULL; +@@ -690,20 +687,6 @@ default_register_info (Ebl *ebl __attribute__ ((unused)), + return snprintf (name, namelen, "reg%d", regno); + } + +-static int +-default_syscall_abi (Ebl *ebl __attribute__ ((unused)), +- int *sp, int *pc, int *callno, int args[6]) +-{ +- *sp = *pc = *callno = -1; +- args[0] = -1; +- args[1] = -1; +- args[2] = -1; +- args[3] = -1; +- args[4] = -1; +- args[5] = -1; +- return -1; +-} +- + static bool + default_check_object_attribute (Ebl *ebl __attribute__ ((unused)), + const char *vendor __attribute__ ((unused)), +diff --git a/libebl/libebl.h b/libebl/libebl.h +index 23c0e950..731001d3 100644 +--- a/libebl/libebl.h ++++ b/libebl/libebl.h +@@ -241,14 +241,6 @@ extern ssize_t ebl_register_info (Ebl *ebl, + const char **prefix, const char **setname, + int *bits, int *type); + +-/* Fill in the DWARF register numbers for the registers used in system calls. +- The SP and PC are what kernel reports call the user stack pointer and PC. +- The CALLNO and ARGS are the system call number and incoming arguments. +- Each of these is filled with the DWARF register number corresponding, +- or -1 if there is none. Returns zero when the information is available. */ +-extern int ebl_syscall_abi (Ebl *ebl, int *sp, int *pc, +- int *callno, int args[6]); +- + /* Supply the ABI-specified state of DWARF CFI before CIE initial programs. + + The DWARF 3.0 spec says that the default initial states of all registers +commit 4b2edc1161e6786b09b65da3a62ef24078324d4c +Author: Mark Wielaard +Date: Mon Oct 19 10:17:59 2020 +0200 + + libdw: dwarf_frame_register takes an array of at least 3 Dwarf_Ops + + GCC11 will warn about a mismatch in the declaration of dwarf_frame_register: + + dwarf_frame_register.c:37:61: error: argument 3 of type ‘Dwarf_Op *’ + declared as a pointer [-Werror=array-parameter=] + 37 | dwarf_frame_register (Dwarf_Frame *fs, int regno, Dwarf_Op *ops_mem, + | ~~~~~~~~~~^~~~~~~ + libdw.h:1068:43: note: previously declared as an array ‘Dwarf_Op[3]’ + 1068 | Dwarf_Op ops_mem[3], + | ~~~~~~~~~^~~~~~~~~~ + + When fixing that it will show an actual bug in the addrcfi testcase: + + addrcfi.c:98:16: error: ‘dwarf_frame_register’ accessing 96 bytes in a + region of size 64 [-Werror=stringop-overflow=] + 98 | int result = dwarf_frame_register (stuff->frame, regno, ops_mem, &ops, &nops); + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + addrcfi.c:98:16: note: referencing argument 3 of type ‘Dwarf_Op *’ + 1069 | extern int dwarf_frame_register (Dwarf_Frame *frame, int regno, + | ^~~~~~~~~~~~~~~~~~~~ + + Fix the declaration, fix the bug and add an extra comment to the description + in libdw.h. + + Signed-off-by: Mark Wielaard + +diff --git a/libdw/dwarf_frame_register.c b/libdw/dwarf_frame_register.c +index d0159fb8..bcf3fa03 100644 +--- a/libdw/dwarf_frame_register.c ++++ b/libdw/dwarf_frame_register.c +@@ -34,7 +34,7 @@ + #include + + int +-dwarf_frame_register (Dwarf_Frame *fs, int regno, Dwarf_Op *ops_mem, ++dwarf_frame_register (Dwarf_Frame *fs, int regno, Dwarf_Op ops_mem[3], + Dwarf_Op **ops, size_t *nops) + { + /* Maybe there was a previous error. */ +diff --git a/libdw/libdw.h b/libdw/libdw.h +index 1a4e15a1..ad4fa6ea 100644 +--- a/libdw/libdw.h ++++ b/libdw/libdw.h +@@ -1061,9 +1061,11 @@ extern int dwarf_frame_cfa (Dwarf_Frame *frame, Dwarf_Op **ops, size_t *nops) + caller's REGNO is "same_value", i.e. this frame did not change it; + ask the caller frame where to find it. + +- For common simple expressions *OPS is OPS_MEM. For arbitrary DWARF +- expressions in the CFI, *OPS is an internal pointer that can be used as +- long as the Dwarf_CFI used to create FRAME remains alive. */ ++ For common simple expressions *OPS is OPS_MEM (which is a caller ++ owned array for for at least 3 Dwarf_Ops). For arbitrary DWARF ++ expressions in the CFI, *OPS is an internal pointer that can be ++ used as long as the Dwarf_CFI used to create FRAME remains ++ alive. */ + extern int dwarf_frame_register (Dwarf_Frame *frame, int regno, + Dwarf_Op ops_mem[3], + Dwarf_Op **ops, size_t *nops) +diff --git a/tests/addrcfi.c b/tests/addrcfi.c +index 589b8513..2b7d7bd0 100644 +--- a/tests/addrcfi.c ++++ b/tests/addrcfi.c +@@ -92,7 +92,7 @@ print_register (void *arg, + + printf ("\t%s reg%u (%s%s): ", setname, regno, prefix, regname); + +- Dwarf_Op ops_mem[2]; ++ Dwarf_Op ops_mem[3]; + Dwarf_Op *ops; + size_t nops; + int result = dwarf_frame_register (stuff->frame, regno, ops_mem, &ops, &nops); diff --git a/elfutils.spec b/elfutils.spec index d3a6eae..0ad6e76 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -1,6 +1,6 @@ Name: elfutils Version: 0.181 -%global baserelease 2 +%global baserelease 3 Release: %{baserelease}%{?dist} URL: http://elfutils.org/ %global source_url ftp://sourceware.org/pub/elfutils/%{version}/ @@ -61,6 +61,7 @@ BuildRequires: autoconf # Patches Patch1: elfutils-0.181-zstd.patch +Patch2: elfutils-0.181-array-param.patch %description Elfutils is a collection of utilities, including stack (to show @@ -253,6 +254,7 @@ such servers to download those files on demand. # Apply patches %patch1 -p1 -b .zstd +%patch2 -p1 -b .array_param autoreconf -f -v -i @@ -439,6 +441,9 @@ exit 0 %systemd_postun_with_restart debuginfod.service %changelog +* Mon Oct 19 2020 Mark Wielaard - 0.181-3 +- Add elfutils-0.181-array-param.patch. + * Fri Sep 18 2020 Mark Wielaard - 0.181-2 - Add ZSTD support elfutils-0.181-zstd.patch. From c256956adcd5391c36c7abb55e2ef5423dbcbdb7 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sat, 31 Oct 2020 17:52:50 +0100 Subject: [PATCH 11/15] elfutils 0.182 --- .gitignore | 1 + elfutils-0.181-array-param.patch | 472 ------------------------------- elfutils-0.181-zstd.patch | 348 ----------------------- elfutils.spec | 27 +- sources | 2 +- 5 files changed, 21 insertions(+), 829 deletions(-) delete mode 100644 elfutils-0.181-array-param.patch delete mode 100644 elfutils-0.181-zstd.patch diff --git a/.gitignore b/.gitignore index f7d1f6e..d0ad04a 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ /elfutils-0.179.tar.bz2 /elfutils-0.180.tar.bz2 /elfutils-0.181.tar.bz2 +/elfutils-0.182.tar.bz2 diff --git a/elfutils-0.181-array-param.patch b/elfutils-0.181-array-param.patch deleted file mode 100644 index 5099b1a..0000000 --- a/elfutils-0.181-array-param.patch +++ /dev/null @@ -1,472 +0,0 @@ -commit 09b034419ef16cf39abcd7a2df9d0fe704176d13 -Author: Mark Wielaard -Date: Sat Oct 17 21:22:22 2020 +0200 - - libebl: Remove unused ebl_syscall_abi. - - GCC11 -Warray-parameter warned about ebl_syscall_abi being inconsistently - declared (once with a pointer to int, once with an array of 6 int elements). - Since ebl_syscall_abi isn't actually used and was only implemented for - 3 backends without any tests just remove it. - - Signed-off-by: Mark Wielaard - -diff --git a/backends/Makefile.am b/backends/Makefile.am -index f4052125..3849f457 100644 ---- a/backends/Makefile.am -+++ b/backends/Makefile.am -@@ -40,13 +40,13 @@ modules = i386 sh x86_64 ia64 alpha arm aarch64 sparc ppc ppc64 s390 \ - tilegx m68k bpf riscv csky - - i386_SRCS = i386_init.c i386_symbol.c i386_corenote.c i386_cfi.c \ -- i386_retval.c i386_regs.c i386_auxv.c i386_syscall.c \ -+ i386_retval.c i386_regs.c i386_auxv.c \ - i386_initreg.c i386_unwind.c - - sh_SRCS = sh_init.c sh_symbol.c sh_corenote.c sh_regs.c sh_retval.c - - x86_64_SRCS = x86_64_init.c x86_64_symbol.c x86_64_corenote.c x86_64_cfi.c \ -- x86_64_retval.c x86_64_regs.c x86_64_syscall.c x86_64_initreg.c \ -+ x86_64_retval.c x86_64_regs.c x86_64_initreg.c \ - x86_64_unwind.c x32_corenote.c - - -@@ -67,7 +67,7 @@ sparc_SRCS = sparc_init.c sparc_symbol.c sparc_regs.c sparc_retval.c \ - sparc_cfi.c sparc_initreg.c - - ppc_SRCS = ppc_init.c ppc_symbol.c ppc_retval.c ppc_regs.c \ -- ppc_corenote.c ppc_auxv.c ppc_attrs.c ppc_syscall.c \ -+ ppc_corenote.c ppc_auxv.c ppc_attrs.c \ - ppc_cfi.c ppc_initreg.c - - ppc64_SRCS = ppc64_init.c ppc64_symbol.c ppc64_retval.c ppc64_corenote.c \ -diff --git a/backends/i386_init.c b/backends/i386_init.c -index 3f6b9ed1..579e5fad 100644 ---- a/backends/i386_init.c -+++ b/backends/i386_init.c -@@ -52,7 +52,6 @@ i386_init (Elf *elf __attribute__ ((unused)), - HOOK (eh, debugscn_p); - HOOK (eh, return_value_location); - HOOK (eh, register_info); -- HOOK (eh, syscall_abi); - HOOK (eh, auxv_info); - HOOK (eh, disasm); - HOOK (eh, abi_cfi); -diff --git a/backends/i386_syscall.c b/backends/i386_syscall.c -deleted file mode 100644 -index 535dcd86..00000000 ---- a/backends/i386_syscall.c -+++ /dev/null -@@ -1,50 +0,0 @@ --/* Linux/i386 system call ABI in DWARF register numbers. -- Copyright (C) 2008 Red Hat, Inc. -- This file is part of elfutils. -- -- This file is free software; you can redistribute it and/or modify -- it under the terms of either -- -- * the GNU Lesser General Public License as published by the Free -- Software Foundation; either version 3 of the License, or (at -- your option) any later version -- -- or -- -- * the GNU General Public License as published by the Free -- Software Foundation; either version 2 of the License, or (at -- your option) any later version -- -- or both in parallel, as here. -- -- elfutils is distributed in the hope that it will be useful, but -- WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- General Public License for more details. -- -- You should have received copies of the GNU General Public License and -- the GNU Lesser General Public License along with this program. If -- not, see . */ -- --#ifdef HAVE_CONFIG_H --# include --#endif -- --#define BACKEND i386_ --#include "libebl_CPU.h" -- --int --i386_syscall_abi (Ebl *ebl __attribute__ ((unused)), -- int *sp, int *pc, int *callno, int args[6]) --{ -- *sp = 4; /* %esp */ -- *pc = 8; /* %eip */ -- *callno = 0; /* %eax */ -- args[0] = 3; /* %ebx */ -- args[1] = 1; /* %ecx */ -- args[2] = 2; /* %edx */ -- args[3] = 6; /* %esi */ -- args[4] = 7; /* %edi */ -- args[5] = 5; /* %ebp */ -- return 0; --} -diff --git a/backends/ppc64_init.c b/backends/ppc64_init.c -index f509aef6..ffc9842c 100644 ---- a/backends/ppc64_init.c -+++ b/backends/ppc64_init.c -@@ -58,7 +58,6 @@ ppc64_init (Elf *elf __attribute__ ((unused)), - HOOK (eh, bss_plt_p); - HOOK (eh, return_value_location); - HOOK (eh, register_info); -- HOOK (eh, syscall_abi); - HOOK (eh, core_note); - HOOK (eh, auxv_info); - HOOK (eh, check_object_attribute); -diff --git a/backends/ppc_init.c b/backends/ppc_init.c -index ac440ab2..08468f8f 100644 ---- a/backends/ppc_init.c -+++ b/backends/ppc_init.c -@@ -54,7 +54,6 @@ ppc_init (Elf *elf __attribute__ ((unused)), - HOOK (eh, bss_plt_p); - HOOK (eh, return_value_location); - HOOK (eh, register_info); -- HOOK (eh, syscall_abi); - HOOK (eh, core_note); - HOOK (eh, auxv_info); - HOOK (eh, check_object_attribute); -diff --git a/backends/ppc_syscall.c b/backends/ppc_syscall.c -deleted file mode 100644 -index b1b9c52b..00000000 ---- a/backends/ppc_syscall.c -+++ /dev/null -@@ -1,53 +0,0 @@ --/* Linux/PPC system call ABI in DWARF register numbers. -- Copyright (C) 2008 Red Hat, Inc. -- This file is part of elfutils. -- -- This file is free software; you can redistribute it and/or modify -- it under the terms of either -- -- * the GNU Lesser General Public License as published by the Free -- Software Foundation; either version 3 of the License, or (at -- your option) any later version -- -- or -- -- * the GNU General Public License as published by the Free -- Software Foundation; either version 2 of the License, or (at -- your option) any later version -- -- or both in parallel, as here. -- -- elfutils is distributed in the hope that it will be useful, but -- WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- General Public License for more details. -- -- You should have received copies of the GNU General Public License and -- the GNU Lesser General Public License along with this program. If -- not, see . */ -- --#ifdef HAVE_CONFIG_H --# include --#endif -- --#define BACKEND ppc_ --#include "libebl_CPU.h" -- --int --ppc_syscall_abi (Ebl *ebl __attribute__ ((unused)), -- int *sp, int *pc, int *callno, int args[6]) --{ -- *sp = 1; -- *pc = -1; -- *callno = 0; -- args[0] = 3; -- args[1] = 4; -- args[2] = 5; -- args[3] = 6; -- args[4] = 7; -- args[5] = 8; -- return 0; --} -- --__typeof (ppc_syscall_abi) --ppc64_syscall_abi __attribute__ ((alias ("ppc_syscall_abi"))); -diff --git a/backends/x86_64_init.c b/backends/x86_64_init.c -index 44c1ad28..8db9b643 100644 ---- a/backends/x86_64_init.c -+++ b/backends/x86_64_init.c -@@ -56,7 +56,6 @@ x86_64_init (Elf *elf __attribute__ ((unused)), - HOOK (eh, core_note); - HOOK (eh, return_value_location); - HOOK (eh, register_info); -- HOOK (eh, syscall_abi); - HOOK (eh, auxv_info); - HOOK (eh, disasm); - HOOK (eh, abi_cfi); -diff --git a/backends/x86_64_syscall.c b/backends/x86_64_syscall.c -deleted file mode 100644 -index 0deb8bad..00000000 ---- a/backends/x86_64_syscall.c -+++ /dev/null -@@ -1,50 +0,0 @@ --/* Linux/x86-64 system call ABI in DWARF register numbers. -- Copyright (C) 2008 Red Hat, Inc. -- This file is part of elfutils. -- -- This file is free software; you can redistribute it and/or modify -- it under the terms of either -- -- * the GNU Lesser General Public License as published by the Free -- Software Foundation; either version 3 of the License, or (at -- your option) any later version -- -- or -- -- * the GNU General Public License as published by the Free -- Software Foundation; either version 2 of the License, or (at -- your option) any later version -- -- or both in parallel, as here. -- -- elfutils is distributed in the hope that it will be useful, but -- WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- General Public License for more details. -- -- You should have received copies of the GNU General Public License and -- the GNU Lesser General Public License along with this program. If -- not, see . */ -- --#ifdef HAVE_CONFIG_H --# include --#endif -- --#define BACKEND x86_64_ --#include "libebl_CPU.h" -- --int --x86_64_syscall_abi (Ebl *ebl __attribute__ ((unused)), -- int *sp, int *pc, int *callno, int args[6]) --{ -- *sp = 7; /* %rsp */ -- *pc = 16; /* %rip */ -- *callno = 0; /* %rax */ -- args[0] = 5; /* %rdi */ -- args[1] = 4; /* %rsi */ -- args[2] = 1; /* %rdx */ -- args[3] = 10; /* %r10 */ -- args[4] = 8; /* %r8 */ -- args[5] = 9; /* %r9 */ -- return 0; --} -diff --git a/libebl/Makefile.am b/libebl/Makefile.am -index d0d475b8..d84e7ee2 100644 ---- a/libebl/Makefile.am -+++ b/libebl/Makefile.am -@@ -51,7 +51,7 @@ libebl_a_SOURCES = eblopenbackend.c eblclosebackend.c eblreloctypename.c \ - eblbsspltp.c eblretval.c eblreginfo.c eblnonerelocp.c \ - eblrelativerelocp.c eblsysvhashentrysize.c eblauxvinfo.c \ - eblcheckobjattr.c ebl_check_special_section.c \ -- ebl_syscall_abi.c eblabicfi.c eblstother.c eblinitreg.c \ -+ eblabicfi.c eblstother.c eblinitreg.c \ - ebldwarftoregno.c eblnormalizepc.c eblunwind.c \ - eblresolvesym.c eblcheckreloctargettype.c \ - ebl_data_marker_symbol.c -diff --git a/libebl/ebl-hooks.h b/libebl/ebl-hooks.h -index 1e7960b8..1214bb84 100644 ---- a/libebl/ebl-hooks.h -+++ b/libebl/ebl-hooks.h -@@ -142,10 +142,6 @@ ssize_t EBLHOOK(register_info) (Ebl *ebl, - const char **prefix, const char **setname, - int *bits, int *type); - --/* Return system call ABI registers. */ --int EBLHOOK(syscall_abi) (Ebl *ebl, int *sp, int *pc, -- int *callno, int args[6]); -- - /* Disassembler function. */ - int EBLHOOK(disasm) (Ebl *ebl, const uint8_t **startp, const uint8_t *end, - GElf_Addr addr, const char *fmt, DisasmOutputCB_t outcb, -diff --git a/libebl/ebl_syscall_abi.c b/libebl/ebl_syscall_abi.c -deleted file mode 100644 -index a25369d2..00000000 ---- a/libebl/ebl_syscall_abi.c -+++ /dev/null -@@ -1,40 +0,0 @@ --/* Return system call ABI mapped to DWARF register numbers. -- Copyright (C) 2008 Red Hat, Inc. -- This file is part of elfutils. -- -- This file is free software; you can redistribute it and/or modify -- it under the terms of either -- -- * the GNU Lesser General Public License as published by the Free -- Software Foundation; either version 3 of the License, or (at -- your option) any later version -- -- or -- -- * the GNU General Public License as published by the Free -- Software Foundation; either version 2 of the License, or (at -- your option) any later version -- -- or both in parallel, as here. -- -- elfutils is distributed in the hope that it will be useful, but -- WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- General Public License for more details. -- -- You should have received copies of the GNU General Public License and -- the GNU Lesser General Public License along with this program. If -- not, see . */ -- --#ifdef HAVE_CONFIG_H --# include --#endif -- --#include -- -- --int --ebl_syscall_abi (Ebl *ebl, int *sp, int *pc, int *callno, int *args) --{ -- return ebl != NULL ? ebl->syscall_abi (ebl, sp, pc, callno, args) : -1; --} -diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c -index b3b6fc01..90a83f26 100644 ---- a/libebl/eblopenbackend.c -+++ b/libebl/eblopenbackend.c -@@ -214,8 +214,6 @@ static ssize_t default_register_info (Ebl *ebl, - const char **prefix, - const char **setname, - int *bits, int *type); --static int default_syscall_abi (Ebl *ebl, int *sp, int *pc, -- int *callno, int args[6]); - static bool default_check_object_attribute (Ebl *ebl, const char *vendor, - int tag, uint64_t value, - const char **tag_name, -@@ -259,7 +257,6 @@ fill_defaults (Ebl *result) - result->bss_plt_p = default_bss_plt_p; - result->return_value_location = default_return_value_location; - result->register_info = default_register_info; -- result->syscall_abi = default_syscall_abi; - result->check_object_attribute = default_check_object_attribute; - result->check_reloc_target_type = default_check_reloc_target_type; - result->disasm = NULL; -@@ -690,20 +687,6 @@ default_register_info (Ebl *ebl __attribute__ ((unused)), - return snprintf (name, namelen, "reg%d", regno); - } - --static int --default_syscall_abi (Ebl *ebl __attribute__ ((unused)), -- int *sp, int *pc, int *callno, int args[6]) --{ -- *sp = *pc = *callno = -1; -- args[0] = -1; -- args[1] = -1; -- args[2] = -1; -- args[3] = -1; -- args[4] = -1; -- args[5] = -1; -- return -1; --} -- - static bool - default_check_object_attribute (Ebl *ebl __attribute__ ((unused)), - const char *vendor __attribute__ ((unused)), -diff --git a/libebl/libebl.h b/libebl/libebl.h -index 23c0e950..731001d3 100644 ---- a/libebl/libebl.h -+++ b/libebl/libebl.h -@@ -241,14 +241,6 @@ extern ssize_t ebl_register_info (Ebl *ebl, - const char **prefix, const char **setname, - int *bits, int *type); - --/* Fill in the DWARF register numbers for the registers used in system calls. -- The SP and PC are what kernel reports call the user stack pointer and PC. -- The CALLNO and ARGS are the system call number and incoming arguments. -- Each of these is filled with the DWARF register number corresponding, -- or -1 if there is none. Returns zero when the information is available. */ --extern int ebl_syscall_abi (Ebl *ebl, int *sp, int *pc, -- int *callno, int args[6]); -- - /* Supply the ABI-specified state of DWARF CFI before CIE initial programs. - - The DWARF 3.0 spec says that the default initial states of all registers -commit 4b2edc1161e6786b09b65da3a62ef24078324d4c -Author: Mark Wielaard -Date: Mon Oct 19 10:17:59 2020 +0200 - - libdw: dwarf_frame_register takes an array of at least 3 Dwarf_Ops - - GCC11 will warn about a mismatch in the declaration of dwarf_frame_register: - - dwarf_frame_register.c:37:61: error: argument 3 of type ‘Dwarf_Op *’ - declared as a pointer [-Werror=array-parameter=] - 37 | dwarf_frame_register (Dwarf_Frame *fs, int regno, Dwarf_Op *ops_mem, - | ~~~~~~~~~~^~~~~~~ - libdw.h:1068:43: note: previously declared as an array ‘Dwarf_Op[3]’ - 1068 | Dwarf_Op ops_mem[3], - | ~~~~~~~~~^~~~~~~~~~ - - When fixing that it will show an actual bug in the addrcfi testcase: - - addrcfi.c:98:16: error: ‘dwarf_frame_register’ accessing 96 bytes in a - region of size 64 [-Werror=stringop-overflow=] - 98 | int result = dwarf_frame_register (stuff->frame, regno, ops_mem, &ops, &nops); - | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - addrcfi.c:98:16: note: referencing argument 3 of type ‘Dwarf_Op *’ - 1069 | extern int dwarf_frame_register (Dwarf_Frame *frame, int regno, - | ^~~~~~~~~~~~~~~~~~~~ - - Fix the declaration, fix the bug and add an extra comment to the description - in libdw.h. - - Signed-off-by: Mark Wielaard - -diff --git a/libdw/dwarf_frame_register.c b/libdw/dwarf_frame_register.c -index d0159fb8..bcf3fa03 100644 ---- a/libdw/dwarf_frame_register.c -+++ b/libdw/dwarf_frame_register.c -@@ -34,7 +34,7 @@ - #include - - int --dwarf_frame_register (Dwarf_Frame *fs, int regno, Dwarf_Op *ops_mem, -+dwarf_frame_register (Dwarf_Frame *fs, int regno, Dwarf_Op ops_mem[3], - Dwarf_Op **ops, size_t *nops) - { - /* Maybe there was a previous error. */ -diff --git a/libdw/libdw.h b/libdw/libdw.h -index 1a4e15a1..ad4fa6ea 100644 ---- a/libdw/libdw.h -+++ b/libdw/libdw.h -@@ -1061,9 +1061,11 @@ extern int dwarf_frame_cfa (Dwarf_Frame *frame, Dwarf_Op **ops, size_t *nops) - caller's REGNO is "same_value", i.e. this frame did not change it; - ask the caller frame where to find it. - -- For common simple expressions *OPS is OPS_MEM. For arbitrary DWARF -- expressions in the CFI, *OPS is an internal pointer that can be used as -- long as the Dwarf_CFI used to create FRAME remains alive. */ -+ For common simple expressions *OPS is OPS_MEM (which is a caller -+ owned array for for at least 3 Dwarf_Ops). For arbitrary DWARF -+ expressions in the CFI, *OPS is an internal pointer that can be -+ used as long as the Dwarf_CFI used to create FRAME remains -+ alive. */ - extern int dwarf_frame_register (Dwarf_Frame *frame, int regno, - Dwarf_Op ops_mem[3], - Dwarf_Op **ops, size_t *nops) -diff --git a/tests/addrcfi.c b/tests/addrcfi.c -index 589b8513..2b7d7bd0 100644 ---- a/tests/addrcfi.c -+++ b/tests/addrcfi.c -@@ -92,7 +92,7 @@ print_register (void *arg, - - printf ("\t%s reg%u (%s%s): ", setname, regno, prefix, regname); - -- Dwarf_Op ops_mem[2]; -+ Dwarf_Op ops_mem[3]; - Dwarf_Op *ops; - size_t nops; - int result = dwarf_frame_register (stuff->frame, regno, ops_mem, &ops, &nops); diff --git a/elfutils-0.181-zstd.patch b/elfutils-0.181-zstd.patch deleted file mode 100644 index 1b68989..0000000 --- a/elfutils-0.181-zstd.patch +++ /dev/null @@ -1,348 +0,0 @@ -commit c5b0a640f0f7d2a195b822bcd88bb379476dbb97 -Author: Mark Wielaard -Date: Fri Sep 18 12:49:29 2020 +0200 - - zstd support - -diff --git a/config/elfutils.spec.in b/config/elfutils.spec.in -index 95f63f5a..37af1b07 100644 ---- a/config/elfutils.spec.in -+++ b/config/elfutils.spec.in -@@ -24,6 +24,7 @@ BuildRequires: flex - BuildRequires: zlib-devel - BuildRequires: bzip2-devel - BuildRequires: xz-devel -+BuildRequires: libzstd-devel - - # For debuginfod - BuildRequires: pkgconfig(libmicrohttpd) >= 0.9.33 -@@ -33,6 +34,7 @@ BuildRequires: pkgconfig(libarchive) >= 3.1.2 - - # For tests need to bunzip2 test files. - BuildRequires: bzip2 -+BuildRequires: zstd - # For the run-debuginfod-find.sh test case in %check for /usr/sbin/ss - BuildRequires: iproute - BuildRequires: bsdtar -diff --git a/config/libdw.pc.in b/config/libdw.pc.in -index 3fc283db..2e83a432 100644 ---- a/config/libdw.pc.in -+++ b/config/libdw.pc.in -@@ -17,6 +17,6 @@ Requires: libelf = @VERSION@ - - # We support various compressed ELF images, but don't export any of the - # data structures or functions. zlib (gz) is always required, bzip2 (bz2) --# and lzma (xz) are optional. But bzip2 doesn't have a pkg-config file. --Requires.private: zlib @LIBLZMA@ -+# lzma (xz) and zstd () are optional. But bzip2 doesn't have a pkg-config file. -+Requires.private: zlib @LIBLZMA@ @LIBZSTD@ - Libs.private: @BZ2_LIB@ -diff --git a/configure.ac b/configure.ac -index bf833872..1b794df3 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -397,8 +397,8 @@ eu_ZIPLIB(zlib,ZLIB,z,gzdirect,gzip) - AS_IF([test "x$with_zlib" = xno], [AC_MSG_ERROR([zlib not found but is required])]) - LIBS="$save_LIBS" - --dnl Test for bzlib and xz/lzma, gives BZLIB/LZMALIB .am --dnl conditional and config.h USE_BZLIB/USE_LZMALIB #define. -+dnl Test for bzlib and xz/lzma/zstd, gives BZLIB/LZMALIB/ZSTD .am -+dnl conditional and config.h USE_BZLIB/USE_LZMALIB/USE_ZSTD #define. - save_LIBS="$LIBS" - LIBS= - eu_ZIPLIB(bzlib,BZLIB,bz2,BZ2_bzdopen,bzip2) -@@ -408,6 +408,9 @@ AC_SUBST([BZ2_LIB]) - eu_ZIPLIB(lzma,LZMA,lzma,lzma_auto_decoder,[LZMA (xz)]) - AS_IF([test "x$with_lzma" = xyes], [LIBLZMA="liblzma"], [LIBLZMA=""]) - AC_SUBST([LIBLZMA]) -+eu_ZIPLIB(zstd,ZSTD,zstd,ZSTD_decompress,[ZSTD (zst)]) -+AS_IF([test "x$with_zstd" = xyes], [LIBZSTD="libzstd"], [LIBLZSTD=""]) -+AC_SUBST([LIBZSTD]) - zip_LIBS="$LIBS" - LIBS="$save_LIBS" - AC_SUBST([zip_LIBS]) -@@ -677,6 +680,10 @@ if test "$HAVE_BUNZIP2" = "no"; then - AC_MSG_WARN([No bunzip2, needed to run make check]) - fi - -+# For tests that need to use zstd compression -+AC_CHECK_PROG(HAVE_ZSTD, zstd, yes, no) -+AM_CONDITIONAL([HAVE_ZSTD],[test "x$HAVE_ZSTD" = "xyes"]) -+ - # Look for libcurl for libdebuginfod minimum version as per rhel7. - AC_ARG_ENABLE([libdebuginfod],AC_HELP_STRING([--enable-libdebuginfod], [Build debuginfod client library (can be =dummy)])) - AS_IF([test "x$enable_libdebuginfod" != "xno"], [ -@@ -742,6 +749,7 @@ AC_MSG_NOTICE([ - gzip support : ${with_zlib} - bzip2 support : ${with_bzlib} - lzma/xz support : ${with_lzma} -+ zstd support : ${with_zstd} - libstdc++ demangle support : ${enable_demangler} - File textrel check : ${enable_textrelcheck} - Symbol versioning : ${enable_symbol_versioning} -@@ -759,6 +767,7 @@ AC_MSG_NOTICE([ - - EXTRA TEST FEATURES (used with make check) - have bunzip2 installed (required) : ${HAVE_BUNZIP2} -+ have zstd installed : ${HAVE_ZSTD} - debug branch prediction : ${use_debugpred} - gprof support : ${use_gprof} - gcov support : ${use_gcov} -diff --git a/libdwfl/Makefile.am b/libdwfl/Makefile.am -index 1de05492..a0013e41 100644 ---- a/libdwfl/Makefile.am -+++ b/libdwfl/Makefile.am -@@ -78,6 +78,9 @@ endif - if LZMA - libdwfl_a_SOURCES += lzma.c - endif -+if ZSTD -+libdwfl_a_SOURCES += zstd.c -+endif - if LIBDEBUGINFOD - libdwfl_a_SOURCES += debuginfod-client.c - endif -diff --git a/libdwfl/gzip.c b/libdwfl/gzip.c -index e9988cc2..ba8ecfba 100644 ---- a/libdwfl/gzip.c -+++ b/libdwfl/gzip.c -@@ -48,6 +48,12 @@ - # define inflateInit(z) lzma_auto_decoder (z, 1 << 30, 0) - # define do_inflate(z) lzma_code (z, LZMA_RUN) - # define inflateEnd(z) lzma_end (z) -+#elif defined ZSTD -+# define USE_INFLATE 1 -+# include -+# define unzip __libdw_unzstd -+# define DWFL_E_ZLIB DWFL_E_ZSTD -+# define MAGIC "\x28\xb5\x2f\xfd" - #elif defined BZLIB - # define USE_INFLATE 1 - # include -@@ -119,6 +125,7 @@ fail (struct unzip_state *state, Dwfl_Error failure) - return failure; - } - -+#ifndef ZSTD - static inline Dwfl_Error - zlib_fail (struct unzip_state *state, int result) - { -@@ -132,6 +139,7 @@ zlib_fail (struct unzip_state *state, int result) - return fail (state, DWFL_E_ZLIB); - } - } -+#endif - - #if !USE_INFLATE - static Dwfl_Error -@@ -197,7 +205,7 @@ unzip (int fd, off_t start_offset, - - ssize_t n = pread_retry (fd, state.input_buffer, READ_SIZE, start_offset); - if (unlikely (n < 0)) -- return zlib_fail (&state, Z (ERRNO)); -+ return fail (&state, DWFL_E_ERRNO); - - state.input_pos = n; - mapped = state.input_buffer; -@@ -223,7 +231,74 @@ unzip (int fd, off_t start_offset, - /* Not a compressed file. */ - return DWFL_E_BADELF; - --#if USE_INFLATE -+#ifdef ZSTD -+ /* special case for libzstd since it is slightly different from the -+ API provided by bzlib and liblzma. */ -+ -+ void *next_in = mapped; -+ size_t avail_in = state.mapped_size; -+ void *next_out = NULL; -+ size_t avail_out = 0; -+ size_t total_out = 0; -+ -+ size_t result; -+ ZSTD_DCtx *dctx = ZSTD_createDCtx(); -+ if (dctx == NULL) -+ return fail (&state, DWFL_E_NOMEM); -+ -+ do -+ { -+ if (avail_in == 0 && state.input_buffer != NULL) -+ { -+ ssize_t n = pread_retry (fd, state.input_buffer, READ_SIZE, -+ start_offset + state.input_pos); -+ if (unlikely (n < 0)) -+ { -+ ZSTD_freeDCtx (dctx); -+ return fail (&state, DWFL_E_ERRNO); -+ } -+ next_in = state.input_buffer; -+ avail_in = n; -+ state.input_pos += n; -+ } -+ if (avail_out == 0) -+ { -+ ptrdiff_t pos = (void *) next_out - state.buffer; -+ if (!bigger_buffer (&state, avail_in)) -+ { -+ ZSTD_freeDCtx (dctx); -+ return fail (&state, DWFL_E_NOMEM); -+ } -+ next_out = state.buffer + pos; -+ avail_out = state.size - pos; -+ } -+ -+ ZSTD_inBuffer input = { next_in, avail_in, 0 }; -+ ZSTD_outBuffer output = { next_out, avail_out, 0 }; -+ result = ZSTD_decompressStream (dctx, &output, &input); -+ -+ if (! ZSTD_isError (result)) -+ { -+ total_out += output.pos; -+ next_out += output.pos; -+ avail_out -= output.pos; -+ next_in += input.pos; -+ avail_in -= input.pos; -+ } -+ -+ if (result == 0) -+ break; -+ } -+ while (avail_in > 0 && ! ZSTD_isError (result)); -+ -+ ZSTD_freeDCtx (dctx); -+ -+ if (ZSTD_isError (result)) -+ return fail (&state, DWFL_E_ZSTD); -+ -+ smaller_buffer (&state, total_out); -+ -+#elif USE_INFLATE - - /* This style actually only works with bzlib and liblzma. - The stupid zlib interface has nothing to grok the -diff --git a/libdwfl/libdwflP.h b/libdwfl/libdwflP.h -index ad6779ad..4c6fcb28 100644 ---- a/libdwfl/libdwflP.h -+++ b/libdwfl/libdwflP.h -@@ -61,6 +61,7 @@ typedef struct Dwfl_Process Dwfl_Process; - DWFL_ERROR (ZLIB, N_("gzip decompression failed")) \ - DWFL_ERROR (BZLIB, N_("bzip2 decompression failed")) \ - DWFL_ERROR (LZMA, N_("LZMA decompression failed")) \ -+ DWFL_ERROR (ZSTD, N_("zstd decompression failed")) \ - DWFL_ERROR (UNKNOWN_MACHINE, N_("no support library found for machine")) \ - DWFL_ERROR (NOREL, N_("Callbacks missing for ET_REL file")) \ - DWFL_ERROR (BADRELTYPE, N_("Unsupported relocation type")) \ -@@ -612,6 +613,10 @@ extern Dwfl_Error __libdw_unlzma (int fd, off_t start_offset, - void *mapped, size_t mapped_size, - void **whole, size_t *whole_size) - internal_function; -+extern Dwfl_Error __libdw_unzstd (int fd, off_t start_offset, -+ void *mapped, size_t mapped_size, -+ void **whole, size_t *whole_size) -+ internal_function; - - /* Skip the image header before a file image: updates *START_OFFSET. */ - extern Dwfl_Error __libdw_image_header (int fd, off_t *start_offset, -diff --git a/libdwfl/open.c b/libdwfl/open.c -index 35fc5283..77bd2bd9 100644 ---- a/libdwfl/open.c -+++ b/libdwfl/open.c -@@ -44,6 +44,10 @@ - # define __libdw_unlzma(...) DWFL_E_BADELF - #endif - -+#if !USE_ZSTD -+# define __libdw_unzstd(...) DWFL_E_BADELF -+#endif -+ - /* Consumes and replaces *ELF only on success. */ - static Dwfl_Error - decompress (int fd __attribute__ ((unused)), Elf **elf) -@@ -64,6 +68,8 @@ decompress (int fd __attribute__ ((unused)), Elf **elf) - error = __libdw_bunzip2 (fd, offset, mapped, mapped_size, &buffer, &size); - if (error == DWFL_E_BADELF) - error = __libdw_unlzma (fd, offset, mapped, mapped_size, &buffer, &size); -+ if (error == DWFL_E_BADELF) -+ error = __libdw_unzstd (fd, offset, mapped, mapped_size, &buffer, &size); - - if (error == DWFL_E_NOERROR) - { -diff --git a/libdwfl/zstd.c b/libdwfl/zstd.c -new file mode 100644 -index 00000000..dc4d5238 ---- /dev/null -+++ b/libdwfl/zstd.c -@@ -0,0 +1,4 @@ -+/* libzstd is pretty close to zlib and bzlib. */ -+ -+#define ZSTD -+#include "gzip.c" -diff --git a/tests/Makefile.am b/tests/Makefile.am -index 4629ce64..9d0707da 100644 ---- a/tests/Makefile.am -+++ b/tests/Makefile.am -@@ -204,6 +204,10 @@ if LZMA - TESTS += run-readelf-s.sh run-dwflsyms.sh - endif - -+if HAVE_ZSTD -+TESTS += run-readelf-compressed-zstd.sh -+endif -+ - if HAVE_LIBASM - check_PROGRAMS += $(asm_TESTS) - TESTS += $(asm_TESTS) run-disasm-bpf.sh -@@ -256,6 +260,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \ - run-nm-syms.sh testfilesyms32.bz2 testfilesyms64.bz2 \ - run-nm-self.sh run-readelf-self.sh run-readelf-info-plus.sh \ - run-readelf-compressed.sh \ -+ run-readelf-compressed-zstd.sh \ - run-readelf-const-values.sh testfile-const-values.debug.bz2 \ - run-addrcfi.sh run-dwarfcfi.sh \ - testfile11-debugframe.bz2 testfile12-debugframe.bz2 \ -diff --git a/tests/run-readelf-compressed-zstd.sh b/tests/run-readelf-compressed-zstd.sh -new file mode 100755 -index 00000000..96208092 ---- /dev/null -+++ b/tests/run-readelf-compressed-zstd.sh -@@ -0,0 +1,39 @@ -+#! /bin/sh -+# Copyright (C) 2018 Red Hat, Inc. -+# This file is part of elfutils. -+# -+# This file is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3 of the License, or -+# (at your option) any later version. -+# -+# elfutils is distributed in the hope that it will be useful, but -+# WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+. $srcdir/test-subr.sh -+ -+if ! grep -q -F '#define USE_ZSTD' ${abs_top_builddir}/config.h; then -+ echo "elfutils built without zstd support" -+ exit 77 -+fi -+ -+# See run-strip-reloc.sh -+testfiles hello_i386.ko -+ -+tempfiles hello_i386.ko.zst readelf.out.1 readelf.out.2 -+ -+testrun ${abs_top_builddir}/src/readelf -a hello_i386.ko > readelf.out.1 -+zstd hello_i386.ko -+testrun ${abs_top_builddir}/src/readelf -a hello_i386.ko.zst > readelf.out.2 -+ -+diff -u readelf.out.1 readelf.out.2 -+if [ $? != 0 ]; then -+ exit 1; -+fi -+ -+exit 0 diff --git a/elfutils.spec b/elfutils.spec index 0ad6e76..21264cb 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -1,6 +1,6 @@ Name: elfutils -Version: 0.181 -%global baserelease 3 +Version: 0.182 +%global baserelease 1 Release: %{baserelease}%{?dist} URL: http://elfutils.org/ %global source_url ftp://sourceware.org/pub/elfutils/%{version}/ @@ -60,8 +60,6 @@ BuildRequires: autoconf %endif # Patches -Patch1: elfutils-0.181-zstd.patch -Patch2: elfutils-0.181-array-param.patch %description Elfutils is a collection of utilities, including stack (to show @@ -253,8 +251,6 @@ such servers to download those files on demand. %setup -q # Apply patches -%patch1 -p1 -b .zstd -%patch2 -p1 -b .array_param autoreconf -f -v -i @@ -291,6 +287,10 @@ rm -rf ${RPM_BUILD_ROOT} chmod +x ${RPM_BUILD_ROOT}%{_prefix}/%{_lib}/lib*.so* +# We don't have standard DEBUGINFOD_URLS yet. +rm ${RPM_BUILD_ROOT}%{_sysconfdir}/profile.d/debuginfod.sh +rm ${RPM_BUILD_ROOT}%{_sysconfdir}/profile.d/debuginfod.csh + %find_lang %{name} %if %{provide_yama_scope} @@ -420,12 +420,13 @@ fi %files debuginfod %defattr(-,root,root) %{_bindir}/debuginfod -%config(noreplace) %verify(not md5 size mtime) %{_sysconfdir}/sysconfig/debuginfod +%config(noreplace) %{_sysconfdir}/sysconfig/debuginfod %{_unitdir}/debuginfod.service +%{_sysconfdir}/sysconfig/debuginfod %{_mandir}/man8/debuginfod.8* %dir %attr(0700,debuginfod,debuginfod) %{_localstatedir}/cache/debuginfod -%verify(not md5 size mtime) %attr(0600,debuginfod,debuginfod) %{_localstatedir}/cache/debuginfod/debuginfod.sqlite +%ghost %attr(0600,debuginfod,debuginfod) %{_localstatedir}/cache/debuginfod/debuginfod.sqlite %pre debuginfod getent group debuginfod >/dev/null || groupadd -r debuginfod @@ -441,6 +442,16 @@ exit 0 %systemd_postun_with_restart debuginfod.service %changelog +* Sat Oct 31 2020 Mark Wielaard - 0.182-1 +- Upgrade to upstream 0.182 + - backends: Support for tilegx has been removed. + - config: New /etc/profile.d files to provide default $DEBUGINFOD_URLS. + - debuginfod: More efficient package traversal, tolerate various + errors during scanning, grooming progress is more visible and + interruptible, more prometheus metrics. + - debuginfod-client: Now supports compressed (kernel) ELF images. + - libdwfl: Add ZSTD compression support. + * Mon Oct 19 2020 Mark Wielaard - 0.181-3 - Add elfutils-0.181-array-param.patch. diff --git a/sources b/sources index b0e26f0..8697cd9 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (elfutils-0.181.tar.bz2) = d565541d5817f409dc89ebb1ee593366f69c371a1531308eeb67ff934b14a0fab0c9009fd7c23240efbaa1b4e04edac5c425e47d80e3e66ba03dcaf000afea36 +SHA512 (elfutils-0.182.tar.bz2) = 8ab0735bbe11b4383169341bf674ace360038b6ae5239f1d5a991c46260cd4bce545e078735b7de3b8fab132bb5da41f60689ff1b1d7ebccfada117a954a2c81 From f263218747bd33af6f6cf4d00f704beabdf7f5c1 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 17 Dec 2020 04:59:39 +0000 Subject: [PATCH 12/15] Add BuildRequires: make https://fedoraproject.org/wiki/Changes/Remove_make_from_BuildRoot --- elfutils.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/elfutils.spec b/elfutils.spec index 21264cb..9125d47 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -223,6 +223,7 @@ Requires: elfutils-libs%{depsuffix} = %{version}-%{release} Requires: elfutils-libelf%{depsuffix} = %{version}-%{release} Requires: elfutils-debuginfod-client%{depsuffix} = %{version}-%{release} BuildRequires: systemd +BuildRequires: make Requires(post): systemd Requires(preun): systemd Requires(postun): systemd From 181f2d742f7280264b0f9234fd9e121dfcc5d071 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 17 Dec 2020 13:04:32 +0100 Subject: [PATCH 13/15] 0.182-2 - Add elfutils-0.182-s390-pid_memory_read.patch --- elfutils-0.182-s390-pid_memory_read.patch | 39 +++++++++++++++++++++++ elfutils.spec | 7 +++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 elfutils-0.182-s390-pid_memory_read.patch diff --git a/elfutils-0.182-s390-pid_memory_read.patch b/elfutils-0.182-s390-pid_memory_read.patch new file mode 100644 index 0000000..2c056cb --- /dev/null +++ b/elfutils-0.182-s390-pid_memory_read.patch @@ -0,0 +1,39 @@ +commit e4d985a3c1c873f77d20fa0cd421458cc2824996 +Author: Andreas Krebbel +Date: Thu Nov 19 20:32:24 2020 +0100 + + IBM Z: Fix endianess problem in pid_memory_read + + The cached reads lack the big endian adjustments done in the fallback + path. + + Signed-off-by: Andreas Krebbel + +diff --git a/libdwfl/linux-pid-attach.c b/libdwfl/linux-pid-attach.c +index 3a6af997..b23139d9 100644 +--- a/libdwfl/linux-pid-attach.c ++++ b/libdwfl/linux-pid-attach.c +@@ -193,14 +193,22 @@ pid_memory_read (Dwfl *dwfl, Dwarf_Addr addr, Dwarf_Word *result, void *arg) + { + struct __libdwfl_pid_arg *pid_arg = arg; + pid_t tid = pid_arg->tid_attached; ++ Dwfl_Process *process = dwfl->process; + assert (tid > 0); + + #ifdef HAVE_PROCESS_VM_READV + if (read_cached_memory (pid_arg, addr, result)) ++ { ++#if SIZEOF_LONG == 8 ++# if BYTE_ORDER == BIG_ENDIAN ++ if (ebl_get_elfclass (process->ebl) == ELFCLASS32) ++ *result >>= 32; ++# endif ++#endif + return true; ++ } + #endif + +- Dwfl_Process *process = dwfl->process; + if (ebl_get_elfclass (process->ebl) == ELFCLASS64) + { + #if SIZEOF_LONG == 8 diff --git a/elfutils.spec b/elfutils.spec index 9125d47..3ca84eb 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -1,6 +1,6 @@ Name: elfutils Version: 0.182 -%global baserelease 1 +%global baserelease 2 Release: %{baserelease}%{?dist} URL: http://elfutils.org/ %global source_url ftp://sourceware.org/pub/elfutils/%{version}/ @@ -60,6 +60,7 @@ BuildRequires: autoconf %endif # Patches +Patch1: elfutils-0.182-s390-pid_memory_read.patch %description Elfutils is a collection of utilities, including stack (to show @@ -252,6 +253,7 @@ such servers to download those files on demand. %setup -q # Apply patches +%patch1 -p1 autoreconf -f -v -i @@ -443,6 +445,9 @@ exit 0 %systemd_postun_with_restart debuginfod.service %changelog +* Thu Dec 17 2020 Mark Wielaard - 0.182-2 +- Add elfutils-0.182-s390-pid_memory_read.patch + * Sat Oct 31 2020 Mark Wielaard - 0.182-1 - Upgrade to upstream 0.182 - backends: Support for tilegx has been removed. From 51d4df2439217fabc8403fbcaa8871adfdb38e9d Mon Sep 17 00:00:00 2001 From: Robert Scheck Date: Thu, 24 Dec 2020 09:56:13 +0000 Subject: [PATCH 14/15] Spec file cleanup Remove old stuff no longer needed on all active branches --- elfutils.spec | 7 ------- 1 file changed, 7 deletions(-) diff --git a/elfutils.spec b/elfutils.spec index 3ca84eb..a02270d 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -285,7 +285,6 @@ trap '' EXIT %make_build -s %install -rm -rf ${RPM_BUILD_ROOT} %make_install -s chmod +x ${RPM_BUILD_ROOT}%{_prefix}/%{_lib}/lib*.so* @@ -336,7 +335,6 @@ fi %endif %files -%{!?_licensedir:%global license %%doc} %license COPYING COPYING-GPLV2 COPYING-LGPLV3 doc/COPYING-GFDL %doc README TODO CONTRIBUTING %{_bindir}/eu-addr2line @@ -359,7 +357,6 @@ fi %{_mandir}/man1/eu-*.1* %files libs -%{!?_licensedir:%global license %%doc} %license COPYING-GPLV2 COPYING-LGPLV3 %{_libdir}/libasm-%{version}.so %{_libdir}/libdw-%{version}.so @@ -385,7 +382,6 @@ fi %{_libdir}/libasm.a %files -f %{name}.lang libelf -%{!?_licensedir:%global license %%doc} %license COPYING-GPLV2 COPYING-LGPLV3 %{_libdir}/libelf-%{version}.so %{_libdir}/libelf.so.* @@ -407,21 +403,18 @@ fi %endif %files debuginfod-client -%defattr(-,root,root) %{_libdir}/libdebuginfod-%{version}.so %{_libdir}/libdebuginfod.so.* %{_bindir}/debuginfod-find %{_mandir}/man1/debuginfod-find.1* %files debuginfod-client-devel -%defattr(-,root,root) %{_libdir}/pkgconfig/libdebuginfod.pc %{_mandir}/man3/debuginfod_*.3* %{_includedir}/elfutils/debuginfod.h %{_libdir}/libdebuginfod.so %files debuginfod -%defattr(-,root,root) %{_bindir}/debuginfod %config(noreplace) %{_sysconfdir}/sysconfig/debuginfod %{_unitdir}/debuginfod.service From c147a763a283ac72359a9aea5c01a472b34e8495 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sun, 7 Feb 2021 20:39:39 +0100 Subject: [PATCH 15/15] 0.183-1 - Upgrade to upstream 0.183 --- .gitignore | 1 + elfutils-0.182-s390-pid_memory_read.patch | 39 ----------------------- elfutils.spec | 20 +++++++++--- sources | 2 +- 4 files changed, 18 insertions(+), 44 deletions(-) delete mode 100644 elfutils-0.182-s390-pid_memory_read.patch diff --git a/.gitignore b/.gitignore index d0ad04a..710bb51 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ /elfutils-0.180.tar.bz2 /elfutils-0.181.tar.bz2 /elfutils-0.182.tar.bz2 +/elfutils-0.183.tar.bz2 diff --git a/elfutils-0.182-s390-pid_memory_read.patch b/elfutils-0.182-s390-pid_memory_read.patch deleted file mode 100644 index 2c056cb..0000000 --- a/elfutils-0.182-s390-pid_memory_read.patch +++ /dev/null @@ -1,39 +0,0 @@ -commit e4d985a3c1c873f77d20fa0cd421458cc2824996 -Author: Andreas Krebbel -Date: Thu Nov 19 20:32:24 2020 +0100 - - IBM Z: Fix endianess problem in pid_memory_read - - The cached reads lack the big endian adjustments done in the fallback - path. - - Signed-off-by: Andreas Krebbel - -diff --git a/libdwfl/linux-pid-attach.c b/libdwfl/linux-pid-attach.c -index 3a6af997..b23139d9 100644 ---- a/libdwfl/linux-pid-attach.c -+++ b/libdwfl/linux-pid-attach.c -@@ -193,14 +193,22 @@ pid_memory_read (Dwfl *dwfl, Dwarf_Addr addr, Dwarf_Word *result, void *arg) - { - struct __libdwfl_pid_arg *pid_arg = arg; - pid_t tid = pid_arg->tid_attached; -+ Dwfl_Process *process = dwfl->process; - assert (tid > 0); - - #ifdef HAVE_PROCESS_VM_READV - if (read_cached_memory (pid_arg, addr, result)) -+ { -+#if SIZEOF_LONG == 8 -+# if BYTE_ORDER == BIG_ENDIAN -+ if (ebl_get_elfclass (process->ebl) == ELFCLASS32) -+ *result >>= 32; -+# endif -+#endif - return true; -+ } - #endif - -- Dwfl_Process *process = dwfl->process; - if (ebl_get_elfclass (process->ebl) == ELFCLASS64) - { - #if SIZEOF_LONG == 8 diff --git a/elfutils.spec b/elfutils.spec index a02270d..e3acdf7 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -1,6 +1,6 @@ Name: elfutils -Version: 0.182 -%global baserelease 2 +Version: 0.183 +%global baserelease 1 Release: %{baserelease}%{?dist} URL: http://elfutils.org/ %global source_url ftp://sourceware.org/pub/elfutils/%{version}/ @@ -49,6 +49,7 @@ BuildRequires: curl BuildRequires: automake BuildRequires: autoconf +BuildRequires: gettext-devel %global _gnu %{nil} %global _program_prefix eu- @@ -60,7 +61,6 @@ BuildRequires: autoconf %endif # Patches -Patch1: elfutils-0.182-s390-pid_memory_read.patch %description Elfutils is a collection of utilities, including stack (to show @@ -253,7 +253,6 @@ such servers to download those files on demand. %setup -q # Apply patches -%patch1 -p1 autoreconf -f -v -i @@ -438,6 +437,19 @@ exit 0 %systemd_postun_with_restart debuginfod.service %changelog +* Mon Feb 8 2021 Mark Wielaard - 0.183-1 +- Upgrade to upstream 0.183 + - debuginfod: New thread-busy metric and more detailed error metrics. + New --fdcache-mintmp and tracking of filesystem freespace. + - debuginfod-client: DEBUGINFOD_SONAME macro added to debuginfod.h can + be used to dlopen the libdebuginfod.so library. + New function debuginfod_set_verbose_fd and DEBUGINFOD_VERBOSE + environment variable. + - config: profile.sh and profile.csh won't export DEBUGINFOD_URLS + unless configured --enable-debuginfod-urls[=URLS] + - elflint, readelf: Recognize SHF_GNU_RETAIN. + Handle SHT_X86_64_UNWIND as valid relocation target type. + * Thu Dec 17 2020 Mark Wielaard - 0.182-2 - Add elfutils-0.182-s390-pid_memory_read.patch diff --git a/sources b/sources index 8697cd9..9e0e03d 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (elfutils-0.182.tar.bz2) = 8ab0735bbe11b4383169341bf674ace360038b6ae5239f1d5a991c46260cd4bce545e078735b7de3b8fab132bb5da41f60689ff1b1d7ebccfada117a954a2c81 +SHA512 (elfutils-0.183.tar.bz2) = bdafdd738a33cebe4f87849e5e6f1133881e77ef71b27faa0f0234ff80e9674f506957898326c2a55fd8438cbd189f7930597d0b4b9ca6c77921cc0cbd83b6b7