diff --git a/.elfutils.metadata b/.elfutils.metadata index 3ee22bb..4e09f27 100644 --- a/.elfutils.metadata +++ b/.elfutils.metadata @@ -1 +1 @@ -6511203cae7225ae780501834a7ccd234b14889a SOURCES/elfutils-0.176.tar.bz2 +5f52d04105a89e50caf69cea40629c323c1eccd9 SOURCES/elfutils-0.178.tar.bz2 diff --git a/.gitignore b/.gitignore index 89b10d7..259576d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/elfutils-0.176.tar.bz2 +SOURCES/elfutils-0.178.tar.bz2 diff --git a/SOURCES/elfutils-0.176-elf-update.patch b/SOURCES/elfutils-0.176-elf-update.patch deleted file mode 100644 index 501c103..0000000 --- a/SOURCES/elfutils-0.176-elf-update.patch +++ /dev/null @@ -1,664 +0,0 @@ -commit d7193bd7c9dc2a979352eee7fc446dacd3e97779 -Author: Mark Wielaard -Date: Sun May 12 00:37:45 2019 +0200 - - libelf: Mark shdr_flags dirty if offset or size changes during update. - - We forgot to mark the shdr_flags dirty when only the sh_size or - sh_offset changed during elf_update (). This meant that if there were - no other shdr changes we only wrote out the section data, but didn't - write out the shdr table to the file. - - Add a testcase that puts some sections in the reverse order and then - writes out the resulting file again without doing any other - updates. This would show the issue after write out of the - (re-reversed) ELF file (the .shstrtab section offset would be wrong - causing all section names to be garbage). Also run a self test. - - Signed-off-by: Mark Wielaard - -diff --git a/libelf/elf32_updatenull.c b/libelf/elf32_updatenull.c -index 2ce6a59..303055a 100644 ---- a/libelf/elf32_updatenull.c -+++ b/libelf/elf32_updatenull.c -@@ -366,12 +366,15 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int *change_bop, size_t shnum) - } - - /* See whether the section size is correct. */ -+ int size_changed = 0; - update_if_changed (shdr->sh_size, (GElf_Word) offset, -- changed); -+ size_changed); -+ changed |= size_changed; - - if (shdr->sh_type != SHT_NOBITS) - size += offset; - -+ scn->shdr_flags |= (offset_changed | size_changed); - scn->flags |= changed; - } - -diff --git a/tests/Makefile.am b/tests/Makefile.am -index 80900e4..87428aa 100644 ---- a/tests/Makefile.am -+++ b/tests/Makefile.am -@@ -60,7 +60,7 @@ check_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \ - fillfile dwarf_default_lower_bound dwarf-die-addr-die \ - get-units-invalid get-units-split attr-integrate-skel \ - all-dwarf-ranges unit-info next_cfi \ -- elfcopy addsections xlate_notes -+ elfcopy addsections xlate_notes elfrdwrnop - - asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \ - asm-tst6 asm-tst7 asm-tst8 asm-tst9 -@@ -157,6 +157,7 @@ TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \ - run-all-dwarf-ranges.sh run-unit-info.sh \ - run-reloc-bpf.sh \ - run-next-cfi.sh run-next-cfi-self.sh \ -+ run-reverse-sections.sh run-reverse-sections-self.sh \ - run-copyadd-sections.sh run-copymany-sections.sh \ - run-typeiter-many.sh run-strip-test-many.sh \ - run-strip-version.sh run-xlate-note.sh -@@ -419,6 +420,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \ - run-unit-info.sh run-next-cfi.sh run-next-cfi-self.sh \ - testfile-riscv64.bz2 testfile-riscv64-s.bz2 \ - testfile-riscv64-core.bz2 \ -+ run-reverse-sections.sh run-reverse-sections-self.sh \ - run-copyadd-sections.sh run-copymany-sections.sh \ - run-typeiter-many.sh run-strip-test-many.sh \ - testfile-debug-rel-ppc64-g.o.bz2 \ -@@ -598,6 +600,7 @@ next_cfi_LDADD = $(libelf) $(libdw) - elfcopy_LDADD = $(libelf) - addsections_LDADD = $(libelf) - xlate_notes_LDADD = $(libelf) -+elfrdwrnop_LDADD = $(libelf) - - # We want to test the libelf header against the system elf.h header. - # Don't include any -I CPPFLAGS. Except when we install our own elf.h. -diff --git a/tests/elfcopy.c b/tests/elfcopy.c -index 9000cc9..d457bad 100644 ---- a/tests/elfcopy.c -+++ b/tests/elfcopy.c -@@ -69,9 +69,11 @@ setshstrndx (Elf *elf, size_t ndx) - - /* Copies all elements of an ELF file either using mmap or read. */ - static void --copy_elf (const char *in, const char *out, bool use_mmap) -+copy_elf (const char *in, const char *out, bool use_mmap, bool reverse_offs) - { -- printf ("\ncopy_elf: %s -> %s (%s)\n", in, out, use_mmap ? "mmap" : "read"); -+ printf ("\ncopy_elf: %s -> %s (%s,%s)\n", in, out, -+ use_mmap ? "mmap" : "read", -+ reverse_offs ? "reverse" : "same"); - - /* Existing ELF file. */ - int fda = open (in, O_RDONLY); -@@ -182,8 +184,28 @@ copy_elf (const char *in, const char *out, bool use_mmap) - } - } - -+ GElf_Off *offs = NULL; -+ size_t shnum; -+ if (reverse_offs) -+ { -+ if (elf_getshdrnum (elfa, &shnum) < 0) -+ { -+ printf ("couldn't get shdrnum: %s\n", elf_errmsg (-1)); -+ exit (1); -+ } -+ -+ offs = (GElf_Off *) malloc (shnum * sizeof (GElf_Off)); -+ if (offs == NULL) -+ { -+ printf ("couldn't allocate memory for offs\n"); -+ exit (1); -+ } -+ } -+ - /* Copy all sections, headers and data. */ - Elf_Scn *scn = NULL; -+ size_t last_off = 0; -+ GElf_Shdr last_shdr = { .sh_type = SHT_NULL }; - while ((scn = elf_nextscn (elfa, scn)) != NULL) - { - /* Get the header. */ -@@ -194,6 +216,34 @@ copy_elf (const char *in, const char *out, bool use_mmap) - exit (1); - } - -+ if (reverse_offs) -+ { -+ offs[last_off] = shdr.sh_offset; -+ -+ if (last_shdr.sh_type != SHT_NULL -+ && last_shdr.sh_addralign == shdr.sh_addralign -+ && shdr.sh_addralign == 1 -+ && last_shdr.sh_type != SHT_NOBITS -+ && shdr.sh_type != SHT_NOBITS -+ && (phnum == 0 -+ || ((shdr.sh_flags & SHF_ALLOC) == 0 -+ && (last_shdr.sh_flags & SHF_ALLOC) == 0))) -+ { -+ printf ("Swapping offsets of section %zd and %zd\n", -+ last_off, last_off + 1); -+ GElf_Word off = offs[last_off - 1]; -+ offs[last_off - 1] = off + shdr.sh_size; -+ offs[last_off] = off; -+ last_shdr.sh_type = SHT_NULL; -+ } -+ else -+ { -+ last_shdr = shdr; -+ offs[last_off] = shdr.sh_offset; -+ } -+ last_off++; -+ } -+ - /* Create new section. */ - Elf_Scn *new_scn = elf_newscn (elfb); - if (new_scn == NULL) -@@ -223,9 +273,34 @@ copy_elf (const char *in, const char *out, bool use_mmap) - } - } - -- /* Write everything to disk. If there are any phdrs then we want -- the exact same layout. Do we want ELF_F_PERMISSIVE? */ -- if (phnum > 0) -+ if (reverse_offs) -+ { -+ last_off = 0; -+ scn = NULL; -+ while ((scn = elf_nextscn (elfb, scn)) != NULL) -+ { -+ GElf_Shdr shdr; -+ if (gelf_getshdr (scn, &shdr) == NULL) -+ { -+ printf ("couldn't get shdr for updating: %s\n", elf_errmsg (-1)); -+ exit (1); -+ } -+ -+ shdr.sh_offset = offs[last_off++]; -+ -+ if (gelf_update_shdr (scn, &shdr) == 0) -+ { -+ printf ("couldn't update shdr sh_off: %s\n", elf_errmsg (-1)); -+ exit (1); -+ } -+ } -+ free (offs); -+ } -+ -+ /* Write everything to disk. If there are any phdrs, or we want to -+ update the offsets, then we want the exact same layout. Do we -+ want ELF_F_PERMISSIVE? */ -+ if (phnum > 0 || reverse_offs) - elf_flagelf (elfb, ELF_C_SET, ELF_F_LAYOUT); - if (elf_update (elfb, ELF_C_WRITE) < 0) - { -@@ -264,9 +339,9 @@ main (int argc, const char *argv[]) - elf_version (EV_CURRENT); - - /* Takes the given file, and create a new identical one. */ -- if (argc < 3 || argc > 4) -+ if (argc < 3 || argc > 5) - { -- fprintf (stderr, "elfcopy [--mmap] in.elf out.elf\n"); -+ fprintf (stderr, "elfcopy [--mmap] [--reverse-offs] in.elf out.elf\n"); - exit (1); - } - -@@ -278,9 +353,16 @@ main (int argc, const char *argv[]) - argn++; - } - -+ bool reverse_offs = false; -+ if (strcmp (argv[argn], "--reverse-offs") == 0) -+ { -+ reverse_offs = true; -+ argn++; -+ } -+ - const char *in = argv[argn++]; - const char *out = argv[argn]; -- copy_elf (in, out, use_mmap); -+ copy_elf (in, out, use_mmap, reverse_offs); - - return 0; - } -diff --git a/tests/elfrdwrnop.c b/tests/elfrdwrnop.c -new file mode 100644 -index 0000000..997150b ---- /dev/null -+++ b/tests/elfrdwrnop.c -@@ -0,0 +1,100 @@ -+/* Test program for reading and writing out the same file in-place -+ Copyright (C) 2019 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 . */ -+ -+ -+#ifdef HAVE_CONFIG_H -+# include -+#endif -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include ELFUTILS_HEADER(elf) -+#include -+ -+ -+int -+main (int argc, const char *argv[]) -+{ -+ /* Takes the given file, and create a new identical one. */ -+ if (argc != 2) -+ { -+ fprintf (stderr, "elfrdwrnop elf-file\n"); -+ exit (1); -+ } -+ -+ elf_version (EV_CURRENT); -+ -+ const char *name = argv[1]; -+ printf ("elfrdwrdnop %s\n", name); -+ -+ int fd = open (name, O_RDWR); -+ if (fd < 0) -+ { -+ fprintf (stderr, "Couldn't open file '%s': %s\n", -+ name, strerror (errno)); -+ exit (1); -+ } -+ -+ Elf *elf = elf_begin (fd, ELF_C_RDWR, NULL); -+ if (elf == NULL) -+ { -+ fprintf (stderr, "Couldn't open ELF file '%s': %s\n", -+ name, elf_errmsg (-1)); -+ exit (1); -+ } -+ -+ /* Write everything to disk. If there are any phdrs, then we want -+ the exact same layout. */ -+ size_t phnum; -+ if (elf_getphdrnum (elf, &phnum) != 0) -+ { -+ printf ("cannot get phdrs: %s\n", elf_errmsg (-1)); -+ exit (1); -+ } -+ -+ if (phnum > 0) -+ elf_flagelf (elf, ELF_C_SET, ELF_F_LAYOUT); -+ -+ if (elf_update (elf, ELF_C_WRITE) < 0) -+ { -+ printf ("failure in elf_update: %s\n", elf_errmsg (-1)); -+ exit (1); -+ } -+ -+ if (elf_end (elf) != 0) -+ { -+ printf ("couldn't cleanup elf '%s': %s\n", name, elf_errmsg (-1)); -+ exit (1); -+ } -+ -+ if (close (fd) != 0) -+ { -+ printf ("couldn't close '%s': %s\n", name, strerror (errno)); -+ exit (1); -+ } -+ -+ return 0; -+} -diff --git a/tests/run-reverse-sections-self.sh b/tests/run-reverse-sections-self.sh -new file mode 100755 -index 0000000..71afd6a ---- /dev/null -+++ b/tests/run-reverse-sections-self.sh -@@ -0,0 +1,45 @@ -+#! /bin/sh -+# Copyright (C) 2019 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 -+ -+test_reverse_self () -+{ -+ in_file="$1" -+ base_name="$(basename ${in_file})" -+ out_file="${base_name}.rev" -+ out_file_mmap="${out_file}.mmap" -+ -+ tempfiles ${out_file} ${out_file_mmap} -+ -+ # Reverse the offsets (the files should still be the same otherwise) -+ testrun ${abs_builddir}/elfcopy --reverse-offs ${in_file} ${out_file} -+ testrun ${abs_top_builddir}/src/elfcmp ${in_file} ${out_file} -+ testrun ${abs_top_builddir}/src/elflint --gnu ${out_file} -+ # An in-place nop will likely revert them back -+ testrun ${abs_builddir}/elfrdwrnop ${out_file} -+ testrun ${abs_top_builddir}/src/elfcmp ${in_file} ${out_file} -+ testrun ${abs_top_builddir}/src/elflint --gnu ${out_file} -+} -+ -+# Only really makes sense for ET_REL files, but try all, just to check -+# it also works if we keep the order for the allocated sections. -+for file in $self_test_files; do -+ test_reverse_self $file -+done -+ -+exit 0 -diff --git a/tests/run-reverse-sections.sh b/tests/run-reverse-sections.sh -new file mode 100755 -index 0000000..102a126 ---- /dev/null -+++ b/tests/run-reverse-sections.sh -@@ -0,0 +1,69 @@ -+#! /bin/sh -+# Copyright (C) 2019 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 -+ -+test_reverse () -+{ -+ in_file="$1" -+ out_file="${in_file}.rev" -+ out_file_mmap="${out_file}.mmap" -+ -+ testfiles ${in_file} -+ tempfiles ${out_file} ${out_file_mmap} -+ -+ # Reverse the offsets (the files should still be the same otherwise) -+ testrun ${abs_builddir}/elfcopy --reverse-offs ${in_file} ${out_file} -+ testrun ${abs_top_builddir}/src/elfcmp ${in_file} ${out_file} -+ testrun ${abs_top_builddir}/src/elflint --gnu ${out_file} -+ # An in-place nop will likely revert them back -+ testrun ${abs_builddir}/elfrdwrnop ${out_file} -+ testrun ${abs_top_builddir}/src/elfcmp ${in_file} ${out_file} -+ testrun ${abs_top_builddir}/src/elflint --gnu ${out_file} -+} -+ -+# A collection of random testfiles to test 32/64bit, little/big endian -+# and non-ET_REL (with phdrs)/ET_REL (without phdrs). -+ -+# 32bit, big endian, rel -+test_reverse testfile29 -+ -+# 64bit, big endian, rel -+test_reverse testfile23 -+ -+# 32bit, little endian, rel -+test_reverse testfile9 -+ -+# 64bit, little endian, rel -+test_reverse testfile38 -+ -+# 32bit, big endian, non-rel -+test_reverse testfile26 -+ -+# 64bit, big endian, non-rel -+test_reverse testfile27 -+ -+# 32bit, little endian, non-rel -+test_reverse testfile -+ -+# 64bit, little endian, non-rel -+# Don't use testfile10. It has section headers in the middle of the file. -+# Same for testfile12. It is legal, but not the point of this testcase. -+# test_reverse testfile10 -+test_reverse testfile13 -+ -+exit 0 -diff -ru elfutils-0.176.orig/tests/Makefile.in elfutils-0.176/tests/Makefile.in ---- elfutils-0.176.orig/tests/Makefile.in 2019-06-03 14:57:17.223607024 +0200 -+++ elfutils-0.176/tests/Makefile.in 2019-06-03 14:58:32.671049626 +0200 -@@ -131,8 +131,8 @@ - get-units-invalid$(EXEEXT) get-units-split$(EXEEXT) \ - attr-integrate-skel$(EXEEXT) all-dwarf-ranges$(EXEEXT) \ - unit-info$(EXEEXT) next_cfi$(EXEEXT) elfcopy$(EXEEXT) \ -- addsections$(EXEEXT) xlate_notes$(EXEEXT) $(am__EXEEXT_1) \ -- $(am__EXEEXT_2) $(am__EXEEXT_4) -+ addsections$(EXEEXT) xlate_notes$(EXEEXT) elfrdwrnop$(EXEEXT) \ -+ $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_4) - @BIARCH_TRUE@am__append_5 = backtrace-child-biarch - TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile$(EXEEXT) \ - test-nlist$(EXEEXT) update1$(EXEEXT) update2$(EXEEXT) \ -@@ -209,7 +209,8 @@ - run-get-units-invalid.sh run-get-units-split.sh \ - run-attr-integrate-skel.sh run-all-dwarf-ranges.sh \ - run-unit-info.sh run-reloc-bpf.sh run-next-cfi.sh \ -- run-next-cfi-self.sh run-copyadd-sections.sh \ -+ run-next-cfi-self.sh run-reverse-sections.sh \ -+ run-reverse-sections-self.sh run-copyadd-sections.sh \ - run-copymany-sections.sh run-typeiter-many.sh \ - run-strip-test-many.sh run-strip-version.sh run-xlate-note.sh \ - $(am__EXEEXT_2) $(am__append_8) $(am__EXEEXT_5) -@@ -451,6 +452,9 @@ - elfputzdata_SOURCES = elfputzdata.c - elfputzdata_OBJECTS = elfputzdata.$(OBJEXT) - elfputzdata_DEPENDENCIES = $(am__DEPENDENCIES_2) -+elfrdwrnop_SOURCES = elfrdwrnop.c -+elfrdwrnop_OBJECTS = elfrdwrnop.$(OBJEXT) -+elfrdwrnop_DEPENDENCIES = $(am__DEPENDENCIES_2) - elfshphehdr_SOURCES = elfshphehdr.c - elfshphehdr_OBJECTS = elfshphehdr.$(OBJEXT) - elfshphehdr_DEPENDENCIES = $(am__DEPENDENCIES_2) -@@ -660,13 +664,13 @@ - ./$(DEPDIR)/early-offscn.Po ./$(DEPDIR)/ecp.Po \ - ./$(DEPDIR)/elfcopy.Po ./$(DEPDIR)/elfgetchdr.Po \ - ./$(DEPDIR)/elfgetzdata.Po ./$(DEPDIR)/elfputzdata.Po \ -- ./$(DEPDIR)/elfshphehdr.Po ./$(DEPDIR)/elfstrmerge.Po \ -- ./$(DEPDIR)/elfstrtab.Po ./$(DEPDIR)/emptyfile.Po \ -- ./$(DEPDIR)/fillfile.Po ./$(DEPDIR)/find-prologues.Po \ -- ./$(DEPDIR)/funcretval.Po ./$(DEPDIR)/funcscopes.Po \ -- ./$(DEPDIR)/get-aranges.Po ./$(DEPDIR)/get-files.Po \ -- ./$(DEPDIR)/get-lines.Po ./$(DEPDIR)/get-pubnames.Po \ -- ./$(DEPDIR)/get-units-invalid.Po \ -+ ./$(DEPDIR)/elfrdwrnop.Po ./$(DEPDIR)/elfshphehdr.Po \ -+ ./$(DEPDIR)/elfstrmerge.Po ./$(DEPDIR)/elfstrtab.Po \ -+ ./$(DEPDIR)/emptyfile.Po ./$(DEPDIR)/fillfile.Po \ -+ ./$(DEPDIR)/find-prologues.Po ./$(DEPDIR)/funcretval.Po \ -+ ./$(DEPDIR)/funcscopes.Po ./$(DEPDIR)/get-aranges.Po \ -+ ./$(DEPDIR)/get-files.Po ./$(DEPDIR)/get-lines.Po \ -+ ./$(DEPDIR)/get-pubnames.Po ./$(DEPDIR)/get-units-invalid.Po \ - ./$(DEPDIR)/get-units-split.Po ./$(DEPDIR)/getsrc_die.Po \ - ./$(DEPDIR)/hash.Po ./$(DEPDIR)/line2addr.Po \ - ./$(DEPDIR)/low_high_pc.Po ./$(DEPDIR)/msg_tst.Po \ -@@ -718,19 +722,19 @@ - dwfl-bug-getmodules.c dwfl-bug-report.c dwfl-proc-attach.c \ - dwfl-report-elf-align.c dwfllines.c dwflmodtest.c dwflsyms.c \ - early-offscn.c ecp.c elfcopy.c elfgetchdr.c elfgetzdata.c \ -- elfputzdata.c elfshphehdr.c elfstrmerge.c elfstrtab.c \ -- emptyfile.c fillfile.c find-prologues.c funcretval.c \ -- funcscopes.c get-aranges.c get-files.c get-lines.c \ -- get-pubnames.c get-units-invalid.c get-units-split.c \ -- getsrc_die.c hash.c line2addr.c low_high_pc.c msg_tst.c \ -- newdata.c newfile.c newscn.c next-files.c next-lines.c \ -- next_cfi.c peel_type.c rdwrmmap.c rerequest_tag.c saridx.c \ -- scnnames.c sectiondump.c show-abbrev.c show-die-info.c \ -- showptable.c strptr.c system-elf-libelf-test.c \ -- test-elf_cntl_gelf_getshdr.c test-flag-nobits.c test-nlist.c \ -- typeiter.c typeiter2.c unit-info.c update1.c update2.c \ -- update3.c update4.c varlocs.c vdsosyms.c vendorelf.c \ -- xlate_notes.c zstrptr.c -+ elfputzdata.c elfrdwrnop.c elfshphehdr.c elfstrmerge.c \ -+ elfstrtab.c emptyfile.c fillfile.c find-prologues.c \ -+ funcretval.c funcscopes.c get-aranges.c get-files.c \ -+ get-lines.c get-pubnames.c get-units-invalid.c \ -+ get-units-split.c getsrc_die.c hash.c line2addr.c \ -+ low_high_pc.c msg_tst.c newdata.c newfile.c newscn.c \ -+ next-files.c next-lines.c next_cfi.c peel_type.c rdwrmmap.c \ -+ rerequest_tag.c saridx.c scnnames.c sectiondump.c \ -+ show-abbrev.c show-die-info.c showptable.c strptr.c \ -+ system-elf-libelf-test.c test-elf_cntl_gelf_getshdr.c \ -+ test-flag-nobits.c test-nlist.c typeiter.c typeiter2.c \ -+ unit-info.c update1.c update2.c update3.c update4.c varlocs.c \ -+ vdsosyms.c vendorelf.c xlate_notes.c zstrptr.c - DIST_SOURCES = addrcfi.c addrscopes.c addsections.c aggregate_size.c \ - all-dwarf-ranges.c alldts.c allfcts.c allregs.c arextract.c \ - arls.c arsymtest.c asm-tst1.c asm-tst2.c asm-tst3.c asm-tst4.c \ -@@ -745,19 +749,19 @@ - dwfl-bug-getmodules.c dwfl-bug-report.c dwfl-proc-attach.c \ - dwfl-report-elf-align.c dwfllines.c dwflmodtest.c dwflsyms.c \ - early-offscn.c ecp.c elfcopy.c elfgetchdr.c elfgetzdata.c \ -- elfputzdata.c elfshphehdr.c elfstrmerge.c elfstrtab.c \ -- emptyfile.c fillfile.c find-prologues.c funcretval.c \ -- funcscopes.c get-aranges.c get-files.c get-lines.c \ -- get-pubnames.c get-units-invalid.c get-units-split.c \ -- getsrc_die.c hash.c line2addr.c low_high_pc.c msg_tst.c \ -- newdata.c newfile.c newscn.c next-files.c next-lines.c \ -- next_cfi.c peel_type.c rdwrmmap.c rerequest_tag.c saridx.c \ -- scnnames.c sectiondump.c show-abbrev.c show-die-info.c \ -- showptable.c strptr.c system-elf-libelf-test.c \ -- test-elf_cntl_gelf_getshdr.c test-flag-nobits.c test-nlist.c \ -- typeiter.c typeiter2.c unit-info.c update1.c update2.c \ -- update3.c update4.c varlocs.c vdsosyms.c vendorelf.c \ -- xlate_notes.c zstrptr.c -+ elfputzdata.c elfrdwrnop.c elfshphehdr.c elfstrmerge.c \ -+ elfstrtab.c emptyfile.c fillfile.c find-prologues.c \ -+ funcretval.c funcscopes.c get-aranges.c get-files.c \ -+ get-lines.c get-pubnames.c get-units-invalid.c \ -+ get-units-split.c getsrc_die.c hash.c line2addr.c \ -+ low_high_pc.c msg_tst.c newdata.c newfile.c newscn.c \ -+ next-files.c next-lines.c next_cfi.c peel_type.c rdwrmmap.c \ -+ rerequest_tag.c saridx.c scnnames.c sectiondump.c \ -+ show-abbrev.c show-die-info.c showptable.c strptr.c \ -+ system-elf-libelf-test.c test-elf_cntl_gelf_getshdr.c \ -+ test-flag-nobits.c test-nlist.c typeiter.c typeiter2.c \ -+ unit-info.c update1.c update2.c update3.c update4.c varlocs.c \ -+ vdsosyms.c vendorelf.c xlate_notes.c zstrptr.c - am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ -@@ -1405,6 +1409,7 @@ - run-unit-info.sh run-next-cfi.sh run-next-cfi-self.sh \ - testfile-riscv64.bz2 testfile-riscv64-s.bz2 \ - testfile-riscv64-core.bz2 \ -+ run-reverse-sections.sh run-reverse-sections-self.sh \ - run-copyadd-sections.sh run-copymany-sections.sh \ - run-typeiter-many.sh run-strip-test-many.sh \ - testfile-debug-rel-ppc64-g.o.bz2 \ -@@ -1566,6 +1571,7 @@ - elfcopy_LDADD = $(libelf) - addsections_LDADD = $(libelf) - xlate_notes_LDADD = $(libelf) -+elfrdwrnop_LDADD = $(libelf) - - # We want to test the libelf header against the system elf.h header. - # Don't include any -I CPPFLAGS. Except when we install our own elf.h. -@@ -1822,6 +1828,10 @@ - @rm -f elfputzdata$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(elfputzdata_OBJECTS) $(elfputzdata_LDADD) $(LIBS) - -+elfrdwrnop$(EXEEXT): $(elfrdwrnop_OBJECTS) $(elfrdwrnop_DEPENDENCIES) $(EXTRA_elfrdwrnop_DEPENDENCIES) -+ @rm -f elfrdwrnop$(EXEEXT) -+ $(AM_V_CCLD)$(LINK) $(elfrdwrnop_OBJECTS) $(elfrdwrnop_LDADD) $(LIBS) -+ - elfshphehdr$(EXEEXT): $(elfshphehdr_OBJECTS) $(elfshphehdr_DEPENDENCIES) $(EXTRA_elfshphehdr_DEPENDENCIES) - @rm -f elfshphehdr$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(elfshphehdr_OBJECTS) $(elfshphehdr_LDADD) $(LIBS) -@@ -2086,6 +2096,7 @@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elfgetchdr.Po@am__quote@ # am--include-marker - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elfgetzdata.Po@am__quote@ # am--include-marker - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elfputzdata.Po@am__quote@ # am--include-marker -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elfrdwrnop.Po@am__quote@ # am--include-marker - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elfshphehdr.Po@am__quote@ # am--include-marker - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elfstrmerge.Po@am__quote@ # am--include-marker - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elfstrtab.Po@am__quote@ # am--include-marker -@@ -3709,6 +3720,20 @@ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -+run-reverse-sections.sh.log: run-reverse-sections.sh -+ @p='run-reverse-sections.sh'; \ -+ b='run-reverse-sections.sh'; \ -+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ -+ --log-file $$b.log --trs-file $$b.trs \ -+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ -+ "$$tst" $(AM_TESTS_FD_REDIRECT) -+run-reverse-sections-self.sh.log: run-reverse-sections-self.sh -+ @p='run-reverse-sections-self.sh'; \ -+ b='run-reverse-sections-self.sh'; \ -+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ -+ --log-file $$b.log --trs-file $$b.trs \ -+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ -+ "$$tst" $(AM_TESTS_FD_REDIRECT) - run-copyadd-sections.sh.log: run-copyadd-sections.sh - @p='run-copyadd-sections.sh'; \ - b='run-copyadd-sections.sh'; \ -@@ -3997,6 +4022,7 @@ - -rm -f ./$(DEPDIR)/elfgetchdr.Po - -rm -f ./$(DEPDIR)/elfgetzdata.Po - -rm -f ./$(DEPDIR)/elfputzdata.Po -+ -rm -f ./$(DEPDIR)/elfrdwrnop.Po - -rm -f ./$(DEPDIR)/elfshphehdr.Po - -rm -f ./$(DEPDIR)/elfstrmerge.Po - -rm -f ./$(DEPDIR)/elfstrtab.Po -@@ -4147,6 +4173,7 @@ - -rm -f ./$(DEPDIR)/elfgetchdr.Po - -rm -f ./$(DEPDIR)/elfgetzdata.Po - -rm -f ./$(DEPDIR)/elfputzdata.Po -+ -rm -f ./$(DEPDIR)/elfrdwrnop.Po - -rm -f ./$(DEPDIR)/elfshphehdr.Po - -rm -f ./$(DEPDIR)/elfstrmerge.Po - -rm -f ./$(DEPDIR)/elfstrtab.Po -diff --git a/tests/elfcopy.c b/tests/elfcopy.c -index d457bad..4542222 100644 ---- a/tests/elfcopy.c -+++ b/tests/elfcopy.c -@@ -225,6 +225,7 @@ copy_elf (const char *in, const char *out, bool use_mmap, bool reverse_offs) - && shdr.sh_addralign == 1 - && last_shdr.sh_type != SHT_NOBITS - && shdr.sh_type != SHT_NOBITS -+ && last_shdr.sh_offset + last_shdr.sh_size == shdr.sh_offset - && (phnum == 0 - || ((shdr.sh_flags & SHF_ALLOC) == 0 - && (last_shdr.sh_flags & SHF_ALLOC) == 0))) diff --git a/SOURCES/elfutils-0.176-gcc-pr88835.patch b/SOURCES/elfutils-0.176-gcc-pr88835.patch deleted file mode 100644 index 6571f49..0000000 --- a/SOURCES/elfutils-0.176-gcc-pr88835.patch +++ /dev/null @@ -1,28 +0,0 @@ -Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88835 - -diff --git a/src/readelf.c b/src/readelf.c -index 33706bd..b55844c 100644 ---- a/src/readelf.c -+++ b/src/readelf.c -@@ -10143,7 +10143,7 @@ print_debug_str_section (Dwfl_Module *dwflmod __attribute__ ((unused)), - ++digits; - tmp >>= 4; - } -- digits = MAX (4, digits); -+ digits = MIN (16, MAX (4, digits)); - - printf (gettext ("\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n" - " %*s String\n"), -diff --git a/tests/backtrace.c b/tests/backtrace.c -index 05e8ef8..d621fbf 100644 ---- a/tests/backtrace.c -+++ b/tests/backtrace.c -@@ -185,7 +185,7 @@ frame_callback (Dwfl_Frame *state, void *frame_arg) - symname = dwfl_module_addrname (mod, pc_adjusted); - - printf ("#%2d %#" PRIx64 "%4s\t%s\n", *framenop, (uint64_t) pc, -- ! isactivation ? "- 1" : "", symname); -+ ! isactivation ? "- 1" : "", symname ?: ""); - pid_t tid = dwfl_thread_tid (thread); - callback_verify (tid, *framenop, pc, symname, dwfl); - (*framenop)++; diff --git a/SOURCES/elfutils-0.176-strip-symbols-illformed.patch b/SOURCES/elfutils-0.176-strip-symbols-illformed.patch deleted file mode 100644 index a0f22c8..0000000 --- a/SOURCES/elfutils-0.176-strip-symbols-illformed.patch +++ /dev/null @@ -1,26 +0,0 @@ -commit f03ac75239e0981deaf4aa18f66f423bcc5ce051 -Author: Mark Wielaard -Date: Wed Mar 27 21:54:06 2019 +0100 - - strip: Files with symbols referring to non-existing sections are illformed - - The check added in commit 4540ea98c "strip: Fix check test for SHN_XINDEX - symbol" was not complete. The (extended) section index should also exist. - If it doesn't exist, mark the file as illformed. - - https://sourceware.org/bugzilla/show_bug.cgi?id=24385 - - Signed-off-by: Mark Wielaard - -diff --git a/src/strip.c b/src/strip.c -index a73009d9..4cd87506 100644 ---- a/src/strip.c -+++ b/src/strip.c -@@ -1975,6 +1975,7 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname, - && shndxdata->d_buf != NULL); - size_t sidx = (sym->st_shndx != SHN_XINDEX - ? sym->st_shndx : xshndx); -+ elf_assert (sidx < shnum); - sec = shdr_info[sidx].idx; - - if (sec != 0) diff --git a/SOURCES/elfutils-0.176-xlate-note.patch b/SOURCES/elfutils-0.176-xlate-note.patch deleted file mode 100644 index e3bbf48..0000000 --- a/SOURCES/elfutils-0.176-xlate-note.patch +++ /dev/null @@ -1,486 +0,0 @@ -commit 28b5f578ae772bb2404c3847e4e22ad1c407af54 -Author: Mark Wielaard -Date: Tue Apr 30 13:00:17 2019 +0200 - - libelf: If xlate can only convert the ELF note header, just do that. - - When we started parsing new style ELF_T_NHDR8 notes we added extra - checks on alignment and padding. When those failed we would stop - converting and just return the rest of the ELF Note unconverted. - In the case were we just had enough data for just the ELF Note header - and the destionation and source weren't the same we would then - accidentially throw away the Note header conversion we just did. - - Fix that by indicating we did correctly convert just the header. - - Adds testcase that compares parsing ELF notes with gelf_getnote - and parsing the raw data by hand using elf32_xlatetom using just - the Note header and ignoring the (raw) note data. - - Signed-off-by: Mark Wielaard - -diff --git a/libelf/note_xlate.h b/libelf/note_xlate.h -index bc9950f..7e2784b 100644 ---- a/libelf/note_xlate.h -+++ b/libelf/note_xlate.h -@@ -47,13 +47,25 @@ elf_cvt_note (void *dest, const void *src, size_t len, int encode, - note_len += n->n_namesz; - note_len = nhdr8 ? NOTE_ALIGN8 (note_len) : NOTE_ALIGN4 (note_len); - if (note_len > len || note_len < sizeof *n) -- break; -+ { -+ /* Header was translated, nothing else. */ -+ len -= sizeof *n; -+ src += sizeof *n; -+ dest += sizeof *n; -+ break; -+ } - - /* data as a whole needs to be aligned. */ - note_len += n->n_descsz; - note_len = nhdr8 ? NOTE_ALIGN8 (note_len) : NOTE_ALIGN4 (note_len); - if (note_len > len || note_len < sizeof *n) -- break; -+ { -+ /* Header was translated, nothing else. */ -+ len -= sizeof *n; -+ src += sizeof *n; -+ dest += sizeof *n; -+ break; -+ } - - /* Copy or skip the note data. */ - size_t note_data_len = note_len - sizeof *n; -diff --git a/tests/Makefile.am b/tests/Makefile.am -index 1b0c7d3..498c1db 100644 ---- a/tests/Makefile.am -+++ b/tests/Makefile.am -@@ -60,7 +60,7 @@ check_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \ - fillfile dwarf_default_lower_bound dwarf-die-addr-die \ - get-units-invalid get-units-split attr-integrate-skel \ - all-dwarf-ranges unit-info next_cfi \ -- elfcopy addsections -+ elfcopy addsections xlate_notes - - asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \ - asm-tst6 asm-tst7 asm-tst8 asm-tst9 -@@ -159,7 +159,7 @@ TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \ - run-next-cfi.sh run-next-cfi-self.sh \ - run-copyadd-sections.sh run-copymany-sections.sh \ - run-typeiter-many.sh run-strip-test-many.sh \ -- run-strip-version.sh -+ run-strip-version.sh run-xlate-note.sh - - if !BIARCH - export ELFUTILS_DISABLE_BIARCH = 1 -@@ -423,7 +423,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \ - testfile-debug-rel-ppc64-g.o.bz2 \ - testfile-debug-rel-ppc64-z.o.bz2 \ - testfile-debug-rel-ppc64.o.bz2 \ -- run-strip-version.sh testfile-version.bz2 -+ run-strip-version.sh testfile-version.bz2 \ -+ run-xlate-note.sh - - if USE_VALGRIND - valgrind_cmd='valgrind -q --leak-check=full --error-exitcode=1' -@@ -593,6 +594,7 @@ unit_info_LDADD = $(libdw) - next_cfi_LDADD = $(libelf) $(libdw) - elfcopy_LDADD = $(libelf) - addsections_LDADD = $(libelf) -+xlate_notes_LDADD = $(libelf) - - # We want to test the libelf header against the system elf.h header. - # Don't include any -I CPPFLAGS. Except when we install our own elf.h. -diff --git a/tests/run-xlate-note.sh b/tests/run-xlate-note.sh -new file mode 100755 -index 0000000..a907418 ---- /dev/null -+++ b/tests/run-xlate-note.sh -@@ -0,0 +1,93 @@ -+# Copyright (C) 2019 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 -+ -+testfiles testfileppc32 -+testrun_compare ${abs_top_builddir}/tests/xlate_notes testfileppc32 << EOF -+Notes in section 2: -+type: 1,1, namesz: 4,4, descsz: 16,16 -+Notes in section 3: -+type: 3,3, namesz: 4,4, descsz: 20,20 -+EOF -+ -+testfiles testfileppc64 -+testrun_compare ${abs_top_builddir}/tests/xlate_notes testfileppc64 << EOF -+Notes in section 2: -+type: 1,1, namesz: 4,4, descsz: 16,16 -+Notes in section 3: -+type: 3,3, namesz: 4,4, descsz: 20,20 -+EOF -+ -+testfiles testfiles390 -+testrun_compare ${abs_top_builddir}/tests/xlate_notes testfiles390 << EOF -+Notes in section 2: -+type: 1,1, namesz: 4,4, descsz: 16,16 -+Notes in section 3: -+type: 3,3, namesz: 4,4, descsz: 20,20 -+EOF -+ -+testfiles testfiles390x -+testrun_compare ${abs_top_builddir}/tests/xlate_notes testfiles390x << EOF -+Notes in section 2: -+type: 1,1, namesz: 4,4, descsz: 16,16 -+Notes in section 3: -+type: 3,3, namesz: 4,4, descsz: 20,20 -+EOF -+ -+testfiles testfileaarch64 -+testrun_compare ${abs_top_builddir}/tests/xlate_notes testfileaarch64 << EOF -+Notes in section 2: -+type: 1,1, namesz: 4,4, descsz: 16,16 -+Notes in section 3: -+type: 3,3, namesz: 4,4, descsz: 20,20 -+EOF -+ -+testfiles testfilearm -+testrun_compare ${abs_top_builddir}/tests/xlate_notes testfilearm << EOF -+Notes in section 2: -+type: 1,1, namesz: 4,4, descsz: 16,16 -+Notes in section 3: -+type: 3,3, namesz: 4,4, descsz: 20,20 -+EOF -+ -+testfiles testfile_gnu_props.32be.o -+testrun_compare ${abs_top_builddir}/tests/xlate_notes testfile_gnu_props.32be.o << EOF -+Notes in section 4: -+type: 5,5, namesz: 4,4, descsz: 12,12 -+type: 5,5, namesz: 4,4, descsz: 8,8 -+EOF -+ -+testfiles testfile_gnu_props.32le.o -+testrun_compare ${abs_top_builddir}/tests/xlate_notes testfile_gnu_props.32le.o << EOF -+Notes in section 4: -+type: 5,5, namesz: 4,4, descsz: 12,12 -+type: 5,5, namesz: 4,4, descsz: 8,8 -+EOF -+ -+testfiles testfile_gnu_props.64be.o -+testrun_compare ${abs_top_builddir}/tests/xlate_notes testfile_gnu_props.64be.o << EOF -+Notes in section 4: -+type: 5,5, namesz: 4,4, descsz: 16,16 -+type: 5,5, namesz: 4,4, descsz: 8,8 -+EOF -+ -+testfiles testfile_gnu_props.64le.o -+testrun_compare ${abs_top_builddir}/tests/xlate_notes testfile_gnu_props.64le.o << EOF -+Notes in section 4: -+type: 5,5, namesz: 4,4, descsz: 16,16 -+type: 5,5, namesz: 4,4, descsz: 8,8 -+EOF -diff --git a/tests/xlate_notes.c b/tests/xlate_notes.c -new file mode 100644 -index 0000000..90a4ae2 ---- /dev/null -+++ b/tests/xlate_notes.c -@@ -0,0 +1,157 @@ -+/* Test program for extracting ELF Note headers and getting whole notes. -+ Copyright (C) 2019 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 . */ -+ -+#ifdef HAVE_CONFIG_H -+# include -+#endif -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include ELFUTILS_HEADER(elf) -+#include -+ -+int -+main (int argc, char *argv[]) -+{ -+ if (argc != 2) -+ { -+ printf ("No ELF file given as argument\n"); -+ exit (1); -+ } -+ -+ const char *fname = argv[1]; -+ -+ // Initialize libelf. -+ elf_version (EV_CURRENT); -+ -+ /* Read the ELF from disk now. */ -+ int fd = open (fname, O_RDONLY); -+ if (fd == -1) -+ { -+ printf ("cannot open '%s': %s\n", fname, strerror (errno)); -+ exit (1); -+ } -+ -+ Elf *elf = elf_begin (fd, ELF_C_READ, NULL); -+ if (elf == NULL) -+ { -+ printf ("cannot create ELF descriptor: %s\n", elf_errmsg (-1)); -+ exit (1); -+ } -+ -+ GElf_Ehdr ehdr; -+ if (gelf_getehdr (elf, &ehdr) == NULL) -+ { -+ printf ("cannot get Ehdr: %s\n", elf_errmsg (-1)); -+ exit (1); -+ } -+ -+ /* Search for all SHT_NOTE sections. */ -+ Elf_Scn *scn = NULL; -+ while ((scn = elf_nextscn (elf, scn)) != NULL) -+ { -+ /* Get the header. */ -+ GElf_Shdr shdr; -+ if (gelf_getshdr (scn, &shdr) == NULL) -+ { -+ printf ("couldn't get shdr: %s\n", elf_errmsg (-1)); -+ exit (1); -+ } -+ -+ if (shdr.sh_type == SHT_NOTE) -+ { -+ printf ("Notes in section %zd:\n", elf_ndxscn (scn)); -+ -+ Elf_Data *raw = elf_rawdata (scn, NULL); -+ if (raw == NULL) -+ { -+ printf ("couldn't get raw data: %s\n", elf_errmsg (-1)); -+ exit (1); -+ } -+ -+ Elf_Data *data = elf_getdata (scn, NULL); -+ if (data == NULL) -+ { -+ printf ("couldn't get data: %s\n", elf_errmsg (-1)); -+ exit (1); -+ } -+ -+ size_t off = 0; -+ size_t next; -+ GElf_Nhdr nhdr; -+ size_t n_off; -+ size_t d_off; -+ while ((next = gelf_getnote (data, off, &nhdr, &n_off, &d_off)) > 0) -+ { -+ /* Now just get the note header "raw" (don't -+ copy/translate the note data). This only handles -+ traditional GNU ELF Notes, so we still use the next -+ from gelf_getnote (padding is different for new style -+ ELF_T_NHDR8 notes). */ -+ Elf32_Nhdr nh; -+ Elf_Data src = -+ { -+ .d_version = EV_CURRENT, .d_type = ELF_T_NHDR, -+ .d_size = sizeof nh -+ }; -+ Elf_Data dst = src; -+ src.d_buf = raw->d_buf + off; -+ dst.d_buf = &nh; -+ -+ if (elf32_xlatetom (&dst, &src, ehdr.e_ident[EI_DATA]) == NULL) -+ { -+ printf ("couldn't xlate note: %s\n", elf_errmsg (-1)); -+ exit (1); -+ } -+ -+ printf ("type: %" PRId32 ",%" PRId32 -+ ", namesz: %" PRId32 ",%" PRId32 -+ ", descsz: %" PRId32 ",%" PRId32 "\n", -+ nhdr.n_type, nh.n_type, -+ nhdr.n_namesz, nh.n_namesz, -+ nhdr.n_descsz, nh.n_descsz); -+ -+ if (nhdr.n_type != nh.n_type -+ || nhdr.n_namesz != nh.n_namesz -+ || nhdr.n_descsz != nh.n_descsz) -+ { -+ printf ("Nhdrs not equal!\n"); -+ exit (1); -+ } -+ -+ off = next; -+ } -+ } -+ -+ } -+ -+ if (elf_end (elf) != 0) -+ { -+ printf ("failure in elf_end: %s\n", elf_errmsg (-1)); -+ exit (1); -+ } -+ -+ close (fd); -+ -+ return 0; -+} -diff -ur elfutils-0.176.orig/tests/Makefile.in elfutils-0.176/tests/Makefile.in ---- elfutils-0.176.orig/tests/Makefile.in 2019-04-30 22:42:49.534655124 +0200 -+++ elfutils-0.176/tests/Makefile.in 2019-04-30 22:46:30.046656790 +0200 -@@ -131,8 +131,8 @@ - get-units-invalid$(EXEEXT) get-units-split$(EXEEXT) \ - attr-integrate-skel$(EXEEXT) all-dwarf-ranges$(EXEEXT) \ - unit-info$(EXEEXT) next_cfi$(EXEEXT) elfcopy$(EXEEXT) \ -- addsections$(EXEEXT) $(am__EXEEXT_1) $(am__EXEEXT_2) \ -- $(am__EXEEXT_4) -+ addsections$(EXEEXT) xlate_notes$(EXEEXT) $(am__EXEEXT_1) \ -+ $(am__EXEEXT_2) $(am__EXEEXT_4) - @BIARCH_TRUE@am__append_5 = backtrace-child-biarch - TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile$(EXEEXT) \ - test-nlist$(EXEEXT) update1$(EXEEXT) update2$(EXEEXT) \ -@@ -211,8 +211,8 @@ - run-unit-info.sh run-reloc-bpf.sh run-next-cfi.sh \ - run-next-cfi-self.sh run-copyadd-sections.sh \ - run-copymany-sections.sh run-typeiter-many.sh \ -- run-strip-test-many.sh run-strip-version.sh $(am__EXEEXT_2) \ -- $(am__append_8) $(am__EXEEXT_5) -+ run-strip-test-many.sh run-strip-version.sh run-xlate-note.sh \ -+ $(am__EXEEXT_2) $(am__append_8) $(am__EXEEXT_5) - @STANDALONE_FALSE@am__append_6 = msg_tst system-elf-libelf-test - @STANDALONE_FALSE@am__append_7 = msg_tst system-elf-libelf-test - @LZMA_TRUE@am__append_8 = run-readelf-s.sh run-dwflsyms.sh -@@ -606,6 +606,9 @@ - vendorelf_SOURCES = vendorelf.c - vendorelf_OBJECTS = vendorelf.$(OBJEXT) - vendorelf_DEPENDENCIES = $(am__DEPENDENCIES_2) -+xlate_notes_SOURCES = xlate_notes.c -+xlate_notes_OBJECTS = xlate_notes.$(OBJEXT) -+xlate_notes_DEPENDENCIES = $(am__DEPENDENCIES_2) - zstrptr_SOURCES = zstrptr.c - zstrptr_OBJECTS = zstrptr.$(OBJEXT) - zstrptr_DEPENDENCIES = $(am__DEPENDENCIES_2) -@@ -683,7 +686,7 @@ - ./$(DEPDIR)/update2.Po ./$(DEPDIR)/update3.Po \ - ./$(DEPDIR)/update4.Po ./$(DEPDIR)/varlocs.Po \ - ./$(DEPDIR)/vdsosyms.Po ./$(DEPDIR)/vendorelf.Po \ -- ./$(DEPDIR)/zstrptr.Po -+ ./$(DEPDIR)/xlate_notes.Po ./$(DEPDIR)/zstrptr.Po - am__mv = mv -f - AM_V_lt = $(am__v_lt_@AM_V@) - am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -@@ -726,7 +729,8 @@ - showptable.c strptr.c system-elf-libelf-test.c \ - test-elf_cntl_gelf_getshdr.c test-flag-nobits.c test-nlist.c \ - typeiter.c typeiter2.c unit-info.c update1.c update2.c \ -- update3.c update4.c varlocs.c vdsosyms.c vendorelf.c zstrptr.c -+ update3.c update4.c varlocs.c vdsosyms.c vendorelf.c \ -+ xlate_notes.c zstrptr.c - DIST_SOURCES = addrcfi.c addrscopes.c addsections.c aggregate_size.c \ - all-dwarf-ranges.c alldts.c allfcts.c allregs.c arextract.c \ - arls.c arsymtest.c asm-tst1.c asm-tst2.c asm-tst3.c asm-tst4.c \ -@@ -752,7 +756,8 @@ - showptable.c strptr.c system-elf-libelf-test.c \ - test-elf_cntl_gelf_getshdr.c test-flag-nobits.c test-nlist.c \ - typeiter.c typeiter2.c unit-info.c update1.c update2.c \ -- update3.c update4.c varlocs.c vdsosyms.c vendorelf.c zstrptr.c -+ update3.c update4.c varlocs.c vdsosyms.c vendorelf.c \ -+ xlate_notes.c zstrptr.c - am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ -@@ -1405,7 +1410,8 @@ - testfile-debug-rel-ppc64-g.o.bz2 \ - testfile-debug-rel-ppc64-z.o.bz2 \ - testfile-debug-rel-ppc64.o.bz2 \ -- run-strip-version.sh testfile-version.bz2 -+ run-strip-version.sh testfile-version.bz2 \ -+ run-xlate-note.sh - - @USE_VALGRIND_TRUE@valgrind_cmd = 'valgrind -q --leak-check=full --error-exitcode=1' - installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir); \ -@@ -1559,6 +1565,7 @@ - next_cfi_LDADD = $(libelf) $(libdw) - elfcopy_LDADD = $(libelf) - addsections_LDADD = $(libelf) -+xlate_notes_LDADD = $(libelf) - - # We want to test the libelf header against the system elf.h header. - # Don't include any -I CPPFLAGS. Except when we install our own elf.h. -@@ -2011,6 +2018,10 @@ - @rm -f vendorelf$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(vendorelf_OBJECTS) $(vendorelf_LDADD) $(LIBS) - -+xlate_notes$(EXEEXT): $(xlate_notes_OBJECTS) $(xlate_notes_DEPENDENCIES) $(EXTRA_xlate_notes_DEPENDENCIES) -+ @rm -f xlate_notes$(EXEEXT) -+ $(AM_V_CCLD)$(LINK) $(xlate_notes_OBJECTS) $(xlate_notes_LDADD) $(LIBS) -+ - zstrptr$(EXEEXT): $(zstrptr_OBJECTS) $(zstrptr_DEPENDENCIES) $(EXTRA_zstrptr_DEPENDENCIES) - @rm -f zstrptr$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(zstrptr_OBJECTS) $(zstrptr_LDADD) $(LIBS) -@@ -2124,6 +2135,7 @@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/varlocs.Po@am__quote@ # am--include-marker - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vdsosyms.Po@am__quote@ # am--include-marker - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vendorelf.Po@am__quote@ # am--include-marker -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xlate_notes.Po@am__quote@ # am--include-marker - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zstrptr.Po@am__quote@ # am--include-marker - - $(am__depfiles_remade): -@@ -3732,6 +3744,13 @@ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -+run-xlate-note.sh.log: run-xlate-note.sh -+ @p='run-xlate-note.sh'; \ -+ b='run-xlate-note.sh'; \ -+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ -+ --log-file $$b.log --trs-file $$b.trs \ -+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ -+ "$$tst" $(AM_TESTS_FD_REDIRECT) - msg_tst.log: msg_tst$(EXEEXT) - @p='msg_tst$(EXEEXT)'; \ - b='msg_tst'; \ -@@ -4027,6 +4046,7 @@ - -rm -f ./$(DEPDIR)/varlocs.Po - -rm -f ./$(DEPDIR)/vdsosyms.Po - -rm -f ./$(DEPDIR)/vendorelf.Po -+ -rm -f ./$(DEPDIR)/xlate_notes.Po - -rm -f ./$(DEPDIR)/zstrptr.Po - -rm -f Makefile - distclean-am: clean-am distclean-compile distclean-generic \ -@@ -4176,6 +4196,7 @@ - -rm -f ./$(DEPDIR)/varlocs.Po - -rm -f ./$(DEPDIR)/vdsosyms.Po - -rm -f ./$(DEPDIR)/vendorelf.Po -+ -rm -f ./$(DEPDIR)/xlate_notes.Po - -rm -f ./$(DEPDIR)/zstrptr.Po - -rm -f Makefile - maintainer-clean-am: distclean-am maintainer-clean-generic diff --git a/SOURCES/elfutils-0.178-compressed-vmlinuz.patch b/SOURCES/elfutils-0.178-compressed-vmlinuz.patch new file mode 100644 index 0000000..1df54a1 --- /dev/null +++ b/SOURCES/elfutils-0.178-compressed-vmlinuz.patch @@ -0,0 +1,62 @@ +commit 4a90cb11140a6bb3712228861a32e4035013ad85 +Author: Mark Wielaard +Date: Thu Dec 5 15:03:54 2019 +0100 + + libdwfl: Find and handle compressed vmlinuz image. + + Both the dwfl_linux_kernel_find_elf callback and the + dwfl_linux_kernel_report_offline reporting function only handled + vmlinix images possibly compressed with .gz, .bz2 or .xz extension. + They did not find or handle the much more common vmlinuz compressed + images. + + It is not completely clear why we didn't up to now. Support for + compressed ELF files was added in 2009 and the code was updated to + to try to find the .gz, .bz2 or .xz extension variants in 2011. + But not the vmlinuz named variant. + + Reported-by: Aaron Merey + Tested-by: Frank Ch. Eigler + Signed-off-by: Mark Wielaard + +diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c +index d46ab5aa..48fb1ff0 100644 +--- a/libdwfl/linux-kernel-modules.c ++++ b/libdwfl/linux-kernel-modules.c +@@ -174,6 +174,8 @@ kernel_release (void) + static int + find_kernel_elf (Dwfl *dwfl, const char *release, char **fname) + { ++ /* First try to find an uncompressed vmlinux image. Possibly ++ including debuginfo. */ + if ((release[0] == '/' + ? asprintf (fname, "%s/vmlinux", release) + : asprintf (fname, "/boot/vmlinux-%s", release)) < 0) +@@ -188,6 +190,27 @@ find_kernel_elf (Dwfl *dwfl, const char *release, char **fname) + fd = try_kernel_name (dwfl, fname, true); + } + ++ /* There might be a compressed vmlinuz image. Probably without ++ debuginfo, but try to find it under the debug path also, just in ++ case. */ ++ if (fd < 0) ++ { ++ free (*fname); ++ if ((release[0] == '/' ++ ? asprintf (fname, "%s/vmlinuz", release) ++ : asprintf (fname, "/boot/vmlinuz-%s", release)) < 0) ++ return -1; ++ ++ fd = try_kernel_name (dwfl, fname, true); ++ if (fd < 0 && release[0] != '/') ++ { ++ free (*fname); ++ if (asprintf (fname, MODULEDIRFMT "/vmlinuz", release) < 0) ++ return -1; ++ fd = try_kernel_name (dwfl, fname, true); ++ } ++ } ++ + return fd; + } + diff --git a/SOURCES/elfutils-0.178-curl-code-gcc-10.patch b/SOURCES/elfutils-0.178-curl-code-gcc-10.patch new file mode 100644 index 0000000..a1e2741 --- /dev/null +++ b/SOURCES/elfutils-0.178-curl-code-gcc-10.patch @@ -0,0 +1,53 @@ +commit 374fbed3da0197f794a904e78e75e961c7e2e92c +Author: Mark Wielaard +Date: Wed Dec 4 00:39:26 2019 +0100 + + debuginfod: Fix implicit conversion from 'CURLcode' to 'CURLMcode' + + GCC10 warns when converting the value of one enum type into another: + + debuginfod-client.c:530:24: error: implicit conversion from ‘CURLcode’ + to ‘CURLMcode’ [-Werror=enum-conversion] + 530 | curl_res = curl_easy_getinfo(target_handle, + | ^ + + libcurl has different error code enums. The "easy" interfaces return + a CURLcode error. The "multi" interface functions return a CURLMcode. + + Signed-off-by: Mark Wielaard + +diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c +index 6e62b86c..302ea2dc 100644 +--- a/debuginfod/debuginfod-client.c ++++ b/debuginfod/debuginfod-client.c +@@ -509,8 +509,6 @@ debuginfod_query_server (debuginfod_client *c, + long loops = 0; + do + { +- CURLMcode curl_res; +- + if (c->progressfn) /* inform/check progress callback */ + { + loops ++; +@@ -518,6 +516,7 @@ debuginfod_query_server (debuginfod_client *c, + long pb = 0; + if (target_handle) /* we've committed to a server; report its download progress */ + { ++ CURLcode curl_res; + #ifdef CURLINFO_SIZE_DOWNLOAD_T + curl_off_t dl; + curl_res = curl_easy_getinfo(target_handle, +@@ -564,10 +563,10 @@ debuginfod_query_server (debuginfod_client *c, + if (data[i].handle != target_handle) + curl_multi_remove_handle(curlm, data[i].handle); + +- curl_res = curl_multi_perform(curlm, &still_running); +- if (curl_res != CURLM_OK) ++ CURLMcode curlm_res = curl_multi_perform(curlm, &still_running); ++ if (curlm_res != CURLM_OK) + { +- switch (curl_res) ++ switch (curlm_res) + { + case CURLM_CALL_MULTI_PERFORM: continue; + case CURLM_OUT_OF_MEMORY: rc = -ENOMEM; break; diff --git a/SOURCES/elfutils-0.178-debuginfod-no-cache.patch b/SOURCES/elfutils-0.178-debuginfod-no-cache.patch new file mode 100644 index 0000000..a05336b --- /dev/null +++ b/SOURCES/elfutils-0.178-debuginfod-no-cache.patch @@ -0,0 +1,67 @@ +commit d8bad02afc7b7f30402b4e0e458df874a6d600da +Author: Mark Wielaard +Date: Mon Dec 9 19:38:19 2019 +0100 + + debuginfod: Check the DEBUGINFOD_URLS environment variable early in client. + + If the debuginfod-client isn't configured we should do as little + as possible. Simply return early with ENOSYS if no servers are + configured. This means we won't check + + This does change the behavior of the debuginfod_find calls slightly. + Previously we would setup and check the cache if the given build-id + was valid. Which might have provided a result if an earlier client + had run with the same cache and valid server URLs which knew about + that particular build-id. Now we don't return any cached results + unless at least one server is configured. + + This prevents selinux errors when the library is used in a confined + setup. + + Signed-off-by: Mark Wielaard + +diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c +index 302ea2dc..ab7b4e13 100644 +--- a/debuginfod/debuginfod-client.c ++++ b/debuginfod/debuginfod-client.c +@@ -301,6 +301,16 @@ debuginfod_query_server (debuginfod_client *c, + char target_cache_tmppath[PATH_MAX*5]; + char suffix[PATH_MAX*2]; + char build_id_bytes[MAX_BUILD_ID_BYTES * 2 + 1]; ++ int rc; ++ ++ /* Is there any server we can query? If not, don't do any work, ++ just return with ENOSYS. Don't even access the cache. */ ++ urls_envvar = getenv(server_urls_envvar); ++ if (urls_envvar == NULL || urls_envvar[0] == '\0') ++ { ++ rc = -ENOSYS; ++ goto out; ++ } + + /* Copy lowercase hex representation of build_id into buf. */ + if ((build_id_len >= MAX_BUILD_ID_BYTES) || +@@ -373,7 +383,7 @@ debuginfod_query_server (debuginfod_client *c, + /* XXX combine these */ + snprintf(interval_path, sizeof(interval_path), "%s/%s", cache_path, cache_clean_interval_filename); + snprintf(maxage_path, sizeof(maxage_path), "%s/%s", cache_path, cache_max_unused_age_filename); +- int rc = debuginfod_init_cache(cache_path, interval_path, maxage_path); ++ rc = debuginfod_init_cache(cache_path, interval_path, maxage_path); + if (rc != 0) + goto out; + rc = debuginfod_clean_cache(c, cache_path, interval_path, maxage_path); +@@ -390,14 +400,6 @@ debuginfod_query_server (debuginfod_client *c, + return fd; + } + +- +- urls_envvar = getenv(server_urls_envvar); +- if (urls_envvar == NULL || urls_envvar[0] == '\0') +- { +- rc = -ENOSYS; +- goto out; +- } +- + if (getenv(server_timeout_envvar)) + server_timeout = atoi (getenv(server_timeout_envvar)); + diff --git a/SOURCES/elfutils-0.178-debuginfod-timeoutprogress.patch b/SOURCES/elfutils-0.178-debuginfod-timeoutprogress.patch new file mode 100644 index 0000000..9e81e9e --- /dev/null +++ b/SOURCES/elfutils-0.178-debuginfod-timeoutprogress.patch @@ -0,0 +1,593 @@ +commit 76ad56c430f0b85c47115688c511d9bd4fa671d4 +Author: Frank Ch. Eigler +Date: Wed Dec 4 15:51:12 2019 -0500 + + debuginfod: usability tweaks, incl. $DEBUGINFOD_PROGRESS client support + + This facility allows a default progress-printing function to be + installed if the given environment variable is set. Some larger usage + experience (systemtap fetching kernels) indicates the default timeout + is too short, so forked it into a connection timeout (default short) + and a transfer timeout (default unlimited). + + Signed-off-by: Frank Ch. Eigler + +diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c +index ab7b4e1..9a4a0e0 100644 +--- a/debuginfod/debuginfod-client.c ++++ b/debuginfod/debuginfod-client.c +@@ -40,6 +40,7 @@ + + #include "config.h" + #include "debuginfod.h" ++#include "system.h" + #include + #include + #include +@@ -98,16 +99,16 @@ static const time_t cache_default_max_unused_age_s = 604800; /* 1 week */ + static const char *cache_default_name = ".debuginfod_client_cache"; + static const char *cache_path_envvar = DEBUGINFOD_CACHE_PATH_ENV_VAR; + +-/* URLs of debuginfods, separated by url_delim. +- This env var must be set for debuginfod-client to run. */ ++/* URLs of debuginfods, separated by url_delim. */ + static const char *server_urls_envvar = DEBUGINFOD_URLS_ENV_VAR; + static const char *url_delim = " "; + static const char url_delim_char = ' '; + +-/* Timeout for debuginfods, in seconds. +- This env var must be set for debuginfod-client to run. */ ++/* Timeout for debuginfods, in seconds. */ + static const char *server_timeout_envvar = DEBUGINFOD_TIMEOUT_ENV_VAR; +-static int server_timeout = 5; ++static const long default_connect_timeout = 5; ++static const long default_transfer_timeout = -1; /* unlimited */ ++ + + /* Data associated with a particular CURL easy handle. Passed to + the write callback. */ +@@ -400,8 +401,18 @@ debuginfod_query_server (debuginfod_client *c, + return fd; + } + +- if (getenv(server_timeout_envvar)) +- server_timeout = atoi (getenv(server_timeout_envvar)); ++ long connect_timeout = default_connect_timeout; ++ long transfer_timeout = default_transfer_timeout; ++ const char* timeout_envvar = getenv(server_timeout_envvar); ++ if (timeout_envvar != NULL) ++ { ++ long ct, tt; ++ rc = sscanf(timeout_envvar, "%ld,%ld", &ct, &tt); ++ if (rc >= 1) ++ connect_timeout = ct; ++ if (rc >= 2) ++ transfer_timeout = tt; ++ } + + /* make a copy of the envvar so it can be safely modified. */ + server_urls = strdup(urls_envvar); +@@ -493,7 +504,10 @@ debuginfod_query_server (debuginfod_client *c, + CURLOPT_WRITEFUNCTION, + debuginfod_write_callback); + curl_easy_setopt(data[i].handle, CURLOPT_WRITEDATA, (void*)&data[i]); +- curl_easy_setopt(data[i].handle, CURLOPT_TIMEOUT, (long) server_timeout); ++ if (connect_timeout >= 0) ++ curl_easy_setopt(data[i].handle, CURLOPT_CONNECTTIMEOUT, connect_timeout); ++ if (transfer_timeout >= 0) ++ curl_easy_setopt(data[i].handle, CURLOPT_TIMEOUT, transfer_timeout); + curl_easy_setopt(data[i].handle, CURLOPT_FILETIME, (long) 1); + curl_easy_setopt(data[i].handle, CURLOPT_FOLLOWLOCATION, (long) 1); + curl_easy_setopt(data[i].handle, CURLOPT_FAILONERROR, (long) 1); +@@ -511,11 +525,32 @@ debuginfod_query_server (debuginfod_client *c, + long loops = 0; + do + { ++ /* Wait 1 second, the minimum DEBUGINFOD_TIMEOUT. */ ++ curl_multi_wait(curlm, NULL, 0, 1000, NULL); ++ ++ /* If the target file has been found, abort the other queries. */ ++ if (target_handle != NULL) ++ for (int i = 0; i < num_urls; i++) ++ if (data[i].handle != target_handle) ++ curl_multi_remove_handle(curlm, data[i].handle); ++ ++ CURLMcode curlm_res = curl_multi_perform(curlm, &still_running); ++ if (curlm_res != CURLM_OK) ++ { ++ switch (curlm_res) ++ { ++ case CURLM_CALL_MULTI_PERFORM: continue; ++ case CURLM_OUT_OF_MEMORY: rc = -ENOMEM; break; ++ default: rc = -ENETUNREACH; break; ++ } ++ goto out1; ++ } ++ + if (c->progressfn) /* inform/check progress callback */ + { + loops ++; + long pa = loops; /* default params for progress callback */ +- long pb = 0; ++ long pb = 0; /* transfer_timeout tempting, but loops != elapsed-time */ + if (target_handle) /* we've committed to a server; report its download progress */ + { + CURLcode curl_res; +@@ -535,6 +570,8 @@ debuginfod_query_server (debuginfod_client *c, + pa = (dl > LONG_MAX ? LONG_MAX : (long)dl); + #endif + ++ /* NB: If going through deflate-compressing proxies, this ++ number is likely to be unavailable, so -1 may show. */ + #ifdef CURLINFO_CURLINFO_CONTENT_LENGTH_DOWNLOAD_T + curl_off_t cl; + curl_res = curl_easy_getinfo(target_handle, +@@ -555,27 +592,6 @@ debuginfod_query_server (debuginfod_client *c, + if ((*c->progressfn) (c, pa, pb)) + break; + } +- +- /* Wait 1 second, the minimum DEBUGINFOD_TIMEOUT. */ +- curl_multi_wait(curlm, NULL, 0, 1000, NULL); +- +- /* If the target file has been found, abort the other queries. */ +- if (target_handle != NULL) +- for (int i = 0; i < num_urls; i++) +- if (data[i].handle != target_handle) +- curl_multi_remove_handle(curlm, data[i].handle); +- +- CURLMcode curlm_res = curl_multi_perform(curlm, &still_running); +- if (curlm_res != CURLM_OK) +- { +- switch (curlm_res) +- { +- case CURLM_CALL_MULTI_PERFORM: continue; +- case CURLM_OUT_OF_MEMORY: rc = -ENOMEM; break; +- default: rc = -ENETUNREACH; break; +- } +- goto out1; +- } + } while (still_running); + + /* Check whether a query was successful. If so, assign its handle +@@ -674,9 +690,9 @@ debuginfod_query_server (debuginfod_client *c, + + curl_multi_cleanup(curlm); + unlink (target_cache_tmppath); ++ close (fd); /* before the rmdir, otherwise it'll fail */ + (void) rmdir (target_cache_dir); /* nop if not empty */ + free(data); +- close (fd); + + out0: + free (server_urls); +@@ -685,6 +701,22 @@ debuginfod_query_server (debuginfod_client *c, + return rc; + } + ++ ++/* Activate a basic form of progress tracing */ ++static int ++default_progressfn (debuginfod_client *c, long a, long b) ++{ ++ (void) c; ++ ++ dprintf(STDERR_FILENO, ++ "Downloading from debuginfod %ld/%ld%s", a, b, ++ ((a == b) ? "\n" : "\r")); ++ /* XXX: include URL - stateful */ ++ ++ return 0; ++} ++ ++ + /* See debuginfod.h */ + debuginfod_client * + debuginfod_begin (void) +@@ -693,7 +725,12 @@ debuginfod_begin (void) + size_t size = sizeof (struct debuginfod_client); + client = (debuginfod_client *) malloc (size); + if (client != NULL) +- client->progressfn = NULL; ++ { ++ if (getenv(DEBUGINFOD_PROGRESS_ENV_VAR)) ++ client->progressfn = default_progressfn; ++ else ++ client->progressfn = NULL; ++ } + return client; + } + +diff --git a/debuginfod/debuginfod.h b/debuginfod/debuginfod.h +index 6b1b1cc..33fae86 100644 +--- a/debuginfod/debuginfod.h ++++ b/debuginfod/debuginfod.h +@@ -33,6 +33,7 @@ + #define DEBUGINFOD_URLS_ENV_VAR "DEBUGINFOD_URLS" + #define DEBUGINFOD_CACHE_PATH_ENV_VAR "DEBUGINFOD_CACHE_PATH" + #define DEBUGINFOD_TIMEOUT_ENV_VAR "DEBUGINFOD_TIMEOUT" ++#define DEBUGINFOD_PROGRESS_ENV_VAR "DEBUGINFOD_PROGRESS" + + /* Handle for debuginfod-client connection. */ + typedef struct debuginfod_client debuginfod_client; +diff --git a/doc/debuginfod-find.1 b/doc/debuginfod-find.1 +index a759ecb..023acbb 100644 +--- a/doc/debuginfod-find.1 ++++ b/doc/debuginfod-find.1 +@@ -119,9 +119,13 @@ debuginfod instances. Alternate URL prefixes are separated by space. + + .TP 21 + .B DEBUGINFOD_TIMEOUT +-This environment variable governs the timeout for each debuginfod HTTP +-connection. A server that fails to respond within this many seconds +-is skipped. The default is 5. ++This environment variable governs the timeouts for each debuginfod ++HTTP connection. One or two comma-separated numbers may be given. ++The first is the number of seconds for the connection establishment ++(CURLOPT_CONNECTTIMEOUT), and the default is 5. The second is the ++number of seconds for the transfer completion (CURLOPT_TIMEOUT), and ++the default is no timeout. (Zero or negative also means "no ++timeout".) + + .TP 21 + .B DEBUGINFOD_CACHE_PATH +diff --git a/doc/debuginfod_find_debuginfo.3 b/doc/debuginfod_find_debuginfo.3 +index be8eed0..ea8c616 100644 +--- a/doc/debuginfod_find_debuginfo.3 ++++ b/doc/debuginfod_find_debuginfo.3 +@@ -163,9 +163,21 @@ debuginfod instances. Alternate URL prefixes are separated by space. + + .TP 21 + .B DEBUGINFOD_TIMEOUT +-This environment variable governs the timeout for each debuginfod HTTP +-connection. A server that fails to respond within this many seconds +-is skipped. The default is 5. ++This environment variable governs the timeouts for each debuginfod ++HTTP connection. One or two comma-separated numbers may be given. ++The first is the number of seconds for the connection establishment ++(CURLOPT_CONNECTTIMEOUT), and the default is 5. The second is the ++number of seconds for the transfer completion (CURLOPT_TIMEOUT), and ++the default is no timeout. (Zero or negative also means "no ++timeout".) ++ ++.TP 21 ++.B DEBUGINFOD_PROGRESS ++This environment variable governs the default progress function. If ++set, and if a progressfn is not explicitly set, then the library will ++configure a default progressfn. This function will append a simple ++progress message periodically to the given file. Consider using ++"/dev/stderr" on platforms that support it. The default is nothing. + + .TP 21 + .B DEBUGINFOD_CACHE_PATH +diff --git a/tests/run-debuginfod-find.sh b/tests/run-debuginfod-find.sh +index 6533996..4cf6138 100755 +--- a/tests/run-debuginfod-find.sh ++++ b/tests/run-debuginfod-find.sh +@@ -89,7 +89,7 @@ wait_ready $PORT1 'ready' 1 + export DEBUGINFOD_URLS=http://127.0.0.1:$PORT1/ # or without trailing / + + # Be patient when run on a busy machine things might take a bit. +-export DEBUGINFOD_TIMEOUT=10 ++export DEBUGINFOD_TIMEOUT=1,10 + + # We use -t0 and -g0 here to turn off time-based scanning & grooming. + # For testing purposes, we just sic SIGUSR1 / SIGUSR2 at the process. +@@ -153,8 +153,11 @@ cmp $filename F/prog2 + cat vlog + grep -q Progress vlog + tempfiles vlog +-filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID2` ++filename=`testrun env DEBUGINFOD_PROGRESS=1 ${abs_top_builddir}/debuginfod/debuginfod-find executable $BUILDID2 2>vlog2` + cmp $filename F/prog2 ++cat vlog2 ++grep -q Downloading vlog2 ++tempfiles vlog2 + filename=`testrun ${abs_top_builddir}/debuginfod/debuginfod-find source $BUILDID2 ${PWD}/prog2.c` + cmp $filename ${PWD}/prog2.c + + +commit 288c76775f2d27976eb269e568b53c742d973dbc +Author: Frank Ch. Eigler +Date: Mon Jan 6 04:29:21 2020 -0500 + + debuginfod: pass a distro-summary User-Agent request header + + It may be useful for a debuginfod server operator to know what kinds + of clients make webapi requests. This is mainly as a + telemetry/diagnostic (though the data cannot be really trusted). It + may also be useful to automate downloading of distro packages to a + debuginfod server in the case of an unknown hex buildid. doc/testing + not affected as these are diagnostics. + + Signed-off-by: Frank Ch. Eigler + Signed-off-by: Mark Wielaard + +diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c +index 9a4a0e0..66ccb21 100644 +--- a/debuginfod/debuginfod-client.c ++++ b/debuginfod/debuginfod-client.c +@@ -1,5 +1,5 @@ + /* Retrieve ELF / DWARF / source files from the debuginfod. +- Copyright (C) 2019 Red Hat, Inc. ++ Copyright (C) 2019-2020 Red Hat, Inc. + This file is part of elfutils. + + This file is free software; you can redistribute it and/or modify +@@ -58,6 +58,7 @@ + #include + #include + #include ++#include + #include + + /* If fts.h is included before config.h, its indirect inclusions may not +@@ -279,6 +280,87 @@ debuginfod_clean_cache(debuginfod_client *c, + #define MAX_BUILD_ID_BYTES 64 + + ++static void ++add_extra_headers(CURL *handle) ++{ ++ /* Compute a User-Agent: string to send. The more accurately this ++ describes this host, the likelier that the debuginfod servers ++ might be able to locate debuginfo for us. */ ++ ++ char* utspart = NULL; ++ struct utsname uts; ++ int rc = 0; ++ rc = uname (&uts); ++ if (rc == 0) ++ rc = asprintf(& utspart, "%s/%s", uts.sysname, uts.machine); ++ if (rc < 0) ++ utspart = NULL; ++ ++ FILE *f = fopen ("/etc/os-release", "r"); ++ if (f == NULL) ++ f = fopen ("/usr/lib/os-release", "r"); ++ char *id = NULL; ++ char *version = NULL; ++ if (f != NULL) ++ { ++ while (id == NULL || version == NULL) ++ { ++ char buf[128]; ++ char *s = &buf[0]; ++ if (fgets (s, sizeof(buf), f) == NULL) ++ break; ++ ++ int len = strlen (s); ++ if (len < 3) ++ continue; ++ if (s[len - 1] == '\n') ++ { ++ s[len - 1] = '\0'; ++ len--; ++ } ++ ++ char *v = strchr (s, '='); ++ if (v == NULL || strlen (v) < 2) ++ continue; ++ ++ /* Split var and value. */ ++ *v = '\0'; ++ v++; ++ ++ /* Remove optional quotes around value string. */ ++ if (*v == '"' || *v == '\'') ++ { ++ v++; ++ s[len - 1] = '\0'; ++ } ++ if (strcmp (s, "ID") == 0) ++ id = strdup (v); ++ if (strcmp (s, "VERSION_ID") == 0) ++ version = strdup (v); ++ } ++ fclose (f); ++ } ++ ++ char *ua = NULL; ++ rc = asprintf(& ua, "%s/%s,%s,%s/%s", ++ PACKAGE_NAME, PACKAGE_VERSION, ++ utspart ?: "", ++ id ?: "", ++ version ?: ""); ++ if (rc < 0) ++ ua = NULL; ++ ++ if (ua) ++ curl_easy_setopt(handle, CURLOPT_USERAGENT, (void*) ua); /* implicit strdup */ ++ ++ free (ua); ++ free (id); ++ free (version); ++ free (utspart); ++} ++ ++ ++ + /* Query each of the server URLs found in $DEBUGINFOD_URLS for the file + with the specified build-id, type (debuginfo, executable or source) + and filename. filename may be NULL. If found, return a file +@@ -514,7 +596,7 @@ debuginfod_query_server (debuginfod_client *c, + curl_easy_setopt(data[i].handle, CURLOPT_NOSIGNAL, (long) 1); + curl_easy_setopt(data[i].handle, CURLOPT_AUTOREFERER, (long) 1); + curl_easy_setopt(data[i].handle, CURLOPT_ACCEPT_ENCODING, ""); +- curl_easy_setopt(data[i].handle, CURLOPT_USERAGENT, (void*) PACKAGE_STRING); ++ add_extra_headers(data[i].handle); + + curl_multi_add_handle(curlm, data[i].handle); + server_url = strtok_r(NULL, url_delim, &strtok_saveptr); + +commit b8d85ed024a745cff05e56c6337d95d654d5294a +Author: Mark Wielaard +Date: Thu Jan 2 17:02:42 2020 +0100 + + debuginfod: Use DEBUGINFOD_TIMEOUT as seconds to get at least 100K. + + Use just one timeout using CURLOPT_LOW_SPEED_TIME (default 90 seconds) + and CURLOPT_LOW_SPEED_LIMIT (100K). + + Signed-off-by: Mark Wielaard + +diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c +index 66ccb21..e5a2e82 100644 +--- a/debuginfod/debuginfod-client.c ++++ b/debuginfod/debuginfod-client.c +@@ -105,10 +105,9 @@ static const char *server_urls_envvar = DEBUGINFOD_URLS_ENV_VAR; + static const char *url_delim = " "; + static const char url_delim_char = ' '; + +-/* Timeout for debuginfods, in seconds. */ ++/* Timeout for debuginfods, in seconds (to get at least 100K). */ + static const char *server_timeout_envvar = DEBUGINFOD_TIMEOUT_ENV_VAR; +-static const long default_connect_timeout = 5; +-static const long default_transfer_timeout = -1; /* unlimited */ ++static const long default_timeout = 90; + + + /* Data associated with a particular CURL easy handle. Passed to +@@ -483,18 +482,10 @@ debuginfod_query_server (debuginfod_client *c, + return fd; + } + +- long connect_timeout = default_connect_timeout; +- long transfer_timeout = default_transfer_timeout; ++ long timeout = default_timeout; + const char* timeout_envvar = getenv(server_timeout_envvar); + if (timeout_envvar != NULL) +- { +- long ct, tt; +- rc = sscanf(timeout_envvar, "%ld,%ld", &ct, &tt); +- if (rc >= 1) +- connect_timeout = ct; +- if (rc >= 2) +- transfer_timeout = tt; +- } ++ timeout = atoi (timeout_envvar); + + /* make a copy of the envvar so it can be safely modified. */ + server_urls = strdup(urls_envvar); +@@ -586,10 +577,15 @@ debuginfod_query_server (debuginfod_client *c, + CURLOPT_WRITEFUNCTION, + debuginfod_write_callback); + curl_easy_setopt(data[i].handle, CURLOPT_WRITEDATA, (void*)&data[i]); +- if (connect_timeout >= 0) +- curl_easy_setopt(data[i].handle, CURLOPT_CONNECTTIMEOUT, connect_timeout); +- if (transfer_timeout >= 0) +- curl_easy_setopt(data[i].handle, CURLOPT_TIMEOUT, transfer_timeout); ++ if (timeout > 0) ++ { ++ /* Make sure there is at least some progress, ++ try to get at least 100K per timeout seconds. */ ++ curl_easy_setopt (data[i].handle, CURLOPT_LOW_SPEED_TIME, ++ timeout); ++ curl_easy_setopt (data[i].handle, CURLOPT_LOW_SPEED_LIMIT, ++ 100 * 1024L); ++ } + curl_easy_setopt(data[i].handle, CURLOPT_FILETIME, (long) 1); + curl_easy_setopt(data[i].handle, CURLOPT_FOLLOWLOCATION, (long) 1); + curl_easy_setopt(data[i].handle, CURLOPT_FAILONERROR, (long) 1); +diff --git a/doc/debuginfod-find.1 b/doc/debuginfod-find.1 +index 023acbb..e71ca29 100644 +--- a/doc/debuginfod-find.1 ++++ b/doc/debuginfod-find.1 +@@ -119,13 +119,10 @@ debuginfod instances. Alternate URL prefixes are separated by space. + + .TP 21 + .B DEBUGINFOD_TIMEOUT +-This environment variable governs the timeouts for each debuginfod +-HTTP connection. One or two comma-separated numbers may be given. +-The first is the number of seconds for the connection establishment +-(CURLOPT_CONNECTTIMEOUT), and the default is 5. The second is the +-number of seconds for the transfer completion (CURLOPT_TIMEOUT), and +-the default is no timeout. (Zero or negative also means "no +-timeout".) ++This environment variable governs the timeout for each debuginfod HTTP ++connection. A server that fails to provide at least 100K of data ++within this many seconds is skipped. The default is 90 seconds. (Zero ++or negative means "no timeout".) + + .TP 21 + .B DEBUGINFOD_CACHE_PATH +diff --git a/doc/debuginfod.8 b/doc/debuginfod.8 +index 342f524..6184bcc 100644 +--- a/doc/debuginfod.8 ++++ b/doc/debuginfod.8 +@@ -366,8 +366,10 @@ or indirectly - the results would be hilarious. + .TP 21 + .B DEBUGINFOD_TIMEOUT + This environment variable governs the timeout for each debuginfod HTTP +-connection. A server that fails to respond within this many seconds +-is skipped. The default is 5. ++connection. A server that fails to provide at least 100K of data ++within this many seconds is skipped. The default is 90 seconds. (Zero ++or negative means "no timeout".) ++ + + .TP 21 + .B DEBUGINFOD_CACHE_PATH +diff --git a/doc/debuginfod_find_debuginfo.3 b/doc/debuginfod_find_debuginfo.3 +index ea8c616..f6ea7a4 100644 +--- a/doc/debuginfod_find_debuginfo.3 ++++ b/doc/debuginfod_find_debuginfo.3 +@@ -163,13 +163,10 @@ debuginfod instances. Alternate URL prefixes are separated by space. + + .TP 21 + .B DEBUGINFOD_TIMEOUT +-This environment variable governs the timeouts for each debuginfod +-HTTP connection. One or two comma-separated numbers may be given. +-The first is the number of seconds for the connection establishment +-(CURLOPT_CONNECTTIMEOUT), and the default is 5. The second is the +-number of seconds for the transfer completion (CURLOPT_TIMEOUT), and +-the default is no timeout. (Zero or negative also means "no +-timeout".) ++This environment variable governs the timeout for each debuginfod HTTP ++connection. A server that fails to provide at least 100K of data ++within this many seconds is skipped. The default is 90 seconds. (Zero ++or negative means "no timeout".) + + .TP 21 + .B DEBUGINFOD_PROGRESS +diff --git a/tests/run-debuginfod-find.sh b/tests/run-debuginfod-find.sh +index 90dafe0..4ab47a3 100755 +--- a/tests/run-debuginfod-find.sh ++++ b/tests/run-debuginfod-find.sh +@@ -94,7 +94,7 @@ wait_ready $PORT1 'ready' 1 + export DEBUGINFOD_URLS=http://127.0.0.1:$PORT1/ # or without trailing / + + # Be patient when run on a busy machine things might take a bit. +-export DEBUGINFOD_TIMEOUT=1,10 ++export DEBUGINFOD_TIMEOUT=10 + + # We use -t0 and -g0 here to turn off time-based scanning & grooming. + # For testing purposes, we just sic SIGUSR1 / SIGUSR2 at the process. + +commit 6f2098114a1acbd5e320a1c5fabfa07df02b14fd +Author: Mark Wielaard +Date: Fri Jan 10 15:46:29 2020 +0100 + + doc: Fix DEBUGINFOD_PROGRESS description to just mention output on stderr. + + An earlier variant of the default progress function could write to any + file. Which is still in the documentation. But the actual implementation + just uses stderr. Fix the documentation to match. + + Signed-off-by: Mark Wielaard + +diff --git a/doc/debuginfod_find_debuginfo.3 b/doc/debuginfod_find_debuginfo.3 +index f6ea7a4..7e5060f 100644 +--- a/doc/debuginfod_find_debuginfo.3 ++++ b/doc/debuginfod_find_debuginfo.3 +@@ -173,8 +173,8 @@ or negative means "no timeout".) + This environment variable governs the default progress function. If + set, and if a progressfn is not explicitly set, then the library will + configure a default progressfn. This function will append a simple +-progress message periodically to the given file. Consider using +-"/dev/stderr" on platforms that support it. The default is nothing. ++progress message periodically to stderr. The default is no progress ++function output. + + .TP 21 + .B DEBUGINFOD_CACHE_PATH diff --git a/SOURCES/elfutils-0.178-libasm-ebl.patch b/SOURCES/elfutils-0.178-libasm-ebl.patch new file mode 100644 index 0000000..784c62b --- /dev/null +++ b/SOURCES/elfutils-0.178-libasm-ebl.patch @@ -0,0 +1,146 @@ +commit 985550a5b24009e9cb9e511f6d320f3ac1b6bf99 +Author: Mark Wielaard +Date: Wed Jan 8 15:04:50 2020 +0100 + + libasm.h: Don't include libebl.h. Define an opaque Ebl handle. + + Using libasm isn't really usable without a way to create an Ebl handle. + But we don't support libebl.h (and libebl itself). Just define the + Ebl handle as an opaque struct. Code that uses it needs to figure out + how to instantiate one itself (they cannot in any supportable way...) + + Signed-off-by: Mark Wielaard + +diff --git a/libasm/libasm.h b/libasm/libasm.h +index 5c61224..a45c9fa 100644 +--- a/libasm/libasm.h ++++ b/libasm/libasm.h +@@ -32,7 +32,7 @@ + #include + #include + +-#include ++typedef struct ebl Ebl; + + + /* Opaque type for the assembler context descriptor. */ +diff --git a/libasm/libasmP.h b/libasm/libasmP.h +index 54460cf..a4703fc 100644 +--- a/libasm/libasmP.h ++++ b/libasm/libasmP.h +@@ -31,6 +31,7 @@ + + #include + ++#include "libebl.h" + #include + + #include "libdwelf.h" +diff --git a/tests/asm-tst1.c b/tests/asm-tst1.c +index 9afc676..cdf2a92 100644 +--- a/tests/asm-tst1.c ++++ b/tests/asm-tst1.c +@@ -20,6 +20,7 @@ + #endif + + #include ++#include ELFUTILS_HEADER(ebl) + #include ELFUTILS_HEADER(asm) + #include + #include +diff --git a/tests/asm-tst2.c b/tests/asm-tst2.c +index 2556d0c..9e88b70 100644 +--- a/tests/asm-tst2.c ++++ b/tests/asm-tst2.c +@@ -20,6 +20,7 @@ + #endif + + #include ++#include ELFUTILS_HEADER(ebl) + #include ELFUTILS_HEADER(asm) + #include + #include +diff --git a/tests/asm-tst3.c b/tests/asm-tst3.c +index e52cfbe..39c1d90 100644 +--- a/tests/asm-tst3.c ++++ b/tests/asm-tst3.c +@@ -20,6 +20,7 @@ + #endif + + #include ++#include ELFUTILS_HEADER(ebl) + #include ELFUTILS_HEADER(asm) + #include + #include +diff --git a/tests/asm-tst4.c b/tests/asm-tst4.c +index 52e9e20..5114938 100644 +--- a/tests/asm-tst4.c ++++ b/tests/asm-tst4.c +@@ -20,6 +20,7 @@ + #endif + + #include ++#include ELFUTILS_HEADER(ebl) + #include ELFUTILS_HEADER(asm) + #include + #include +diff --git a/tests/asm-tst5.c b/tests/asm-tst5.c +index 5a29b01..dcb852f 100644 +--- a/tests/asm-tst5.c ++++ b/tests/asm-tst5.c +@@ -20,6 +20,7 @@ + #endif + + #include ++#include ELFUTILS_HEADER(ebl) + #include ELFUTILS_HEADER(asm) + #include + #include +diff --git a/tests/asm-tst6.c b/tests/asm-tst6.c +index bd9b362..829cd90 100644 +--- a/tests/asm-tst6.c ++++ b/tests/asm-tst6.c +@@ -19,6 +19,7 @@ + # include + #endif + ++#include ELFUTILS_HEADER(ebl) + #include ELFUTILS_HEADER(asm) + #include + #include +diff --git a/tests/asm-tst7.c b/tests/asm-tst7.c +index 00cb2bf..9017976 100644 +--- a/tests/asm-tst7.c ++++ b/tests/asm-tst7.c +@@ -21,6 +21,7 @@ + + #include + #include ++#include ELFUTILS_HEADER(ebl) + #include ELFUTILS_HEADER(asm) + #include + #include +diff --git a/tests/asm-tst8.c b/tests/asm-tst8.c +index 4fb0d99..a65509f 100644 +--- a/tests/asm-tst8.c ++++ b/tests/asm-tst8.c +@@ -21,6 +21,7 @@ + + #include + #include ++#include ELFUTILS_HEADER(ebl) + #include ELFUTILS_HEADER(asm) + #include + #include +diff --git a/tests/asm-tst9.c b/tests/asm-tst9.c +index b6d0e43..681e872 100644 +--- a/tests/asm-tst9.c ++++ b/tests/asm-tst9.c +@@ -21,6 +21,7 @@ + + #include + #include ++#include ELFUTILS_HEADER(ebl) + #include ELFUTILS_HEADER(asm) + #include + #include diff --git a/SOURCES/elfutils-0.178-pt-gnu-prop.patch b/SOURCES/elfutils-0.178-pt-gnu-prop.patch new file mode 100644 index 0000000..917765b --- /dev/null +++ b/SOURCES/elfutils-0.178-pt-gnu-prop.patch @@ -0,0 +1,18 @@ +diff --git a/src/elflint.c b/src/elflint.c +index 810c8bd..1acf1bc 100644 +--- a/src/elflint.c ++++ b/src/elflint.c +@@ -4483,8 +4483,13 @@ only executables, shared objects, and core files can have program headers\n")); + continue; + } + ++#ifndef PT_GNU_PROPERTY ++#define PT_GNU_PROPERTY (PT_LOOS + 0x474e553) ++#endif ++ + if (phdr->p_type >= PT_NUM && phdr->p_type != PT_GNU_EH_FRAME + && phdr->p_type != PT_GNU_STACK && phdr->p_type != PT_GNU_RELRO ++ && phdr->p_type != PT_GNU_PROPERTY + /* Check for a known machine-specific type. */ + && ebl_segment_type_name (ebl, phdr->p_type, NULL, 0) == NULL) + ERROR (gettext ("\ diff --git a/SPECS/elfutils.spec b/SPECS/elfutils.spec index 5dcd987..afa8646 100644 --- a/SPECS/elfutils.spec +++ b/SPECS/elfutils.spec @@ -1,55 +1,66 @@ Name: elfutils -Summary: A collection of utilities and DSOs to handle ELF files and DWARF data -Version: 0.176 -%global baserelease 5 +Version: 0.178 +%global baserelease 7 +Release: %{baserelease}%{?dist} URL: http://elfutils.org/ %global source_url ftp://sourceware.org/pub/elfutils/%{version}/ -License: GPLv3+ and (GPLv2+ or LGPLv3+) -Group: Development/Tools - -Release: %{baserelease}%{?dist} - -%global provide_yama_scope 0 - -%if 0%{?fedora} >= 22 || 0%{?rhel} >= 7 -%global provide_yama_scope 1 -%endif - -%global depsuffix %{?_isa}%{!?_isa:-%{_arch}} - +License: GPLv3+ and (GPLv2+ or LGPLv3+) and GFDL Source: %{?source_url}%{name}-%{version}.tar.bz2 +Summary: A collection of utilities and DSOs to handle ELF files and DWARF data -# Patches -Patch1: elfutils-0.176-gcc-pr88835.patch -Patch2: elfutils-0.176-xlate-note.patch -Patch3: elfutils-0.176-elf-update.patch -Patch4: elfutils-0.176-strip-symbols-illformed.patch +# Needed for isa specific Provides and Requires. +%global depsuffix %{?_isa}%{!?_isa:-%{_arch}} Requires: elfutils-libelf%{depsuffix} = %{version}-%{release} Requires: elfutils-libs%{depsuffix} = %{version}-%{release} +%if 0%{?rhel} >= 8 || 0%{?fedora} >= 20 +Recommends: elfutils-debuginfod-client%{depsuffix} = %{version}-%{release} +%else +Requires: elfutils-debuginfod-client%{depsuffix} = %{version}-%{release} +%endif -BuildRequires: gettext -BuildRequires: bison >= 1.875 -BuildRequires: flex >= 2.5.4a -BuildRequires: bzip2 -BuildRequires: gcc >= 4.4 +BuildRequires: gcc # For libstdc++ demangle support BuildRequires: gcc-c++ -BuildRequires: zlib-devel >= 1.2.2.3 +BuildRequires: gettext +BuildRequires: bison +BuildRequires: flex + +# Compression support +BuildRequires: zlib-devel BuildRequires: bzip2-devel BuildRequires: xz-devel +# For debuginfod +BuildRequires: pkgconfig(libmicrohttpd) >= 0.9.33 +BuildRequires: pkgconfig(libcurl) >= 7.29.0 +BuildRequires: pkgconfig(sqlite3) >= 3.7.17 +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 +BuildRequires: iproute +BuildRequires: curl + %global _gnu %{nil} %global _program_prefix eu- -# The lib[64]/elfutils directory contains the private ebl backend -# libraries. They must not be exposed as global provides. We don't -# need to filter the requires since they are only loaded with dlopen. -%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7 -%global __provides_exclude ^libebl_.*\\.so.*$ +%global provide_yama_scope 0 + +%if 0%{?fedora} >= 22 || 0%{?rhel} >= 7 +%global provide_yama_scope 1 %endif +# Patches +Patch1: elfutils-0.178-pt-gnu-prop.patch +Patch2: elfutils-0.178-debuginfod-no-cache.patch +Patch3: elfutils-0.178-curl-code-gcc-10.patch +Patch4: elfutils-0.178-compressed-vmlinuz.patch +Patch5: elfutils-0.178-debuginfod-timeoutprogress.patch +Patch6: elfutils-0.178-libasm-ebl.patch + %description Elfutils is a collection of utilities, including stack (to show backtraces), nm (for listing symbols from object files), size @@ -58,10 +69,8 @@ strip (for discarding symbols), readelf (to see the raw ELF file structures), elflint (to check for well-formed ELF files) and elfcompress (to compress or decompress ELF sections). - %package libs Summary: Libraries to handle compiled objects -Group: Development/Tools License: GPLv2+ or LGPLv3+ %if 0%{!?_isa:1} Provides: elfutils-libs%{depsuffix} = %{version}-%{release} @@ -70,33 +79,41 @@ Requires: elfutils-libelf%{depsuffix} = %{version}-%{release} %if %{provide_yama_scope} Requires: default-yama-scope %endif +%if 0%{?rhel} >= 8 || 0%{?fedora} >= 20 +Recommends: elfutils-debuginfod-client%{depsuffix} = %{version}-%{release} +%else +Requires: elfutils-debuginfod-client%{depsuffix} = %{version}-%{release} +%endif %description libs The elfutils-libs package contains libraries which implement DWARF, ELF, -and machine-specific ELF handling. These libraries are used by the programs -in the elfutils package. The elfutils-devel package enables building -other programs using these libraries. +and machine-specific ELF handling and process introspection. These +libraries are used by the programs in the elfutils package. The +elfutils-devel package enables building other programs using these +libraries. %package devel Summary: Development libraries to handle compiled objects -Group: Development/Tools License: GPLv2+ or LGPLv3+ %if 0%{!?_isa:1} Provides: elfutils-devel%{depsuffix} = %{version}-%{release} %endif Requires: elfutils-libs%{depsuffix} = %{version}-%{release} Requires: elfutils-libelf-devel%{depsuffix} = %{version}-%{release} +%if 0%{?rhel} >= 8 || 0%{?fedora} >= 20 +Recommends: elfutils-debuginfod-client-devel%{depsuffix} = %{version}-%{release} +%else +Requires: elfutils-debuginfod-client-devel%{depsuffix} = %{version}-%{release} +%endif %description devel The elfutils-devel package contains the libraries to create -applications for handling compiled objects. libebl provides some -higher-level ELF access functionality. libdw provides access to -the DWARF debugging information. libasm provides a programmable +applications for handling compiled objects. libdw provides access +to the DWARF debugging information. libasm provides a programmable assembler interface. %package devel-static Summary: Static archives to handle compiled objects -Group: Development/Tools License: GPLv2+ or LGPLv3+ %if 0%{!?_isa:1} Provides: elfutils-devel-static%{depsuffix} = %{version}-%{release} @@ -110,7 +127,6 @@ with the code to handle compiled objects. %package libelf Summary: Library to read and write ELF files -Group: Development/Tools License: GPLv2+ or LGPLv3+ %if 0%{!?_isa:1} Provides: elfutils-libelf%{depsuffix} = %{version}-%{release} @@ -125,7 +141,6 @@ elfutils package use it also to generate new ELF files. %package libelf-devel Summary: Development support for libelf -Group: Development/Tools License: GPLv2+ or LGPLv3+ %if 0%{!?_isa:1} Provides: elfutils-libelf-devel%{depsuffix} = %{version}-%{release} @@ -141,7 +156,6 @@ different sections of an ELF file. %package libelf-devel-static Summary: Static archive of libelf -Group: Development/Tools License: GPLv2+ or LGPLv3+ %if 0%{!?_isa:1} Provides: elfutils-libelf-devel-static%{depsuffix} = %{version}-%{release} @@ -155,7 +169,6 @@ for libelf. %if %{provide_yama_scope} %package default-yama-scope Summary: Default yama attach scope sysctl setting -Group: Development/Tools License: GPLv2+ or LGPLv3+ Provides: default-yama-scope BuildArch: noarch @@ -188,23 +201,67 @@ interprocess services, communication and introspection profiling) of processes. %endif +%package debuginfod-client +Summary: Library and command line client for build-id HTTP ELF/DWARF server +License: GPLv3+ and (GPLv2+ or LGPLv3+) +%if 0%{!?_isa:1} +Provides: elfutils-debuginfod-client%{depsuffix} = %{version}-%{release} +%endif + +%package debuginfod-client-devel +Summary: Libraries and headers to build debuginfod client applications +License: GPLv2+ or LGPLv3+ +%if 0%{!?_isa:1} +Provides: elfutils-debuginfod-client-devel%{depsuffix} = %{version}-%{release} +%endif +Requires: elfutils-debuginfod-client%{depsuffix} = %{version}-%{release} + +%package debuginfod +Summary: HTTP ELF/DWARF file server addressed by build-id +License: GPLv3+ +Requires: elfutils-libs%{depsuffix} = %{version}-%{release} +Requires: elfutils-libelf%{depsuffix} = %{version}-%{release} +Requires: elfutils-debuginfod-client%{depsuffix} = %{version}-%{release} +BuildRequires: systemd +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd +Requires(pre): shadow-utils +# For /usr/bin/cpio2rpm +Requires: rpm + +%description debuginfod-client +The elfutils-debuginfod-client package contains shared libraries +dynamically loaded from -ldw, which use a debuginfod service +to look up debuginfo and associated data. Also includes a +command-line frontend. + +%description debuginfod-client-devel +The elfutils-debuginfod-client-devel package contains the libraries +to create applications to use the debuginfod service. + +%description debuginfod +The elfutils-debuginfod package contains the debuginfod binary +and control files for a service that can provide ELF/DWARF +files to remote clients, based on build-id identification. +The ELF/DWARF file searching functions in libdwfl can query +such servers to download those files on demand. + %prep %setup -q # Apply patches -%patch1 -p1 -b .gcc-pr88835 -%patch2 -p1 -b .xlate-note -%patch3 -p1 -b .elf-update -%patch4 -p1 -b .strip-illformed +%patch1 -p1 -b .pt-gnu-prop +%patch2 -p1 -b .debuginfod-client-cache +%patch3 -p1 -b .curl-gcc-10 +%patch4 -p1 -b .vmlinuz +%patch5 -p1 -b .debuginfod-timeout-progress +%patch6 -p1 -b .libasm-ebl # In case the above patches added any new test scripts, make sure they # are executable. find . -name \*.sh ! -perm -0100 -print | xargs chmod +x -%ifarch %{arm} -echo -e '"dwarf: arm needs debuginfo installed for all libraries"\nexit 77' > tests/run-backtrace-native-core.sh -%endif - %build # Remove -Wall from default flags. The makefiles enable enough warnings # themselves, and they use -Werror. Appending -Wall defeats the cases where @@ -225,7 +282,6 @@ rm -rf ${RPM_BUILD_ROOT} make -s install DESTDIR=${RPM_BUILD_ROOT} chmod +x ${RPM_BUILD_ROOT}%{_prefix}/%{_lib}/lib*.so* -chmod +x ${RPM_BUILD_ROOT}%{_prefix}/%{_lib}/elfutils/lib*.so* %find_lang %{name} @@ -233,9 +289,14 @@ chmod +x ${RPM_BUILD_ROOT}%{_prefix}/%{_lib}/elfutils/lib*.so* install -Dm0644 config/10-default-yama-scope.conf ${RPM_BUILD_ROOT}%{_sysctldir}/10-default-yama-scope.conf %endif +install -Dm0644 config/debuginfod.service ${RPM_BUILD_ROOT}%{_unitdir}/debuginfod.service +install -Dm0644 config/debuginfod.sysconfig ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/debuginfod +mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/cache/debuginfod +touch ${RPM_BUILD_ROOT}%{_localstatedir}/cache/debuginfod/debuginfod.sqlite + %check # Record some build root versions in build.log -uname -r; rpm -q glibc +uname -r; rpm -q binutils gcc glibc make -s %{?_smp_mflags} check || (cat tests/test-suite.log; false) @@ -244,11 +305,14 @@ make -s %{?_smp_mflags} check || (cat tests/test-suite.log; false) %if 0%{?ldconfig_scriptlets:1} %ldconfig_scriptlets libs %ldconfig_scriptlets libelf +%ldconfig_scriptlets debuginfod-client %else %post libs -p /sbin/ldconfig %postun libs -p /sbin/ldconfig %post libelf -p /sbin/ldconfig %postun libelf -p /sbin/ldconfig +%post debuginfod-client -p /sbin/ldconfig +%postun debuginfod-client -p /sbin/ldconfig %endif %if %{provide_yama_scope} @@ -262,13 +326,16 @@ fi %files %{!?_licensedir:%global license %%doc} -%license COPYING COPYING-GPLV2 COPYING-LGPLV3 +%license COPYING COPYING-GPLV2 COPYING-LGPLV3 doc/COPYING-GFDL %doc README TODO CONTRIBUTING %{_bindir}/eu-addr2line %{_bindir}/eu-ar +%{_bindir}/eu-elfclassify %{_bindir}/eu-elfcmp +%{_bindir}/eu-elfcompress %{_bindir}/eu-elflint %{_bindir}/eu-findtextrel +%{_bindir}/eu-make-debug-archive %{_bindir}/eu-nm %{_bindir}/eu-objdump %{_bindir}/eu-ranlib @@ -278,18 +345,15 @@ fi %{_bindir}/eu-strings %{_bindir}/eu-strip %{_bindir}/eu-unstrip -%{_bindir}/eu-make-debug-archive -%{_bindir}/eu-elfcompress +%{_mandir}/man1/eu-*.1* %files libs %{!?_licensedir:%global license %%doc} %license COPYING-GPLV2 COPYING-LGPLV3 %{_libdir}/libasm-%{version}.so -%{_libdir}/libasm.so.* %{_libdir}/libdw-%{version}.so +%{_libdir}/libasm.so.* %{_libdir}/libdw.so.* -%dir %{_libdir}/elfutils -%{_libdir}/elfutils/lib*.so %files devel %{_includedir}/dwarf.h @@ -297,19 +361,17 @@ fi %{_includedir}/elfutils/elf-knowledge.h %{_includedir}/elfutils/known-dwarf.h %{_includedir}/elfutils/libasm.h -%{_includedir}/elfutils/libebl.h %{_includedir}/elfutils/libdw.h %{_includedir}/elfutils/libdwfl.h %{_includedir}/elfutils/libdwelf.h %{_includedir}/elfutils/version.h -%{_libdir}/libebl.a %{_libdir}/libasm.so %{_libdir}/libdw.so %{_libdir}/pkgconfig/libdw.pc %files devel-static -%{_libdir}/libasm.a %{_libdir}/libdw.a +%{_libdir}/libasm.a %files -f %{name}.lang libelf %{!?_licensedir:%global license %%doc} @@ -323,6 +385,7 @@ fi %{_includedir}/nlist.h %{_libdir}/libelf.so %{_libdir}/pkgconfig/libelf.pc +%{_mandir}/man3/elf_*.3* %files libelf-devel-static %{_libdir}/libelf.a @@ -332,7 +395,78 @@ fi %{_sysctldir}/10-default-yama-scope.conf %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) %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 +%verify(not md5 size mtime) %attr(0600,debuginfod,debuginfod) %{_localstatedir}/cache/debuginfod/debuginfod.sqlite + +%pre debuginfod +getent group debuginfod >/dev/null || groupadd -r debuginfod +getent passwd debuginfod >/dev/null || \ + useradd -r -g debuginfod -d /var/cache/debuginfod -s /sbin/nologin \ + -c "elfutils debuginfo server" debuginfod +exit 0 + +%post debuginfod +%systemd_post debuginfod.service + +%postun debuginfod +%systemd_postun_with_restart debuginfod.service + %changelog +* Fri Jan 10 2020 Mark Wielaard - 0.178-7 +- Add elfutils-0.178-debuginfod-timeoutprogress.patch +- Add elfutils-0.178-libasm-ebl.patch + +* Fri Dec 13 2019 Mark Wielaard - 0.178-6 +- Add elfutils-0.178-curl-code-gcc-10.patch +- Add elfutils-0.178-compressed-vmlinuz.patch + +* Mon Dec 9 2019 Mark Wielaard - 0.178-5 +- Add elfutils-0.178-debuginfod-no-cache.patch. #1781097 + +* Thu Nov 28 2019 Mark Wielaard - 0.178-4 +- Add elfutils-debuginfod-client Provides and Requires with depsuffix + to get multilib dependencies correct. Add %%{version}-%%{release} to + keep subpackages in sync. + +* Tue Nov 26 2019 Mark Wielaard - 0.178-2 +- New upstream release. + - debuginfod: New server, client tool and library to index and fetch + ELF/DWARF files addressed by build-id through HTTP. + - doc: There are now some manual pages for functions and tools. + - backends: The libebl libraries are no longer dynamically loaded + through dlopen, but are now compiled into libdw.so directly. + - readelf: -n, --notes now takes an optional "SECTION" argument. + -p and -x now also handle section numbers. + New option --dyn-sym to show just the dynamic symbol table. + - libcpu: Add RISC-V disassembler. + - libdw: Abbrevs and DIEs can now be read concurrently by multiple + threads through the same Dwarf handle. + - libdwfl: Will try to use debuginfod when installed as fallback to + retrieve ELF and DWARF debug data files by build-id. +- Fix libdebuginfod file list for debuginfo-client[-devel]. + * Fri Jul 5 2019 Mark Wielaard - 0.176-5 - Add elfutils-0.176-strip-symbols-illformed.patch