Compare commits

..

No commits in common. "imports/c8s/gcc-toolset-10-elfutils-0.176-6.el8" and "c8" have entirely different histories.

15 changed files with 517 additions and 1860 deletions

View File

@ -1 +1 @@
6511203cae7225ae780501834a7ccd234b14889a SOURCES/elfutils-0.176.tar.bz2 3efc2253564a2ca8be0a5cf9aba3e4b5f544ee22 SOURCES/elfutils-0.182.tar.bz2

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/elfutils-0.176.tar.bz2 SOURCES/elfutils-0.182.tar.bz2

View File

@ -1,664 +0,0 @@
commit d7193bd7c9dc2a979352eee7fc446dacd3e97779
Author: Mark Wielaard <mark@klomp.org>
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 <mark@klomp.org>
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 <http://www.gnu.org/licenses/>. */
+
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include ELFUTILS_HEADER(elf)
+#include <gelf.h>
+
+
+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 <http://www.gnu.org/licenses/>.
+
+. $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 <http://www.gnu.org/licenses/>.
+
+. $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)))

View File

@ -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 ?: "<null>");
pid_t tid = dwfl_thread_tid (thread);
callback_verify (tid, *framenop, pc, symname, dwfl);
(*framenop)++;

View File

@ -1,18 +0,0 @@
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 ("\

View File

@ -1,26 +0,0 @@
commit f03ac75239e0981deaf4aa18f66f423bcc5ce051
Author: Mark Wielaard <mark@klomp.org>
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 <mark@klomp.org>
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)

View File

@ -1,486 +0,0 @@
commit 28b5f578ae772bb2404c3847e4e22ad1c407af54
Author: Mark Wielaard <mark@klomp.org>
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 <mark@klomp.org>
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 <http://www.gnu.org/licenses/>.
+
+. $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 <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include ELFUTILS_HEADER(elf)
+#include <gelf.h>
+
+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

View File

@ -0,0 +1,43 @@
commit f172a31c56405750114924eba0786999bccc501f
Author: Mark Wielaard <mark@klomp.org>
Date: Mon Nov 2 15:20:54 2020 +0100
tests: Create bogus R/nothing.rpm with cyclic symlink.
We used to try to trigger an error during debuginfod scanning using
a chmod 000 file. But this doesn't always result in an error. Create
a cyclic symlink instead, which always results in a failure to open/read.
Signed-off-by: Mark Wielaard <mark@klomp.org>
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 57fc4c8e..2f8b75c3 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,8 @@
+2020-11-02 Mark Wielaard <mark@klomp.org>
+
+ * run-debuginfod-find.sh: Create bogus R/nothing.rpm with cyclic
+ symlink instead of chmod 000.
+
2020-10-31 Mark Wielaard <mark@klomp.org>
* dwfl-proc-attach.c (dlopen): New external function override.
diff --git a/tests/run-debuginfod-find.sh b/tests/run-debuginfod-find.sh
index 48dbc7d4..5af45667 100755
--- a/tests/run-debuginfod-find.sh
+++ b/tests/run-debuginfod-find.sh
@@ -95,9 +95,10 @@ wait_ready()
fi
}
-# create a 000 empty .rpm file to evoke a metric-visible error
-touch R/nothing.rpm
-chmod 000 R/nothing.rpm
+# create a bogus .rpm file to evoke a metric-visible error
+# Use a cyclic symlink instead of chmod 000 to make sure even root
+# would see an error (running the testsuite under root is NOT encouraged).
+ln -s R/nothing.rpm R/nothing.rpm
env LD_LIBRARY_PATH=$ldpath DEBUGINFOD_URLS= ${abs_builddir}/../debuginfod/debuginfod $VERBOSE -F -R -d $DB -p $PORT1 -t0 -g0 --fdcache-fds 1 --fdcache-mbs 2 -Z .tar.xz -Z .tar.bz2=bzcat -v R F Z L > vlog4 2>&1 &
PID1=$!

View File

@ -1,53 +1,30 @@
diff --git a/backends/Makefile.am b/backends/Makefile.am diff --git a/backends/Makefile.am b/backends/Makefile.am
index 2126a2e..3a4e56e 100644 index 62916c9c..d6934de6 100644
--- a/backends/Makefile.am --- a/backends/Makefile.am
+++ b/backends/Makefile.am +++ b/backends/Makefile.am
@@ -41,12 +41,38 @@ libebl_pic = libebl_i386_pic.a libebl_sh_pic.a libebl_x86_64_pic.a \ @@ -95,11 +95,11 @@ riscv_SRCS = riscv_init.c riscv_symbol.c riscv_cfi.c riscv_regs.c \
libebl_m68k_pic.a libebl_bpf_pic.a libebl_riscv_pic.a csky_SRCS = csky_attrs.c csky_init.c csky_symbol.c csky_cfi.c \
noinst_LIBRARIES = $(libebl_pic) csky_regs.c csky_initreg.c csky_corenote.c
noinst_DATA = $(libebl_pic:_pic.a=.so)
+lib_LIBRARIES = libebl_static_pic.a
-libebl_backends_a_SOURCES = $(i386_SRCS) $(sh_SRCS) $(x86_64_SRCS) \
- $(ia64_SRCS) $(alpha_SRCS) $(arm_SRCS) \
- $(aarch64_SRCS) $(sparc_SRCS) $(ppc_SRCS) \
+libebl_backends_a_CFLAGS = -fPIC $(AM_CFLAGS)
+libebl_backends_a_SOURCES = $(i386_SRCS) $(x86_64_SRCS) \
+ $(ia64_SRCS) $(aarch64_SRCS) $(ppc_SRCS) \
$(ppc64_SRCS) $(s390_SRCS) \
- $(m68k_SRCS) $(bpf_SRCS) $(riscv_SRCS) $(csky_SRCS)
+ $(bpf_SRCS)
libelf = ../libelf/libelf.so libebl_backends_pic_a_SOURCES =
libdw = ../libdw/libdw.so am_libebl_backends_pic_a_OBJECTS = $(libebl_backends_a_SOURCES:.c=.os)
libeu = ../lib/libeu.a
+# The following is minimal set of backends that we link with libdw to
+# avoid dlopen. Note repeats files below because some backends reuse
+# each others files.
+static_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_initreg.c i386_unwind.c \
+ 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_unwind.c x32_corenote.c \
+ ia64_init.c ia64_symbol.c ia64_regs.c ia64_retval.c \
+ aarch64_init.c aarch64_regs.c aarch64_symbol.c \
+ aarch64_corenote.c aarch64_retval.c aarch64_cfi.c \
+ aarch64_initreg.c aarch64_unwind.c \
+ 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_cfi.c ppc_initreg.c \
+ ppc64_init.c ppc64_symbol.c ppc64_retval.c ppc64_corenote.c \
+ ppc64_resolve_sym.c ppc64_unwind.c \
+ s390_init.c s390_symbol.c s390_regs.c s390_retval.c \
+ s390_corenote.c s390x_corenote.c s390_cfi.c s390_initreg.c \
+ s390_unwind.c bpf_init.c bpf_regs.c bpf_symbol.c
+
+libebl_static_pic_a_SOURCES = $(static_SRCS)
+am_libebl_static_pic_a_OBJECTS = $(static_SRCS:.c=.os)
+
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_initreg.c i386_unwind.c
diff --git a/configure.ac b/configure.ac diff --git a/configure.ac b/configure.ac
index b4e012d..54ad07a 100644 index 515ac704..b7e76504 100644
--- a/configure.ac --- a/configure.ac
+++ b/configure.ac +++ b/configure.ac
@@ -25,6 +25,12 @@ m4_ifndef([AC_PACKAGE_URL], @@ -19,6 +19,12 @@ dnl You should have received a copy of the GNU General Public License
[Define to home page for this package]) dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
AC_SUBST([PACKAGE_URL], ["http://elfutils.org/"])]) AC_INIT([elfutils],[0.182],[https://sourceware.org/bugzilla],[elfutils],[http://elfutils.org/])
+dnl Workaround for older autoconf < 2.64 +dnl Workaround for older autoconf < 2.64
+m4_ifndef([AC_PACKAGE_URL], +m4_ifndef([AC_PACKAGE_URL],
@ -55,459 +32,204 @@ index b4e012d..54ad07a 100644
+ [Define to home page for this package]) + [Define to home page for this package])
+ AC_SUBST([PACKAGE_URL], ["http://elfutils.org/"])]) + AC_SUBST([PACKAGE_URL], ["http://elfutils.org/"])])
+ +
# We want eu- as default program prefix if none was given by the user. dnl Workaround for older autoconf < 2.64
# But if the user explicitly provided --program-prefix="" then pretend m4_ifndef([AC_PACKAGE_URL],
# it wasn't set at all (NONE). We want to test this really early before [AC_DEFINE([PACKAGE_URL], ["http://elfutils.org/"],
diff --git a/debuginfod/Makefile.am b/debuginfod/Makefile.am
index 01985600..8b07ed0b 100644
--- a/debuginfod/Makefile.am
+++ b/debuginfod/Makefile.am
@@ -77,10 +77,11 @@ debuginfod_find_SOURCES = debuginfod-find.c
debuginfod_find_LDADD = $(libdw) $(libelf) $(libeu) $(libdebuginfod)
if LIBDEBUGINFOD
-noinst_LIBRARIES = libdebuginfod.a
-noinst_LIBRARIES += libdebuginfod_pic.a
+lib_LIBRARIES = libdebuginfod.a
+noinst_LIBRARIES = libdebuginfod_pic.a
endif
+libdebuginfod_a_CFLAGS = -fPIC $(AM_CFLAGS)
libdebuginfod_a_SOURCES = debuginfod-client.c
libdebuginfod_pic_a_SOURCES = debuginfod-client.c
am_libdebuginfod_pic_a_OBJECTS = $(libdebuginfod_a_SOURCES:.c=.os)
diff --git a/libasm/Makefile.am b/libasm/Makefile.am diff --git a/libasm/Makefile.am b/libasm/Makefile.am
index 19fef50..fcc7ffc 100644 index b2bff929..a92b63ad 100644
--- a/libasm/Makefile.am --- a/libasm/Makefile.am
+++ b/libasm/Makefile.am +++ b/libasm/Makefile.am
@@ -38,6 +38,7 @@ noinst_LIBRARIES = libasm_pic.a @@ -38,6 +38,7 @@ noinst_LIBRARIES = libasm_pic.a
noinst_PROGRAMS = $(noinst_LIBRARIES:_pic.a=.so) noinst_PROGRAMS = $(noinst_LIBRARIES:_pic.a=.so)
pkginclude_HEADERS = libasm.h pkginclude_HEADERS = libasm.h
+libasm_a_CFLAGS = -fPIC -fvisibility=hidden $(AM_CFLAGS) +libasm_a_CFLAGS = -fPIC $(AM_CFLAGS)
libasm_a_SOURCES = asm_begin.c asm_abort.c asm_end.c asm_error.c \ libasm_a_SOURCES = asm_begin.c asm_abort.c asm_end.c asm_error.c \
asm_getelf.c asm_newscn.c asm_newscn_ingrp.c \ asm_getelf.c asm_newscn.c asm_newscn_ingrp.c \
asm_newsubscn.c asm_newsym.c asm_newcomsym.c \ asm_newsubscn.c asm_newsym.c asm_newcomsym.c \
diff --git a/libcpu/Makefile.am b/libcpu/Makefile.am
index 4c8778d..f0a1cb8 100644
--- a/libcpu/Makefile.am
+++ b/libcpu/Makefile.am
@@ -36,9 +36,11 @@ LEX_OUTPUT_ROOT = lex.$(<F:lex.l=)
AM_YFLAGS = -p$(<F:parse.y=)
noinst_LIBRARIES = libcpu_i386.a libcpu_x86_64.a
+lib_LIBRARIES = libcpu_static_pic.a
libcpu_i386_a_SOURCES = i386_disasm.c i386_dis.h
libcpu_x86_64_a_SOURCES = x86_64_disasm.c x86_64_dis.h
+libcpu_static_pic_a_SOURCES = $(libcpu_i386_a_SOURCES) $(libcpu_x86_64_a_SOURCES)
i386_gendis_SOURCES = i386_gendis.c i386_lex.l i386_parse.y
@@ -48,6 +50,8 @@ x86_64_disasm.o: x86_64.mnemonics $(srcdir)/x86_64_dis.h
noinst_LIBRARIES += libcpu_bpf.a
libcpu_bpf_a_SOURCES = bpf_disasm.c
libcpu_bpf_a_CFLAGS = $(AM_CFLAGS) -Wno-format-nonliteral
+libcpu_static_pic_a_SOURCES += $(libcpu_bpf_a_SOURCES)
+bpf_disasm_CFLAGS = -fPIC -Wno-format-nonliteral
%_defs: $(srcdir)/defs/i386
$(AM_V_GEN)m4 -D$* -DDISASSEMBLER $< > $@T
diff --git a/libdw/Makefile.am b/libdw/Makefile.am diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index 7a3d532..166e37c 100644 index 33b5838d..ef566399 100644
--- a/libdw/Makefile.am --- a/libdw/Makefile.am
+++ b/libdw/Makefile.am +++ b/libdw/Makefile.am
@@ -35,12 +35,13 @@ AM_CPPFLAGS += -I$(srcdir)/../libelf -I$(srcdir)/../libdwelf @@ -41,6 +41,7 @@ noinst_PROGRAMS = $(noinst_LIBRARIES:_pic.a=.so)
VERSION = 1
lib_LIBRARIES = libdw.a
-noinst_LIBRARIES = libdw_pic.a
-noinst_PROGRAMS = $(noinst_LIBRARIES:_pic.a=.so)
+noinst_LIBRARIES = libdw_pic.a libdw_static_pic.a
+noinst_PROGRAMS = libdw.so
include_HEADERS = dwarf.h include_HEADERS = dwarf.h
pkginclude_HEADERS = libdw.h known-dwarf.h pkginclude_HEADERS = libdw.h known-dwarf.h
+libdw_a_CFLAGS = -fPIC -fvisibility=hidden $(AM_CFLAGS) +libdw_a_CFLAGS = -fPIC $(AM_CFLAGS)
libdw_a_SOURCES = dwarf_begin.c dwarf_begin_elf.c dwarf_end.c dwarf_getelf.c \ libdw_a_SOURCES = dwarf_begin.c dwarf_begin_elf.c dwarf_end.c dwarf_getelf.c \
dwarf_getpubnames.c dwarf_getabbrev.c dwarf_tag.c \ dwarf_getpubnames.c dwarf_getabbrev.c dwarf_tag.c \
dwarf_error.c dwarf_nextcu.c dwarf_diename.c dwarf_offdie.c \ dwarf_error.c dwarf_nextcu.c dwarf_diename.c dwarf_offdie.c \
@@ -94,6 +95,25 @@ libdw_a_SOURCES = dwarf_begin.c dwarf_begin_elf.c dwarf_end.c dwarf_getelf.c \
libdw_find_split_unit.c dwarf_cu_info.c \
dwarf_next_lines.c
+# Minimal library with symbols needed by those libebl backends that we
+# ship statically. This is so that e.g. strip doesn't end up bringing
+# in the whole of libdw, and depending on libbz2, liblzma, etc.
+libdw_static_pic_a_SOURCES = libdw_form.c dwarf_child.c dwarf_attr.c \
+ dwarf_attr_integrate.c dwarf_formref_die.c dwarf_error.c \
+ dwarf_tag.c dwarf_formref.c \
+ dwarf_abbrev_hash.c dwarf_sig8_hash.c \
+ dwarf_formudata.c libdw_findcu.c dwarf_offdie.c \
+ dwarf_getabbrev.c dwarf_nextcu.c libdw_alloc.c \
+ dwarf_hasattr_integrate.c dwarf_hasattr.c \
+ dwarf_aggregate_size.c dwarf_siblingof.c dwarf_formsdata.c \
+ dwarf_srclang.c dwarf_formflag.c dwarf_diecu.c \
+ dwarf_bytesize.c dwarf_bitsize.c dwarf_peel_type.c \
+ dwarf_default_lower_bound.c libdw_find_split_unit.c \
+ dwarf_getalt.c dwarf_haschildren.c \
+ dwarf_begin.c dwarf_begin_elf.c dwarf_end.c frame-cache.c \
+ dwarf_get_units.c dwarf_formstring.c \
+ ../libdwelf/dwelf_dwarf_gnu_debugaltlink.c
+
if MAINTAINER_MODE
BUILT_SOURCES = $(srcdir)/known-dwarf.h
MAINTAINERCLEANFILES = $(srcdir)/known-dwarf.h
@@ -104,9 +124,12 @@ endif
libdw_pic_a_SOURCES =
am_libdw_pic_a_OBJECTS = $(libdw_a_SOURCES:.c=.os)
+am_libdw_static_pic_a_OBJECTS = $(libdw_static_pic_a_SOURCES:.c=.os)
libdw_so_LIBS = libdw_pic.a ../libdwelf/libdwelf_pic.a \
- ../libdwfl/libdwfl_pic.a ../libebl/libebl.a
+ ../libdwfl/libdwfl_pic.a ../libebl/libebl.a \
+ ../backends/libebl_static_pic.a \
+ ../libcpu/libcpu_static_pic.a
libdw_so_DEPS = ../lib/libeu.a ../libelf/libelf.so
libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS)
libdw_so_SOURCES =
diff --git a/libdwelf/Makefile.am b/libdwelf/Makefile.am diff --git a/libdwelf/Makefile.am b/libdwelf/Makefile.am
index a7933fd..da418e6 100644 index a35a2873..4932b8dd 100644
--- a/libdwelf/Makefile.am --- a/libdwelf/Makefile.am
+++ b/libdwelf/Makefile.am +++ b/libdwelf/Makefile.am
@@ -39,6 +39,7 @@ noinst_LIBRARIES = libdwelf.a libdwelf_pic.a @@ -39,6 +39,7 @@ noinst_LIBRARIES = libdwelf.a libdwelf_pic.a
pkginclude_HEADERS = libdwelf.h pkginclude_HEADERS = libdwelf.h
noinst_HEADERS = libdwelfP.h noinst_HEADERS = libdwelfP.h
+libdwelf_a_CFLAGS = -fPIC -fvisibility=hidden $(AM_CFLAGS) +libdwelf_a_CFLAGS = -fPIC $(AM_CFLAGS)
libdwelf_a_SOURCES = dwelf_elf_gnu_debuglink.c dwelf_dwarf_gnu_debugaltlink.c \ libdwelf_a_SOURCES = dwelf_elf_gnu_debuglink.c dwelf_dwarf_gnu_debugaltlink.c \
dwelf_elf_gnu_build_id.c dwelf_scn_gnu_compressed_size.c \ dwelf_elf_gnu_build_id.c dwelf_scn_gnu_compressed_size.c \
dwelf_strtab.c dwelf_elf_begin.c dwelf_strtab.c dwelf_elf_begin.c \
diff --git a/libdwfl/Makefile.am b/libdwfl/Makefile.am diff --git a/libdwfl/Makefile.am b/libdwfl/Makefile.am
index 89ca92e..d9d13b2 100644 index a0013e41..51e36dfb 100644
--- a/libdwfl/Makefile.am --- a/libdwfl/Makefile.am
+++ b/libdwfl/Makefile.am +++ b/libdwfl/Makefile.am
@@ -39,6 +39,7 @@ noinst_LIBRARIES += libdwfl_pic.a @@ -39,7 +39,7 @@ noinst_LIBRARIES += libdwfl_pic.a
pkginclude_HEADERS = libdwfl.h pkginclude_HEADERS = libdwfl.h
+libdwfl_a_CFLAGS = -fPIC -fvisibility=hidden $(AM_CFLAGS) -
+libdwfl_a_CFLAGS = -fPIC $(AM_CFLAGS)
libdwfl_a_SOURCES = dwfl_begin.c dwfl_end.c dwfl_error.c dwfl_version.c \ libdwfl_a_SOURCES = dwfl_begin.c dwfl_end.c dwfl_error.c dwfl_version.c \
dwfl_module.c dwfl_report_elf.c relocate.c \ dwfl_module.c dwfl_report_elf.c relocate.c \
dwfl_module_build_id.c dwfl_module_report_build_id.c \ dwfl_module_build_id.c dwfl_module_report_build_id.c \
diff --git a/libebl/Makefile.am b/libebl/Makefile.am diff --git a/libebl/Makefile.am b/libebl/Makefile.am
index 737de6b..ecebdd0 100644 index d84e7ee2..4943353d 100644
--- a/libebl/Makefile.am --- a/libebl/Makefile.am
+++ b/libebl/Makefile.am +++ b/libebl/Makefile.am
@@ -56,6 +56,7 @@ gen_SOURCES = eblopenbackend.c eblclosebackend.c \ @@ -59,6 +59,8 @@ libebl_a_SOURCES = eblopenbackend.c eblclosebackend.c eblreloctypename.c \
eblunwind.c eblresolvesym.c eblcheckreloctargettype.c \ libebl_pic_a_SOURCES =
ebl_data_marker_symbol.c am_libebl_pic_a_OBJECTS = $(libebl_a_SOURCES:.c=.os)
+libebl_a_CFLAGS = -fvisibility=hidden $(AM_CFLAGS) +libebl_a_CFLAGS = -fPIC $(AM_CFLAGS)
libebl_a_SOURCES = $(gen_SOURCES) +
noinst_HEADERS = libebl.h libeblP.h ebl-hooks.h
noinst_HEADERS = libeblP.h ebl-hooks.h MOSTLYCLEANFILES = $(am_libebl_pic_a_OBJECTS)
diff --git a/libebl/eblclosebackend.c b/libebl/eblclosebackend.c
index 67fbdfe..501e5c7 100644
--- a/libebl/eblclosebackend.c
+++ b/libebl/eblclosebackend.c
@@ -44,10 +44,6 @@ ebl_closebackend (Ebl *ebl)
/* Run the destructor. */
ebl->destr (ebl);
- /* Close the dynamically loaded object. */
- if (ebl->dlhandle != NULL)
- (void) dlclose (ebl->dlhandle);
-
/* Free the resources. */
free (ebl);
}
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index d54b720..74251ea 100644 index a8af1658..e16de649 100644
--- a/libebl/eblopenbackend.c --- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c +++ b/libebl/eblopenbackend.c
@@ -41,6 +41,14 @@ @@ -42,20 +42,13 @@
#include <system.h>
#include <libeblP.h> #include <libeblP.h>
+const char *i386_init (Elf *elf, GElf_Half machine, Ebl *eh, size_t ehlen); Ebl *i386_init (Elf *, GElf_Half, Ebl *);
+const char *x86_64_init (Elf *elf, GElf_Half machine, Ebl *eh, size_t ehlen); -Ebl *sh_init (Elf *, GElf_Half, Ebl *);
+const char *ppc_init (Elf *elf, GElf_Half machine, Ebl *eh, size_t ehlen); Ebl *x86_64_init (Elf *, GElf_Half, Ebl *);
+const char *ppc64_init (Elf *elf, GElf_Half machine, Ebl *eh, size_t ehlen); Ebl *ia64_init (Elf *, GElf_Half, Ebl *);
+const char *ia64_init (Elf *elf, GElf_Half machine, Ebl *eh, size_t ehlen); -Ebl *alpha_init (Elf *, GElf_Half, Ebl *);
+const char *s390_init (Elf *elf, GElf_Half machine, Ebl *eh, size_t ehlen); -Ebl *arm_init (Elf *, GElf_Half, Ebl *);
+const char *aarch64_init (Elf *elf, GElf_Half machine, Ebl *eh, size_t ehlen); Ebl *aarch64_init (Elf *, GElf_Half, Ebl *);
+const char *bpf_init (Elf *elf, GElf_Half machine, Ebl *eh, size_t ehlen); -Ebl *sparc_init (Elf *, GElf_Half, Ebl *);
Ebl *ppc_init (Elf *, GElf_Half, Ebl *);
Ebl *ppc64_init (Elf *, GElf_Half, Ebl *);
Ebl *s390_init (Elf *, GElf_Half, Ebl *);
-Ebl *m68k_init (Elf *, GElf_Half, Ebl *);
Ebl *bpf_init (Elf *, GElf_Half, Ebl *);
-Ebl *riscv_init (Elf *, GElf_Half, Ebl *);
-Ebl *csky_init (Elf *, GElf_Half, Ebl *);
/* This table should contain the complete list of architectures as far /* This table should contain the complete list of architectures as far
as the ELF specification is concerned. */ as the ELF specification is concerned. */
@@ -48,7 +56,7 @@ @@ -74,27 +67,27 @@ static const struct
arrays to avoid relocations. */
static const struct
{ {
- const char *dsoname; { i386_init, "elf_i386", "i386", 4, EM_386, ELFCLASS32, ELFDATA2LSB },
+ ebl_bhinit_t initptr; { ia64_init, "elf_ia64", "ia64", 4, EM_IA_64, ELFCLASS64, ELFDATA2LSB },
const char *emulation; - { alpha_init, "elf_alpha", "alpha", 5, EM_ALPHA, ELFCLASS64, ELFDATA2LSB },
const char *prefix;
int prefix_len;
@@ -57,84 +65,84 @@ static const struct
int data;
} machines[] =
{
- { "i386", "elf_i386", "i386", 4, EM_386, ELFCLASS32, ELFDATA2LSB },
- { "ia64", "elf_ia64", "ia64", 4, EM_IA_64, ELFCLASS64, ELFDATA2LSB },
- { "alpha", "elf_alpha", "alpha", 5, EM_ALPHA, ELFCLASS64, ELFDATA2LSB },
- { "x86_64", "elf_x86_64", "x86_64", 6, EM_X86_64, ELFCLASS64, ELFDATA2LSB },
- { "ppc", "elf_ppc", "ppc", 3, EM_PPC, ELFCLASS32, ELFDATA2MSB },
- { "ppc64", "elf_ppc64", "ppc64", 5, EM_PPC64, ELFCLASS64, ELFDATA2MSB },
- { "tilegx", "elf_tilegx", "tilegx", 6, EM_TILEGX, ELFCLASS64, ELFDATA2LSB },
+ { i386_init, "elf_i386", "i386", 4, EM_386, ELFCLASS32, ELFDATA2LSB },
+ { ia64_init, "elf_ia64", "ia64", 4, EM_IA_64, ELFCLASS64, ELFDATA2LSB },
+ { NULL, "elf_alpha", "alpha", 5, EM_ALPHA, ELFCLASS64, ELFDATA2LSB }, + { NULL, "elf_alpha", "alpha", 5, EM_ALPHA, ELFCLASS64, ELFDATA2LSB },
+ { x86_64_init, "elf_x86_64", "x86_64", 6, EM_X86_64, ELFCLASS64, ELFDATA2LSB }, { x86_64_init, "elf_x86_64", "x86_64", 6, EM_X86_64, ELFCLASS64, ELFDATA2LSB },
+ { ppc_init, "elf_ppc", "ppc", 3, EM_PPC, ELFCLASS32, ELFDATA2MSB }, { ppc_init, "elf_ppc", "ppc", 3, EM_PPC, ELFCLASS32, ELFDATA2MSB },
+ { ppc64_init, "elf_ppc64", "ppc64", 5, EM_PPC64, ELFCLASS64, ELFDATA2MSB }, { ppc64_init, "elf_ppc64", "ppc64", 5, EM_PPC64, ELFCLASS64, ELFDATA2MSB },
+ { NULL, "elf_tilegx", "tilegx", 6, EM_TILEGX, ELFCLASS64, ELFDATA2LSB },
// XXX class and machine fields need to be filled in for all archs. // XXX class and machine fields need to be filled in for all archs.
- { "sh", "elf_sh", "sh", 2, EM_SH, 0, 0 }, - { sh_init, "elf_sh", "sh", 2, EM_SH, 0, 0 },
- { "arm", "ebl_arm", "arm", 3, EM_ARM, 0, 0 }, - { arm_init, "ebl_arm", "arm", 3, EM_ARM, 0, 0 },
- { "sparc", "elf_sparcv9", "sparc", 5, EM_SPARCV9, 0, 0 }, - { sparc_init, "elf_sparcv9", "sparc", 5, EM_SPARCV9, 0, 0 },
- { "sparc", "elf_sparc", "sparc", 5, EM_SPARC, 0, 0 }, - { sparc_init, "elf_sparc", "sparc", 5, EM_SPARC, 0, 0 },
- { "sparc", "elf_sparcv8plus", "sparc", 5, EM_SPARC32PLUS, 0, 0 }, - { sparc_init, "elf_sparcv8plus", "sparc", 5, EM_SPARC32PLUS, 0, 0 },
- { "s390", "ebl_s390", "s390", 4, EM_S390, 0, 0 },
-
- { "m32", "elf_m32", "m32", 3, EM_M32, 0, 0 },
- { "m68k", "elf_m68k", "m68k", 4, EM_68K, ELFCLASS32, ELFDATA2MSB },
- { "m88k", "elf_m88k", "m88k", 4, EM_88K, 0, 0 },
- { "i860", "elf_i860", "i860", 4, EM_860, 0, 0 },
- { "s370", "ebl_s370", "s370", 4, EM_S370, 0, 0 },
- { "parisc", "elf_parisc", "parisc", 6, EM_PARISC, 0, 0 },
- { "vpp500", "elf_vpp500", "vpp500", 5, EM_VPP500, 0, 0 },
- { "sparc", "elf_v8plus", "v8plus", 6, EM_SPARC32PLUS, 0, 0 },
- { "i960", "elf_i960", "i960", 4, EM_960, 0, 0 },
- { "v800", "ebl_v800", "v800", 4, EM_V800, 0, 0 },
- { "fr20", "ebl_fr20", "fr20", 4, EM_FR20, 0, 0 },
- { "rh32", "ebl_rh32", "rh32", 4, EM_RH32, 0, 0 },
- { "rce", "ebl_rce", "rce", 3, EM_RCE, 0, 0 },
- { "tricore", "elf_tricore", "tricore", 7, EM_TRICORE, 0, 0 },
- { "arc", "elf_arc", "arc", 3, EM_ARC, 0, 0 },
- { "h8", "elf_h8_300", "h8_300", 6, EM_H8_300, 0, 0 },
- { "h8", "elf_h8_300h", "h8_300h", 6, EM_H8_300H, 0, 0 },
- { "h8", "elf_h8s", "h8s", 6, EM_H8S, 0, 0 },
- { "h8", "elf_h8_500", "h8_500", 6, EM_H8_500, 0, 0 },
- { "coldfire", "elf_coldfire", "coldfire", 8, EM_COLDFIRE, 0, 0 },
- { "m68k", "elf_68hc12", "68hc12", 6, EM_68HC12, 0, 0 },
- { "mma", "elf_mma", "mma", 3, EM_MMA, 0, 0 },
- { "pcp", "elf_pcp", "pcp", 3, EM_PCP, 0, 0 },
- { "ncpu", "elf_ncpu", "ncpu", 4, EM_NCPU, 0, 0 },
- { "ndr1", "elf_ndr1", "ndr1", 4, EM_NDR1, 0, 0 },
- { "starcore", "elf_starcore", "starcore", 8, EM_STARCORE, 0, 0 },
- { "me16", "elf_me16", "em16", 4, EM_ME16, 0, 0 },
- { "st100", "elf_st100", "st100", 5, EM_ST100, 0, 0 },
- { "tinyj", "elf_tinyj", "tinyj", 5, EM_TINYJ, 0, 0 },
- { "pdsp", "elf_pdsp", "pdsp", 4, EM_PDSP, 0, 0 },
- { "fx66", "elf_fx66", "fx66", 4, EM_FX66, 0, 0 },
- { "st9plus", "elf_st9plus", "st9plus", 7, EM_ST9PLUS, 0, 0 },
- { "st7", "elf_st7", "st7", 3, EM_ST7, 0, 0 },
- { "m68k", "elf_68hc16", "68hc16", 6, EM_68HC16, 0, 0 },
- { "m68k", "elf_68hc11", "68hc11", 6, EM_68HC11, 0, 0 },
- { "m68k", "elf_68hc08", "68hc08", 6, EM_68HC08, 0, 0 },
- { "m68k", "elf_68hc05", "68hc05", 6, EM_68HC05, 0, 0 },
- { "svx", "elf_svx", "svx", 3, EM_SVX, 0, 0 },
- { "st19", "elf_st19", "st19", 4, EM_ST19, 0, 0 },
- { "vax", "elf_vax", "vax", 3, EM_VAX, 0, 0 },
- { "cris", "elf_cris", "cris", 4, EM_CRIS, 0, 0 },
- { "javelin", "elf_javelin", "javelin", 7, EM_JAVELIN, 0, 0 },
- { "firepath", "elf_firepath", "firepath", 8, EM_FIREPATH, 0, 0 },
- { "zsp", "elf_zsp", "zsp", 3, EM_ZSP, 0, 0 },
- { "mmix", "elf_mmix", "mmix", 4, EM_MMIX, 0, 0 },
- { "hunay", "elf_huany", "huany", 5, EM_HUANY, 0, 0 },
- { "prism", "elf_prism", "prism", 5, EM_PRISM, 0, 0 },
- { "avr", "elf_avr", "avr", 3, EM_AVR, 0, 0 },
- { "fr30", "elf_fr30", "fr30", 4, EM_FR30, 0, 0 },
- { "dv10", "elf_dv10", "dv10", 4, EM_D10V, 0, 0 },
- { "dv30", "elf_dv30", "dv30", 4, EM_D30V, 0, 0 },
- { "v850", "elf_v850", "v850", 4, EM_V850, 0, 0 },
- { "m32r", "elf_m32r", "m32r", 4, EM_M32R, 0, 0 },
- { "mn10300", "elf_mn10300", "mn10300", 7, EM_MN10300, 0, 0 },
- { "mn10200", "elf_mn10200", "mn10200", 7, EM_MN10200, 0, 0 },
- { "pj", "elf_pj", "pj", 2, EM_PJ, 0, 0 },
- { "openrisc", "elf_openrisc", "openrisc", 8, EM_OPENRISC, 0, 0 },
- { "arc", "elf_arc_a5", "arc_a5", 6, EM_ARC_A5, 0, 0 },
- { "xtensa", "elf_xtensa", "xtensa", 6, EM_XTENSA, 0, 0 },
- { "aarch64", "elf_aarch64", "aarch64", 7, EM_AARCH64, ELFCLASS64, 0 },
- { "bpf", "elf_bpf", "bpf", 3, EM_BPF, 0, 0 },
- { "riscv", "elf_riscv", "riscv", 5, EM_RISCV, ELFCLASS64, ELFDATA2LSB },
- { "riscv", "elf_riscv", "riscv", 5, EM_RISCV, ELFCLASS32, ELFDATA2LSB },
+ { NULL, "elf_sh", "sh", 2, EM_SH, 0, 0 }, + { NULL, "elf_sh", "sh", 2, EM_SH, 0, 0 },
+ { NULL, "ebl_arm", "arm", 3, EM_ARM, 0, 0 }, + { NULL, "ebl_arm", "arm", 3, EM_ARM, 0, 0 },
+ { NULL, "elf_sparcv9", "sparc", 5, EM_SPARCV9, 0, 0 }, + { NULL, "elf_sparcv9", "sparc", 5, EM_SPARCV9, 0, 0 },
+ { NULL, "elf_sparc", "sparc", 5, EM_SPARC, 0, 0 }, + { NULL, "elf_sparc", "sparc", 5, EM_SPARC, 0, 0 },
+ { NULL, "elf_sparcv8plus", "sparc", 5, EM_SPARC32PLUS, 0, 0 }, + { NULL, "elf_sparcv8plus", "sparc", 5, EM_SPARC32PLUS, 0, 0 },
+ { s390_init, "ebl_s390", "s390", 4, EM_S390, 0, 0 }, { s390_init, "ebl_s390", "s390", 4, EM_S390, 0, 0 },
+
+ { NULL, "elf_m32", "m32", 3, EM_M32, 0, 0 }, { NULL, "elf_tilegx", "tilegx", 6, EM_TILEGX, ELFCLASS64, ELFDATA2LSB },
{ NULL, "elf_m32", "m32", 3, EM_M32, 0, 0 },
- { m68k_init, "elf_m68k", "m68k", 4, EM_68K, ELFCLASS32, ELFDATA2MSB },
+ { NULL, "elf_m68k", "m68k", 4, EM_68K, ELFCLASS32, ELFDATA2MSB }, + { NULL, "elf_m68k", "m68k", 4, EM_68K, ELFCLASS32, ELFDATA2MSB },
+ { NULL, "elf_m88k", "m88k", 4, EM_88K, 0, 0 }, { NULL, "elf_m88k", "m88k", 4, EM_88K, 0, 0 },
+ { NULL, "elf_i860", "i860", 4, EM_860, 0, 0 }, { NULL, "elf_i860", "i860", 4, EM_860, 0, 0 },
+ { NULL, "ebl_s370", "s370", 4, EM_S370, 0, 0 }, { NULL, "ebl_s370", "s370", 4, EM_S370, 0, 0 },
+ { NULL, "elf_parisc", "parisc", 6, EM_PARISC, 0, 0 }, { NULL, "elf_parisc", "parisc", 6, EM_PARISC, 0, 0 },
+ { NULL, "elf_vpp500", "vpp500", 5, EM_VPP500, 0, 0 }, { NULL, "elf_vpp500", "vpp500", 5, EM_VPP500, 0, 0 },
- { sparc_init, "elf_v8plus", "v8plus", 6, EM_SPARC32PLUS, 0, 0 },
+ { NULL, "elf_v8plus", "v8plus", 6, EM_SPARC32PLUS, 0, 0 }, + { NULL, "elf_v8plus", "v8plus", 6, EM_SPARC32PLUS, 0, 0 },
+ { NULL, "elf_i960", "i960", 4, EM_960, 0, 0 }, { NULL, "elf_i960", "i960", 4, EM_960, 0, 0 },
+ { NULL, "ebl_v800", "v800", 4, EM_V800, 0, 0 }, { NULL, "ebl_v800", "v800", 4, EM_V800, 0, 0 },
+ { NULL, "ebl_fr20", "fr20", 4, EM_FR20, 0, 0 }, { NULL, "ebl_fr20", "fr20", 4, EM_FR20, 0, 0 },
+ { NULL, "ebl_rh32", "rh32", 4, EM_RH32, 0, 0 }, @@ -107,7 +100,7 @@ static const struct
+ { NULL, "ebl_rce", "rce", 3, EM_RCE, 0, 0 }, { NULL, "elf_h8s", "h8s", 6, EM_H8S, 0, 0 },
+ { NULL, "elf_tricore", "tricore", 7, EM_TRICORE, 0, 0 }, { NULL, "elf_h8_500", "h8_500", 6, EM_H8_500, 0, 0 },
+ { NULL, "elf_arc", "arc", 3, EM_ARC, 0, 0 }, { NULL, "elf_coldfire", "coldfire", 8, EM_COLDFIRE, 0, 0 },
+ { NULL, "elf_h8_300", "h8_300", 6, EM_H8_300, 0, 0 }, - { m68k_init, "elf_68hc12", "68hc12", 6, EM_68HC12, 0, 0 },
+ { NULL, "elf_h8_300h", "h8_300h", 6, EM_H8_300H, 0, 0 },
+ { NULL, "elf_h8s", "h8s", 6, EM_H8S, 0, 0 },
+ { NULL, "elf_h8_500", "h8_500", 6, EM_H8_500, 0, 0 },
+ { NULL, "elf_coldfire", "coldfire", 8, EM_COLDFIRE, 0, 0 },
+ { NULL, "elf_68hc12", "68hc12", 6, EM_68HC12, 0, 0 }, + { NULL, "elf_68hc12", "68hc12", 6, EM_68HC12, 0, 0 },
+ { NULL, "elf_mma", "mma", 3, EM_MMA, 0, 0 }, { NULL, "elf_mma", "mma", 3, EM_MMA, 0, 0 },
+ { NULL, "elf_pcp", "pcp", 3, EM_PCP, 0, 0 }, { NULL, "elf_pcp", "pcp", 3, EM_PCP, 0, 0 },
+ { NULL, "elf_ncpu", "ncpu", 4, EM_NCPU, 0, 0 }, { NULL, "elf_ncpu", "ncpu", 4, EM_NCPU, 0, 0 },
+ { NULL, "elf_ndr1", "ndr1", 4, EM_NDR1, 0, 0 }, @@ -120,10 +113,10 @@ static const struct
+ { NULL, "elf_starcore", "starcore", 8, EM_STARCORE, 0, 0 }, { NULL, "elf_fx66", "fx66", 4, EM_FX66, 0, 0 },
+ { NULL, "elf_me16", "em16", 4, EM_ME16, 0, 0 }, { NULL, "elf_st9plus", "st9plus", 7, EM_ST9PLUS, 0, 0 },
+ { NULL, "elf_st100", "st100", 5, EM_ST100, 0, 0 }, { NULL, "elf_st7", "st7", 3, EM_ST7, 0, 0 },
+ { NULL, "elf_tinyj", "tinyj", 5, EM_TINYJ, 0, 0 }, - { m68k_init, "elf_68hc16", "68hc16", 6, EM_68HC16, 0, 0 },
+ { NULL, "elf_pdsp", "pdsp", 4, EM_PDSP, 0, 0 }, - { m68k_init, "elf_68hc11", "68hc11", 6, EM_68HC11, 0, 0 },
+ { NULL, "elf_fx66", "fx66", 4, EM_FX66, 0, 0 }, - { m68k_init, "elf_68hc08", "68hc08", 6, EM_68HC08, 0, 0 },
+ { NULL, "elf_st9plus", "st9plus", 7, EM_ST9PLUS, 0, 0 }, - { m68k_init, "elf_68hc05", "68hc05", 6, EM_68HC05, 0, 0 },
+ { NULL, "elf_st7", "st7", 3, EM_ST7, 0, 0 },
+ { NULL, "elf_68hc16", "68hc16", 6, EM_68HC16, 0, 0 }, + { NULL, "elf_68hc16", "68hc16", 6, EM_68HC16, 0, 0 },
+ { NULL, "elf_68hc11", "68hc11", 6, EM_68HC11, 0, 0 }, + { NULL, "elf_68hc11", "68hc11", 6, EM_68HC11, 0, 0 },
+ { NULL, "elf_68hc08", "68hc08", 6, EM_68HC08, 0, 0 }, + { NULL, "elf_68hc08", "68hc08", 6, EM_68HC08, 0, 0 },
+ { NULL, "elf_68hc05", "68hc05", 6, EM_68HC05, 0, 0 }, + { NULL, "elf_68hc05", "68hc05", 6, EM_68HC05, 0, 0 },
+ { NULL, "elf_svx", "svx", 3, EM_SVX, 0, 0 }, { NULL, "elf_svx", "svx", 3, EM_SVX, 0, 0 },
+ { NULL, "elf_st19", "st19", 4, EM_ST19, 0, 0 }, { NULL, "elf_st19", "st19", 4, EM_ST19, 0, 0 },
+ { NULL, "elf_vax", "vax", 3, EM_VAX, 0, 0 }, { NULL, "elf_vax", "vax", 3, EM_VAX, 0, 0 },
+ { NULL, "elf_cris", "cris", 4, EM_CRIS, 0, 0 }, @@ -148,9 +141,9 @@ static const struct
+ { NULL, "elf_javelin", "javelin", 7, EM_JAVELIN, 0, 0 }, { NULL, "elf_xtensa", "xtensa", 6, EM_XTENSA, 0, 0 },
+ { NULL, "elf_firepath", "firepath", 8, EM_FIREPATH, 0, 0 }, { aarch64_init, "elf_aarch64", "aarch64", 7, EM_AARCH64, ELFCLASS64, 0 },
+ { NULL, "elf_zsp", "zsp", 3, EM_ZSP, 0, 0 }, { bpf_init, "elf_bpf", "bpf", 3, EM_BPF, 0, 0 },
+ { NULL, "elf_mmix", "mmix", 4, EM_MMIX, 0, 0 }, - { riscv_init, "elf_riscv", "riscv", 5, EM_RISCV, ELFCLASS64, ELFDATA2LSB },
+ { NULL, "elf_huany", "huany", 5, EM_HUANY, 0, 0 }, - { riscv_init, "elf_riscv", "riscv", 5, EM_RISCV, ELFCLASS32, ELFDATA2LSB },
+ { NULL, "elf_prism", "prism", 5, EM_PRISM, 0, 0 }, - { csky_init, "elf_csky", "csky", 4, EM_CSKY, ELFCLASS32, ELFDATA2LSB },
+ { NULL, "elf_avr", "avr", 3, EM_AVR, 0, 0 },
+ { NULL, "elf_fr30", "fr30", 4, EM_FR30, 0, 0 },
+ { NULL, "elf_dv10", "dv10", 4, EM_D10V, 0, 0 },
+ { NULL, "elf_dv30", "dv30", 4, EM_D30V, 0, 0 },
+ { NULL, "elf_v850", "v850", 4, EM_V850, 0, 0 },
+ { NULL, "elf_m32r", "m32r", 4, EM_M32R, 0, 0 },
+ { NULL, "elf_mn10300", "mn10300", 7, EM_MN10300, 0, 0 },
+ { NULL, "elf_mn10200", "mn10200", 7, EM_MN10200, 0, 0 },
+ { NULL, "elf_pj", "pj", 2, EM_PJ, 0, 0 },
+ { NULL, "elf_openrisc", "openrisc", 8, EM_OPENRISC, 0, 0 },
+ { NULL, "elf_arc_a5", "arc_a5", 6, EM_ARC_A5, 0, 0 },
+ { NULL, "elf_xtensa", "xtensa", 6, EM_XTENSA, 0, 0 },
+ { aarch64_init, "elf_aarch64", "aarch64", 7, EM_AARCH64, ELFCLASS64, 0 },
+ { bpf_init, "elf_bpf", "bpf", 3, EM_BPF, 0, 0 },
+ { NULL, "elf_riscv", "riscv", 5, EM_RISCV, ELFCLASS64, ELFDATA2LSB }, + { NULL, "elf_riscv", "riscv", 5, EM_RISCV, ELFCLASS64, ELFDATA2LSB },
+ { NULL, "elf_riscv", "riscv", 5, EM_RISCV, ELFCLASS32, ELFDATA2LSB }, + { NULL, "elf_riscv", "riscv", 5, EM_RISCV, ELFCLASS32, ELFDATA2LSB },
+ { NULL, "elf_csky", "csky", 4, EM_CSKY, ELFCLASS32, ELFDATA2LSB },
}; };
#define nmachines (sizeof (machines) / sizeof (machines[0])) #define nmachines (sizeof (machines) / sizeof (machines[0]))
@@ -318,46 +326,17 @@ openbackend (Elf *elf, const char *emulation, GElf_Half machine)
#endif
#define ORIGINDIR "$ORIGIN/../$LIB/" LIBEBL_SUBDIR "/"
- /* Give it a try. At least the machine type matches. First
- try to load the module. */
- char dsoname[100];
- strcpy (stpcpy (stpcpy (dsoname, ORIGINDIR "libebl_"),
- machines[cnt].dsoname),
- ".so");
-
- void *h = dlopen (dsoname, RTLD_LAZY);
- if (h == NULL)
- {
- strcpy (stpcpy (stpcpy (dsoname, "libebl_"),
- machines[cnt].dsoname),
- ".so");
- h = dlopen (dsoname, RTLD_LAZY);
- }
-
- /* Try without an explicit path. */
- if (h != NULL)
+ ebl_bhinit_t initp = machines[cnt].initptr;
+ if (1)
{
- /* We managed to load the object. Now see whether the
- initialization function likes our file. */
static const char version[] = MODVERSION;
const char *modversion;
- ebl_bhinit_t initp;
-
- // We use a static number to help the compiler see we don't
- // overflow the stack with an arbitrary number.
- assert (machines[cnt].prefix_len <= MAX_PREFIX_LEN);
- char symname[MAX_PREFIX_LEN + sizeof "_init"];
-
- strcpy (mempcpy (symname, machines[cnt].prefix,
- machines[cnt].prefix_len), "_init");
-
- initp = (ebl_bhinit_t) dlsym (h, symname);
if (initp != NULL
&& (modversion = initp (elf, machine, result, sizeof (Ebl)))
&& strcmp (version, modversion) == 0)
{
/* We found a module to handle our file. */
- result->dlhandle = h;
+ result->dlhandle = NULL;
result->elf = elf;
/* A few entries are mandatory. */
@@ -366,9 +345,6 @@ openbackend (Elf *elf, const char *emulation, GElf_Half machine)
return result;
}
-
- /* Not the module we need. */
- (void) dlclose (h);
}
/* We cannot find a DSO but the emulation/machine ID matches.
diff --git a/libelf/Makefile.am b/libelf/Makefile.am diff --git a/libelf/Makefile.am b/libelf/Makefile.am
index d5d63f7..0d8679f 100644 index d5d63f73..51e86dc8 100644
--- a/libelf/Makefile.am --- a/libelf/Makefile.am
+++ b/libelf/Makefile.am +++ b/libelf/Makefile.am
@@ -51,6 +51,7 @@ endif @@ -51,6 +51,7 @@ endif
pkginclude_HEADERS = elf-knowledge.h pkginclude_HEADERS = elf-knowledge.h
+libelf_a_CFLAGS = -fPIC -fvisibility=hidden $(AM_CFLAGS) +libelf_a_CFLAGS = -fPIC $(AM_CFLAGS)
libelf_a_SOURCES = elf_version.c elf_hash.c elf_error.c elf_fill.c \ libelf_a_SOURCES = elf_version.c elf_hash.c elf_error.c elf_fill.c \
elf_begin.c elf_next.c elf_rand.c elf_end.c elf_kind.c \ elf_begin.c elf_next.c elf_rand.c elf_end.c elf_kind.c \
gelf_getclass.c elf_getbase.c elf_getident.c \ gelf_getclass.c elf_getbase.c elf_getident.c \
diff --git a/src/Makefile.am b/src/Makefile.am
index 2b1c0dc..657b21a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -47,7 +47,8 @@ libasm = ../libasm/libasm.so
libdw = ../libdw/libdw.so
libelf = ../libelf/libelf.so
endif
-libebl = ../libebl/libebl.a
+libebl = ../libebl/libebl.a ../backends/libebl_static_pic.a ../libcpu/libcpu_static_pic.a
+libdw_static = ../libdw/libdw_static_pic.a
libeu = ../lib/libeu.a
if DEMANGLE
@@ -67,16 +68,17 @@ ranlib_no_Wstack_usage = yes
ar_no_Wstack_usage = yes
unstrip_no_Wstack_usage = yes
+
readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl
nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl \
$(demanglelib)
size_LDADD = $(libelf) $(libeu) $(argp_LDADD)
strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) -ldl
-elflint_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl
+elflint_LDADD = $(libebl) $(libdw_static) $(libelf) $(libeu) $(argp_LDADD) -ldl
findtextrel_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD)
addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(demanglelib)
-elfcmp_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl
-objdump_LDADD = $(libasm) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl
+elfcmp_LDADD = $(libebl) $(libdw_static) $(libeu) $(libelf) $(argp_LDADD) -ldl
+objdump_LDADD = $(libasm) $(libebl) $(libdw_static) $(libelf) $(libeu) $(argp_LDADD) -ldl
ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
strings_LDADD = $(libelf) $(libeu) $(argp_LDADD)
ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
diff --git a/tests/Makefile.am b/tests/Makefile.am diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1b0c7d3..c74a6c1 100644 index 84f6e88e..0a776692 100644
--- a/tests/Makefile.am --- a/tests/Makefile.am
+++ b/tests/Makefile.am +++ b/tests/Makefile.am
@@ -86,9 +86,8 @@ TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \ @@ -104,9 +104,8 @@ TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \
newscn run-strip-test.sh run-strip-test2.sh \ newscn run-strip-test.sh run-strip-test2.sh \
run-strip-test3.sh run-strip-test4.sh run-strip-test5.sh \ run-strip-test3.sh run-strip-test4.sh run-strip-test5.sh \
run-strip-test6.sh run-strip-test7.sh run-strip-test8.sh \ run-strip-test6.sh run-strip-test7.sh run-strip-test8.sh \
@ -519,17 +241,15 @@ index 1b0c7d3..c74a6c1 100644
run-strip-groups.sh run-strip-reloc.sh run-strip-strmerge.sh \ run-strip-groups.sh run-strip-reloc.sh run-strip-strmerge.sh \
run-strip-nobitsalign.sh run-strip-remove-keep.sh \ run-strip-nobitsalign.sh run-strip-remove-keep.sh \
run-unstrip-test.sh run-unstrip-test2.sh run-unstrip-test3.sh \ run-unstrip-test.sh run-unstrip-test2.sh run-unstrip-test3.sh \
@@ -480,7 +479,8 @@ libdw = ../libdw/libdw.so @@ -183,7 +182,6 @@ TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \
libelf = ../libelf/libelf.so run-readelf-discr.sh \
libasm = ../libasm/libasm.so run-dwelf_elf_e_machine_string.sh \
endif run-elfclassify.sh run-elfclassify-self.sh \
-libebl = ../libebl/libebl.a - run-disasm-riscv64.sh \
+libebl = ../libebl/libebl.a ../backends/libebl_static_pic.a ../libcpu/libcpu_static_pic.a run-pt_gnu_prop-tests.sh \
+libdw_static = ../libdw/libdw_static_pic.a run-getphdrnum.sh run-test-includes.sh \
libeu = ../lib/libeu.a leb128 read_unaligned
endif !STANDALONE @@ -606,6 +604,7 @@ get_files_LDADD = $(libdw) $(libelf)
@@ -510,6 +510,7 @@ get_files_LDADD = $(libdw) $(libelf)
next_files_LDADD = $(libdw) $(libelf) next_files_LDADD = $(libdw) $(libelf)
get_aranges_LDADD = $(libdw) $(libelf) get_aranges_LDADD = $(libdw) $(libelf)
allfcts_LDADD = $(libdw) $(libelf) allfcts_LDADD = $(libdw) $(libelf)
@ -538,7 +258,7 @@ index 1b0c7d3..c74a6c1 100644
addrscopes_LDADD = $(libdw) $(argp_LDADD) addrscopes_LDADD = $(libdw) $(argp_LDADD)
funcscopes_LDADD = $(libdw) $(argp_LDADD) funcscopes_LDADD = $(libdw) $(argp_LDADD)
diff --git a/tests/run-addrcfi.sh b/tests/run-addrcfi.sh diff --git a/tests/run-addrcfi.sh b/tests/run-addrcfi.sh
index fd89d02..76db7d2 100755 index 64fa24d7..e9f55644 100755
--- a/tests/run-addrcfi.sh --- a/tests/run-addrcfi.sh
+++ b/tests/run-addrcfi.sh +++ b/tests/run-addrcfi.sh
@@ -3521,82 +3521,6 @@ testrun_compare ${abs_builddir}/addrcfi -e testfiles390x 0x0000000080000510 <<\E @@ -3521,82 +3521,6 @@ testrun_compare ${abs_builddir}/addrcfi -e testfiles390x 0x0000000080000510 <<\E
@ -624,11 +344,57 @@ index fd89d02..76db7d2 100755
# EM_AARCH64 (function bar 0x400550) # EM_AARCH64 (function bar 0x400550)
# Same as arm, 390 and ppc above. # Same as arm, 390 and ppc above.
# Note missing coverage in .eh_frame. # Note missing coverage in .eh_frame.
@@ -3748,45 +3672,3 @@ testrun_compare ${abs_builddir}/addrcfi -e testfile-x32 0x00400390 <<\EOF
handle_cfi no CFI (.debug_frame): no error
EOF
-# EM_CSKY (function bar 0x8440)
-testfiles testfilecsky
-testrun_compare ${abs_builddir}/addrcfi -e testfilecsky 0x8440 <<\EOF
-dwarf_cfi_addrframe (.eh_frame): no matching address range
-.debug_frame has 0x8440 => [0x8440, 0x844a):
- return address in reg15
- CFA location expression: bregx(14)
- integer reg0 (r0): undefined
- integer reg1 (r1): undefined
- integer reg2 (r2): undefined
- integer reg3 (r3): undefined
- integer reg4 (r4): same_value
- integer reg5 (r5): same_value
- integer reg6 (r6): same_value
- integer reg7 (r7): same_value
- integer reg8 (r8): same_value
- integer reg9 (r9): same_value
- integer reg10 (r10): same_value
- integer reg11 (r11): same_value
- integer reg12 (r12): undefined
- integer reg13 (r13): undefined
- integer reg14 (sp): location expression: call_frame_cfa stack_value
- integer reg15 (lr): same_value
- integer reg16 (r16): same_value
- integer reg17 (r17): same_value
- integer reg18 (r18): undefined
- integer reg19 (r19): undefined
- integer reg20 (r20): undefined
- integer reg21 (r21): undefined
- integer reg22 (r22): undefined
- integer reg23 (r23): undefined
- integer reg24 (r24): undefined
- integer reg25 (r25): undefined
- integer reg26 (r26): undefined
- integer reg27 (r27): undefined
- integer reg28 (r28): undefined
- integer reg29 (r29): undefined
- integer reg30 (r30): undefined
- integer reg31 (tls): undefined
- integer reg36 (hi): undefined
- integer reg37 (lo): undefined
-EOF
diff --git a/tests/run-allregs.sh b/tests/run-allregs.sh diff --git a/tests/run-allregs.sh b/tests/run-allregs.sh
index 1422bd6..0d2eb52 100755 index 87b16c95..0d2eb524 100755
--- a/tests/run-allregs.sh --- a/tests/run-allregs.sh
+++ b/tests/run-allregs.sh +++ b/tests/run-allregs.sh
@@ -2344,387 +2344,6 @@ control registers: @@ -2344,318 +2344,6 @@ control registers:
65: %pswa (pswa), address 64 bits 65: %pswa (pswa), address 64 bits
EOF EOF
@ -873,75 +639,6 @@ index 1422bd6..0d2eb52 100755
- 63: $fpcr (fpcr), unsigned 64 bits - 63: $fpcr (fpcr), unsigned 64 bits
-EOF -EOF
- -
-regs_test testfile60 <<\EOF
-integer registers:
- 0: r0 (r0), signed 64 bits
- 1: r1 (r1), signed 64 bits
- 2: r2 (r2), signed 64 bits
- 3: r3 (r3), signed 64 bits
- 4: r4 (r4), signed 64 bits
- 5: r5 (r5), signed 64 bits
- 6: r6 (r6), signed 64 bits
- 7: r7 (r7), signed 64 bits
- 8: r8 (r8), signed 64 bits
- 9: r9 (r9), signed 64 bits
- 10: r10 (r10), signed 64 bits
- 11: r11 (r11), signed 64 bits
- 12: r12 (r12), signed 64 bits
- 13: r13 (r13), signed 64 bits
- 14: r14 (r14), signed 64 bits
- 15: r15 (r15), signed 64 bits
- 16: r16 (r16), signed 64 bits
- 17: r17 (r17), signed 64 bits
- 18: r18 (r18), signed 64 bits
- 19: r19 (r19), signed 64 bits
- 20: r20 (r20), signed 64 bits
- 21: r21 (r21), signed 64 bits
- 22: r22 (r22), signed 64 bits
- 23: r23 (r23), signed 64 bits
- 24: r24 (r24), signed 64 bits
- 25: r25 (r25), signed 64 bits
- 26: r26 (r26), signed 64 bits
- 27: r27 (r27), signed 64 bits
- 28: r28 (r28), signed 64 bits
- 29: r29 (r29), signed 64 bits
- 30: r30 (r30), signed 64 bits
- 31: r31 (r31), signed 64 bits
- 32: r32 (r32), signed 64 bits
- 33: r33 (r33), signed 64 bits
- 34: r34 (r34), signed 64 bits
- 35: r35 (r35), signed 64 bits
- 36: r36 (r36), signed 64 bits
- 37: r37 (r37), signed 64 bits
- 38: r38 (r38), signed 64 bits
- 39: r39 (r39), signed 64 bits
- 40: r40 (r40), signed 64 bits
- 41: r41 (r41), signed 64 bits
- 42: r42 (r42), signed 64 bits
- 43: r43 (r43), signed 64 bits
- 44: r44 (r44), signed 64 bits
- 45: r45 (r45), signed 64 bits
- 46: r46 (r46), signed 64 bits
- 47: r47 (r47), signed 64 bits
- 48: r48 (r48), signed 64 bits
- 49: r49 (r49), signed 64 bits
- 50: r50 (r50), signed 64 bits
- 51: r51 (r51), signed 64 bits
- 52: r52 (r52), signed 64 bits
- 53: tp (tp), address 64 bits
- 54: sp (sp), address 64 bits
- 55: lr (lr), address 64 bits
- 56: sn (sn), unsigned 64 bits
- 57: idn0 (idn0), unsigned 64 bits
- 58: idn1 (idn1), unsigned 64 bits
- 59: udn0 (udn0), unsigned 64 bits
- 60: udn1 (udn1), unsigned 64 bits
- 61: udn2 (udn2), unsigned 64 bits
- 62: udn3 (udn3), unsigned 64 bits
- 63: zero (zero), unsigned 64 bits
- 64: pc (pc), address 64 bits
-EOF
-
-regs_test testfile61 <<\EOF -regs_test testfile61 <<\EOF
-integer registers: -integer registers:
- 0: r0 (r0), signed 32 bits - 0: r0 (r0), signed 32 bits
@ -1016,7 +713,7 @@ index 1422bd6..0d2eb52 100755
# See run-readelf-mixed-corenote.sh for instructions to regenerate # See run-readelf-mixed-corenote.sh for instructions to regenerate
# this core file. # this core file.
regs_test testfile_aarch64_core <<\EOF regs_test testfile_aarch64_core <<\EOF
@@ -2871,106 +2490,4 @@ x87 registers: @@ -2802,106 +2490,4 @@ x87 registers:
40: %st7 (st7), float 80 bits 40: %st7 (st7), float 80 bits
EOF EOF
@ -1124,7 +821,7 @@ index 1422bd6..0d2eb52 100755
-EOF -EOF
exit 0 exit 0
diff --git a/tests/run-arextract.sh b/tests/run-arextract.sh diff --git a/tests/run-arextract.sh b/tests/run-arextract.sh
index 44f4a52..0532952 100755 index 44f4a525..05329527 100755
--- a/tests/run-arextract.sh --- a/tests/run-arextract.sh
+++ b/tests/run-arextract.sh +++ b/tests/run-arextract.sh
@@ -26,7 +26,7 @@ if test -f $archive; then @@ -26,7 +26,7 @@ if test -f $archive; then
@ -1137,7 +834,7 @@ index 44f4a52..0532952 100755
cmp $f arextract.test || { cmp $f arextract.test || {
echo "Extraction of $1 failed" echo "Extraction of $1 failed"
diff --git a/tests/run-dwarfcfi.sh b/tests/run-dwarfcfi.sh diff --git a/tests/run-dwarfcfi.sh b/tests/run-dwarfcfi.sh
index 98fa171..87691ae 100755 index 98fa171d..87691ae5 100755
--- a/tests/run-dwarfcfi.sh --- a/tests/run-dwarfcfi.sh
+++ b/tests/run-dwarfcfi.sh +++ b/tests/run-dwarfcfi.sh
@@ -98,23 +98,6 @@ testrun_compare ${abs_builddir}/dwarfcfi testfileppc64-debugframe 0x000000001000 @@ -98,23 +98,6 @@ testrun_compare ${abs_builddir}/dwarfcfi testfileppc64-debugframe 0x000000001000
@ -1165,7 +862,7 @@ index 98fa171..87691ae 100755
testrun_compare ${abs_builddir}/dwarfcfi testfileaarch64-debugframe 0x400550 <<\EOF testrun_compare ${abs_builddir}/dwarfcfi testfileaarch64-debugframe 0x400550 <<\EOF
0x400550 => [0x400550, 0x400568): 0x400550 => [0x400550, 0x400568):
diff --git a/tests/run-elflint-test.sh b/tests/run-elflint-test.sh diff --git a/tests/run-elflint-test.sh b/tests/run-elflint-test.sh
index caf172a..bd88611 100755 index caf172a6..bd886119 100755
--- a/tests/run-elflint-test.sh --- a/tests/run-elflint-test.sh
+++ b/tests/run-elflint-test.sh +++ b/tests/run-elflint-test.sh
@@ -31,12 +31,14 @@ testfiles testfile33 @@ -31,12 +31,14 @@ testfiles testfile33
@ -1186,7 +883,7 @@ index caf172a..bd88611 100755
testfiles testfile46 testfiles testfile46
testrun ${abs_top_builddir}/src/elflint -q testfile46 testrun ${abs_top_builddir}/src/elflint -q testfile46
diff --git a/tests/run-readelf-A.sh b/tests/run-readelf-A.sh diff --git a/tests/run-readelf-A.sh b/tests/run-readelf-A.sh
index b7432be..46e7a42 100755 index b7432bec..46e7a428 100755
--- a/tests/run-readelf-A.sh --- a/tests/run-readelf-A.sh
+++ b/tests/run-readelf-A.sh +++ b/tests/run-readelf-A.sh
@@ -18,51 +18,19 @@ @@ -18,51 +18,19 @@
@ -1260,7 +957,7 @@ index b7432be..46e7a42 100755
Object attributes section [ 4] '.gnu.attributes' of 16 bytes at offset 0x40: Object attributes section [ 4] '.gnu.attributes' of 16 bytes at offset 0x40:
diff --git a/tests/run-readelf-mixed-corenote.sh b/tests/run-readelf-mixed-corenote.sh diff --git a/tests/run-readelf-mixed-corenote.sh b/tests/run-readelf-mixed-corenote.sh
index c960f1d..382ea14 100755 index c960f1d6..382ea143 100755
--- a/tests/run-readelf-mixed-corenote.sh --- a/tests/run-readelf-mixed-corenote.sh
+++ b/tests/run-readelf-mixed-corenote.sh +++ b/tests/run-readelf-mixed-corenote.sh
@@ -18,73 +18,6 @@ @@ -18,73 +18,6 @@
@ -1477,7 +1174,7 @@ index c960f1d..382ea14 100755
- -
exit 0 exit 0
diff --git a/tests/run-strip-g.sh b/tests/run-strip-g.sh diff --git a/tests/run-strip-g.sh b/tests/run-strip-g.sh
index 1303819..8024aa5 100755 index 13038195..8024aa52 100755
--- a/tests/run-strip-g.sh --- a/tests/run-strip-g.sh
+++ b/tests/run-strip-g.sh +++ b/tests/run-strip-g.sh
@@ -49,31 +49,6 @@ if test $status -ne 1; then @@ -49,31 +49,6 @@ if test $status -ne 1; then
@ -1513,24 +1210,25 @@ index 1303819..8024aa5 100755
testfiles testfileaarch64 testfiles testfileaarch64
diff --git a/tests/run-strip-reloc.sh b/tests/run-strip-reloc.sh diff --git a/tests/run-strip-reloc.sh b/tests/run-strip-reloc.sh
index 0c6b1c2..3523f07 100755 index b7ec1420..3523f075 100755
--- a/tests/run-strip-reloc.sh --- a/tests/run-strip-reloc.sh
+++ b/tests/run-strip-reloc.sh +++ b/tests/run-strip-reloc.sh
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
. $srcdir/test-subr.sh . $srcdir/test-subr.sh
testfiles hello_i386.ko hello_x86_64.ko hello_ppc64.ko hello_s390.ko \ testfiles hello_i386.ko hello_x86_64.ko hello_ppc64.ko hello_s390.ko \
- hello_aarch64.ko hello_m68k.ko hello_riscv64.ko - hello_aarch64.ko hello_m68k.ko hello_riscv64.ko hello_csky.ko
+ hello_aarch64.ko + hello_aarch64.ko
tempfiles readelf.out readelf.out1 readelf.out2 tempfiles readelf.out readelf.out1 readelf.out2
tempfiles out.stripped1 out.debug1 out.stripped2 out.debug2 tempfiles out.stripped1 out.debug1 out.stripped2 out.debug2
@@ -117,8 +117,6 @@ runtest hello_x86_64.ko 1 @@ -117,9 +117,6 @@ runtest hello_x86_64.ko 1
runtest hello_ppc64.ko 1 runtest hello_ppc64.ko 1
runtest hello_s390.ko 1 runtest hello_s390.ko 1
runtest hello_aarch64.ko 1 runtest hello_aarch64.ko 1
-runtest hello_m68k.ko 1 -runtest hello_m68k.ko 1
-runtest hello_riscv64.ko 1 -runtest hello_riscv64.ko 1
-runtest hello_csky.ko 1
# self test, shouldn't impact non-ET_REL files at all. # self test, shouldn't impact non-ET_REL files at all.
runtest ${abs_top_builddir}/src/strip 0 runtest ${abs_top_builddir}/src/strip 0

View File

@ -1,5 +1,18 @@
diff --git a/debuginfod/Makefile.am b/debuginfod/Makefile.am
index 52ead30a..9d7ce408 100644
--- a/debuginfod/Makefile.am
+++ b/debuginfod/Makefile.am
@@ -34,7 +34,7 @@ AM_CPPFLAGS += -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
-I$(srcdir)/../libdw -I$(srcdir)/../libdwelf \
$(libmicrohttpd_CFLAGS) $(libcurl_CFLAGS) $(sqlite3_CFLAGS) \
$(libarchive_CFLAGS)
-VERSION = 1
+VERSION = dts.1
# Disable eu- prefixing for artifacts (binaries & man pages) in this
# directory, since they do not conflict with binutils tools.
diff --git a/libasm/Makefile.am b/libasm/Makefile.am diff --git a/libasm/Makefile.am b/libasm/Makefile.am
index fcc7ffc..60b8ed6 100644 index a92b63ad..a92f06de 100644
--- a/libasm/Makefile.am --- a/libasm/Makefile.am
+++ b/libasm/Makefile.am +++ b/libasm/Makefile.am
@@ -31,7 +31,7 @@ include $(top_srcdir)/config/eu.am @@ -31,7 +31,7 @@ include $(top_srcdir)/config/eu.am
@ -12,59 +25,20 @@ index fcc7ffc..60b8ed6 100644
lib_LIBRARIES = libasm.a lib_LIBRARIES = libasm.a
noinst_LIBRARIES = libasm_pic.a noinst_LIBRARIES = libasm_pic.a
diff --git a/libdw/Makefile.am b/libdw/Makefile.am diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index 166e37c..e291478 100644 index ef566399..c6493a08 100644
--- a/libdw/Makefile.am --- a/libdw/Makefile.am
+++ b/libdw/Makefile.am +++ b/libdw/Makefile.am
@@ -32,7 +32,7 @@ if BUILD_STATIC @@ -32,7 +32,7 @@ if BUILD_STATIC
AM_CFLAGS += $(fpic_CFLAGS) AM_CFLAGS += $(fpic_CFLAGS)
endif endif
AM_CPPFLAGS += -I$(srcdir)/../libelf -I$(srcdir)/../libdwelf AM_CPPFLAGS += -I$(srcdir)/../libelf -I$(srcdir)/../libdwelf -pthread
-VERSION = 1 -VERSION = 1
+VERSION = dts.1 +VERSION = dts.1
lib_LIBRARIES = libdw.a lib_LIBRARIES = libdw.a
noinst_LIBRARIES = libdw_pic.a libdw_static_pic.a noinst_LIBRARIES = libdw_pic.a
diff --git a/libdwelf/Makefile.am b/libdwelf/Makefile.am
index b526b7c..fbd51ba 100644
--- a/libdwelf/Makefile.am
+++ b/libdwelf/Makefile.am
@@ -32,7 +32,7 @@
include $(top_srcdir)/config/eu.am
AM_CPPFLAGS += -I$(srcdir)/../libelf -I$(srcdir)/../libdw \
-I$(srcdir)/../libdwfl -I$(srcdir)/../libebl
-VERSION = 1
+VERSION = dts.1
noinst_LIBRARIES = libdwelf.a libdwelf_pic.a
diff --git a/libdwfl/Makefile.am b/libdwfl/Makefile.am
index d9d13b2..3749b51 100644
--- a/libdwfl/Makefile.am
+++ b/libdwfl/Makefile.am
@@ -32,7 +32,7 @@
include $(top_srcdir)/config/eu.am
AM_CPPFLAGS += -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
-I$(srcdir)/../libdw -I$(srcdir)/../libdwelf
-VERSION = 1
+VERSION = dts.1
noinst_LIBRARIES = libdwfl.a
noinst_LIBRARIES += libdwfl_pic.a
diff --git a/libebl/Makefile.am b/libebl/Makefile.am
index ecebdd0..c411c70 100644
--- a/libebl/Makefile.am
+++ b/libebl/Makefile.am
@@ -30,7 +30,7 @@
include $(top_srcdir)/config/eu.am
AM_CFLAGS += $(fpic_CFLAGS)
AM_CPPFLAGS += -I$(srcdir)/../libelf -I$(srcdir)/../libdw -I$(srcdir)/../libasm
-VERSION = 1
+VERSION = dts.1
LIBEBL_SUBDIR = @LIBEBL_SUBDIR@
lib_LIBRARIES = libebl.a
diff --git a/libelf/Makefile.am b/libelf/Makefile.am diff --git a/libelf/Makefile.am b/libelf/Makefile.am
index ba4e3eb..88ce633 100644 index 51e86dc8..988d3ebe 100644
--- a/libelf/Makefile.am --- a/libelf/Makefile.am
+++ b/libelf/Makefile.am +++ b/libelf/Makefile.am
@@ -32,7 +32,7 @@ if BUILD_STATIC @@ -32,7 +32,7 @@ if BUILD_STATIC

7
SOURCES/libdebuginfod.a Normal file
View File

@ -0,0 +1,7 @@
/* GNU ld script
Static libraries in Developer Toolset are named .ar to prevent
brp-strip-static-archive from stripping them. But we still want
them to be found in cases like -static -lxyz, hence this linker
script. */
INPUT(libdebuginfod.ar)

6
SOURCES/libdebuginfod.so Normal file
View File

@ -0,0 +1,6 @@
/* GNU ld script
Libraries in Developer Toolset are linked in statically to allow
compiled binaries to run even when DTS is not installed. */
INPUT(libdebuginfod.ar)
INPUT(-lcurl)

View File

@ -4,4 +4,4 @@
brp-strip-static-archive from stripping them. But we still want brp-strip-static-archive from stripping them. But we still want
them to be found in cases like -static -lxyz, hence this linker them to be found in cases like -static -lxyz, hence this linker
script. */ script. */
GROUP(libdw.ar libebl.ar libebl_static_pic.ar libcpu_static_pic.ar) GROUP(libdw.ar -lpthread -ldl)

View File

@ -2,6 +2,6 @@
Libraries in Developer Toolset are linked in statically to allow Libraries in Developer Toolset are linked in statically to allow
compiled binaries to run even when DTS is not installed. */ compiled binaries to run even when DTS is not installed. */
GROUP(libdw.ar libebl.ar libebl_static_pic.ar libcpu_static_pic.ar) GROUP(libdw.ar -lpthread -ldl)
INPUT(-llzma -lbz2 -lz) INPUT(-lzstd -llzma -lbz2 -lz)
INPUT(-lelf) INPUT(-lelf)

View File

@ -4,23 +4,26 @@
%{?scl:%{?scl_package:%scl_package elfutils}} %{?scl:%{?scl_package:%scl_package elfutils}}
Name: %{?scl_prefix}elfutils Name: %{?scl_prefix}elfutils
Summary: A collection of utilities and DSOs to handle ELF files and DWARF data Version: 0.182
Version: 0.176
%global baserelease 6 %global baserelease 6
Release: %{baserelease}%{?dist}
URL: http://elfutils.org/ URL: http://elfutils.org/
%global source_url ftp://sourceware.org/pub/elfutils/%{version}/ %global source_url ftp://sourceware.org/pub/elfutils/%{version}/
License: GPLv3+ and (GPLv2+ or LGPLv3+) License: GPLv3+ and (GPLv2+ or LGPLv3+) and GFDL
Source: %{?source_url}elfutils-%{version}.tar.bz2
Summary: A collection of utilities and DSOs to handle ELF files and DWARF data
Group: Development/Tools Group: Development/Tools
Release: %{baserelease}%{?dist} # Needed for isa specific Provides and Requires.
%global provide_yama_scope 0
# For DTS we never provide the default yama scope.
%global depsuffix %{?_isa}%{!?_isa:-%{_arch}} %global depsuffix %{?_isa}%{!?_isa:-%{_arch}}
Source: %{?source_url}elfutils-%{version}.tar.bz2 Requires: %{?scl_prefix}elfutils-libelf%{depsuffix} = %{version}-%{release}
Requires: %{?scl_prefix}elfutils-libs%{depsuffix} = %{version}-%{release}
%if 0%{?rhel} >= 8 || 0%{?fedora} >= 20
Recommends: %{?scl_prefix}elfutils-debuginfod-client%{depsuffix} = %{version}-%{release}
%else
Requires: %{?scl_prefix}elfutils-debuginfod-client%{depsuffix} = %{version}-%{release}
%endif
# Libraries in Developer Toolset are linked in statically to allow # Libraries in Developer Toolset are linked in statically to allow
# compiled binaries to run even when DTS is not installed. # compiled binaries to run even when DTS is not installed.
@ -31,32 +34,36 @@ Source4: libasm.so
Source5: libelf.a Source5: libelf.a
Source6: libdw.a Source6: libdw.a
Source7: libasm.a Source7: libasm.a
Source8: libdebuginfod.so
Source9: libdebuginfod.a
# Patches BuildRequires: gcc
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
Patch5: elfutils-0.176-pt-gnu-prop.patch
# DTS specific patches.
Patch100: elfutils-0.176-dts.patch
Patch101: elfutils-dts-libs-version.patch
Requires: %{?scl_prefix}elfutils-libelf%{depsuffix} = %{version}-%{release}
Requires: %{?scl_prefix}elfutils-libs%{depsuffix} = %{version}-%{release}
BuildRequires: gettext
BuildRequires: bison >= 1.875
BuildRequires: flex >= 2.5.4a
BuildRequires: bzip2
BuildRequires: gcc >= 4.4
# For libstdc++ demangle support # For libstdc++ demangle support
BuildRequires: gcc-c++ 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: bzip2-devel
BuildRequires: xz-devel BuildRequires: xz-devel
BuildRequires: libzstd-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
BuildRequires: zstd
# For the run-debuginfod-find.sh test case in %%check for /usr/sbin/ss
BuildRequires: iproute
BuildRequires: bsdtar
BuildRequires: curl
# For DTS because the dts patch changes automake files. # For DTS because the dts patch changes automake files.
BuildRequires: autoconf automake BuildRequires: autoconf automake
@ -66,13 +73,32 @@ BuildRequires: autoconf automake
%global _gnu %{nil} %global _gnu %{nil}
%global _program_prefix eu- %global _program_prefix eu-
# The lib[64]/elfutils directory contains the private ebl backend # For DTS we never provide the default yama scope.
# libraries. They must not be exposed as global provides. We don't %global provide_yama_scope 0
# need to filter the requires since they are only loaded with dlopen.
%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7 # Are we building for a Software Collection?
%global __provides_exclude ^libebl_.*\\.so.*$ %{?scl:%global is_scl 1}
%{!?scl:%global is_scl 0}
# Remove any pkgconfig provides for SCL devel packages.
# These should only be provided by the base packages.
# Also remove the pkgconfig requires for libdw because that
# includes libelf, which should come from the SCL, not the
# base system. The other pkgconfig requires are fine and do
# come from base.
%if %{is_scl}
%define __provides_exclude_from ^%{_libdir}/pkgconfig/.*.pc$
%define __requires_exclude_from ^%{_libdir}/pkgconfig/libdw.pc$
%endif %endif
# Patches
Patch1: elfutils-0.182-debuginfod-test-fix.patch
# DTS specific patches.
Patch100: elfutils-0.182-dts.patch
Patch101: elfutils-dts-libs-version.patch
%description %description
Elfutils is a collection of utilities, including stack (to show Elfutils is a collection of utilities, including stack (to show
backtraces), nm (for listing symbols from object files), size backtraces), nm (for listing symbols from object files), size
@ -81,7 +107,6 @@ strip (for discarding symbols), readelf (to see the raw ELF file
structures), elflint (to check for well-formed ELF files) and structures), elflint (to check for well-formed ELF files) and
elfcompress (to compress or decompress ELF sections). elfcompress (to compress or decompress ELF sections).
%package libs %package libs
Summary: Libraries to handle compiled objects Summary: Libraries to handle compiled objects
Group: Development/Tools Group: Development/Tools
@ -93,12 +118,18 @@ Requires: %{?scl_prefix}elfutils-libelf%{depsuffix} = %{version}-%{release}
%if %{provide_yama_scope} %if %{provide_yama_scope}
Requires: default-yama-scope Requires: default-yama-scope
%endif %endif
%if 0%{?rhel} >= 8 || 0%{?fedora} >= 20
Requires: %{?scl_prefix}elfutils-debuginfod-client%{depsuffix} = %{version}-%{release}
%else
Recommends: %{?scl_prefix}elfutils-debuginfod-client%{depsuffix} = %{version}-%{release}
%endif
%description libs %description libs
The elfutils-libs package contains libraries which implement DWARF, ELF, The elfutils-libs package contains libraries which implement DWARF, ELF,
and machine-specific ELF handling. These libraries are used by the programs and machine-specific ELF handling and process introspection. These
in the elfutils package. The elfutils-devel package enables building libraries are used by the programs in the elfutils package. The
other programs using these libraries. elfutils-devel package enables building other programs using these
libraries.
%package devel %package devel
Summary: Development libraries to handle compiled objects Summary: Development libraries to handle compiled objects
@ -107,16 +138,23 @@ License: GPLv2+ or LGPLv3+
%if 0%{!?_isa:1} %if 0%{!?_isa:1}
Provides: %{?scl_prefix}elfutils-devel%{depsuffix} = %{version}-%{release} Provides: %{?scl_prefix}elfutils-devel%{depsuffix} = %{version}-%{release}
%endif %endif
Requires: %{?scl_prefix}elfutils-libs%{depsuffix} = %{version}-%{release}
Requires: %{?scl_prefix}elfutils-libelf-devel%{depsuffix} = %{version}-%{release} Requires: %{?scl_prefix}elfutils-libelf-devel%{depsuffix} = %{version}-%{release}
Requires: zlib-devel >= 1.2.2.3 %if 0%{?rhel} >= 8 || 0%{?fedora} >= 20
Requires: %{?scl_prefix}elfutils-debuginfod-client-devel%{depsuffix} = %{version}-%{release}
%else
Recommends: %{?scl_prefix}elfutils-debuginfod-client-devel%{depsuffix} = %{version}-%{release}
%endif
# For DTS explicitly require compression -devel packages
Requires: zlib-devel
Requires: bzip2-devel Requires: bzip2-devel
Requires: xz-devel Requires: xz-devel
Requires: libzstd-devel
%description devel %description devel
The elfutils-devel package contains the libraries to create The elfutils-devel package contains the libraries to create
applications for handling compiled objects. libebl provides some applications for handling compiled objects. libdw provides access
higher-level ELF access functionality. libdw provides access to to the DWARF debugging information. libasm provides a programmable
the DWARF debugging information. libasm provides a programmable
assembler interface. assembler interface.
%package libelf %package libelf
@ -140,6 +178,9 @@ License: GPLv2+ or LGPLv3+
%if 0%{!?_isa:1} %if 0%{!?_isa:1}
Provides: %{?scl_prefix}elfutils-libelf-devel%{depsuffix} = %{version}-%{release} Provides: %{?scl_prefix}elfutils-libelf-devel%{depsuffix} = %{version}-%{release}
%endif %endif
Requires: %{?scl_prefix}elfutils-libelf%{depsuffix} = %{version}-%{release}
# For DTS explicitly require zlib-devel
Requires: zlib-devel
%description libelf-devel %description libelf-devel
The elfutils-libelf-devel package contains the libraries to create The elfutils-libelf-devel package contains the libraries to create
@ -168,16 +209,55 @@ interprocess services, communication and introspection
profiling) of processes. profiling) of processes.
%endif %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: %{?scl_prefix}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: %{?scl_prefix}elfutils-debuginfod-client-devel%{depsuffix} = %{version}-%{release}
%endif
Requires: %{?scl_prefix}elfutils-debuginfod-client%{depsuffix} = %{version}-%{release}
# For DTS explicitly require curl-devel to get libcurl.so
Requires: pkgconfig(libcurl) >= 7.29.0
%package debuginfod
Summary: HTTP ELF/DWARF file server addressed by build-id
License: GPLv3+
Requires: %{?scl_prefix}elfutils-libs%{depsuffix} = %{version}-%{release}
Requires: %{?scl_prefix}elfutils-libelf%{depsuffix} = %{version}-%{release}
Requires: %{?scl_prefix}elfutils-debuginfod-client%{depsuffix} = %{version}-%{release}
# To extract .deb files with a bsdtar (= libarchive) subshell
Requires: bsdtar
%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 %prep
%setup -q -n elfutils-%{version} %setup -q -n elfutils-%{version}
# Apply patches # Apply patches
%patch1 -p1 -b .gcc-pr88835
%patch2 -p1 -b .xlate-note
%patch3 -p1 -b .elf-update
%patch4 -p1 -b .strip-illformed
%patch5 -p1 -b .pt-gnu-prop
%patch1 -p1 -b .debuginfod_test_fix
# DTS specific patches # DTS specific patches
%patch100 -p1 -b .dts %patch100 -p1 -b .dts
@ -198,32 +278,21 @@ find . -name \*.sh ! -perm -0100 -print | xargs chmod +x
RPM_OPT_FLAGS="${RPM_OPT_FLAGS/-Wall/}" RPM_OPT_FLAGS="${RPM_OPT_FLAGS/-Wall/}"
RPM_OPT_FLAGS="${RPM_OPT_FLAGS} -Wformat" RPM_OPT_FLAGS="${RPM_OPT_FLAGS} -Wformat"
trap 'cat config.log' EXIT trap 'cat config.log' EXIT
%configure CFLAGS="$RPM_OPT_FLAGS -fexceptions" %configure CFLAGS="$RPM_OPT_FLAGS -fexceptions"
trap '' EXIT trap '' EXIT
%make_build V=1
# Due to static bits, our dependencies are more complex than in plain
# elfutils. We need to build things in parts.
make %{?_smp_mflags} -C lib V=1
make %{?_smp_mflags} -C libdwfl V=1
make %{?_smp_mflags} -C libdwelf V=1
make %{?_smp_mflags} -C libdw libdw_pic.a libdw.a V=1
make %{?_smp_mflags} -C libcpu V=1
make %{?_smp_mflags} -C libebl V=1
make %{?_smp_mflags} -C backends libebl_static_pic.a V=1
make %{?_smp_mflags} -C libelf V=1
make %{?_smp_mflags} -C libdw V=1
make %{?_smp_mflags} V=1
%install %install
rm -rf ${RPM_BUILD_ROOT} rm -rf ${RPM_BUILD_ROOT}
make -s install DESTDIR=${RPM_BUILD_ROOT} %make_install
chmod +x ${RPM_BUILD_ROOT}%{_prefix}/%{_lib}/lib*.so* chmod +x ${RPM_BUILD_ROOT}%{_prefix}/%{_lib}/lib*.so*
chmod +x ${RPM_BUILD_ROOT}%{_prefix}/%{_lib}/elfutils/lib*.so*
ls -ls $RPM_BUILD_ROOT%{_libdir}/lib{elf,dw,asm}.so # We don't have standard DEBUGINFOD_URLS yet.
rm -f $RPM_BUILD_ROOT%{_libdir}/lib{elf,dw,asm}.so rm ${RPM_BUILD_ROOT}%{_sysconfdir}/profile.d/debuginfod.sh
rm ${RPM_BUILD_ROOT}%{_sysconfdir}/profile.d/debuginfod.csh
# Rename static archives to *.ar, so that brp-strip-static-archive # Rename static archives to *.ar, so that brp-strip-static-archive
# doesn't find them. We still want debuginfo for other files, so we # doesn't find them. We still want debuginfo for other files, so we
@ -232,8 +301,11 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/lib{elf,dw,asm}.so
# in the .ar files. # in the .ar files.
find $RPM_BUILD_ROOT%{_libdir}/ -name '*.a' -exec mv -v {} {}r \; find $RPM_BUILD_ROOT%{_libdir}/ -name '*.a' -exec mv -v {} {}r \;
ls -ls $RPM_BUILD_ROOT%{_libdir}/lib{elf,dw,asm,debuginfod}.so
rm -f $RPM_BUILD_ROOT%{_libdir}/lib{elf,dw,asm,debuginfod}.so
install -p -m 644 %{SOURCE2} %{SOURCE3} %{SOURCE4} \ install -p -m 644 %{SOURCE2} %{SOURCE3} %{SOURCE4} \
%{SOURCE5} %{SOURCE6} %{SOURCE7} $RPM_BUILD_ROOT%{_libdir}/ %{SOURCE5} %{SOURCE6} %{SOURCE7} %{SOURCE8} %{SOURCE9} \
$RPM_BUILD_ROOT%{_libdir}/
%find_lang elfutils %find_lang elfutils
@ -243,20 +315,23 @@ install -Dm0644 config/10-default-yama-scope.conf ${RPM_BUILD_ROOT}%{_sysctldir}
%check %check
# Record some build root versions in build.log # 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) %make_build -s check || (cat tests/test-suite.log; false)
# Only the latest Fedora and EPEL have these scriptlets, # Only the latest Fedora and EPEL have these scriptlets,
# older Fedora and plain RHEL don't. # older Fedora and plain RHEL don't.
%if 0%{?ldconfig_scriptlets:1} %if 0%{?ldconfig_scriptlets:1}
%ldconfig_scriptlets libs %ldconfig_scriptlets libs
%ldconfig_scriptlets libelf %ldconfig_scriptlets libelf
%ldconfig_scriptlets debuginfod-client
%else %else
%post libs -p /sbin/ldconfig %post libs -p /sbin/ldconfig
%postun libs -p /sbin/ldconfig %postun libs -p /sbin/ldconfig
%post libelf -p /sbin/ldconfig %post libelf -p /sbin/ldconfig
%postun libelf -p /sbin/ldconfig %postun libelf -p /sbin/ldconfig
%post debuginfod-client -p /sbin/ldconfig
%postun debuginfod-client -p /sbin/ldconfig
%endif %endif
%if %{provide_yama_scope} %if %{provide_yama_scope}
@ -271,13 +346,16 @@ fi
%files %files
%defattr(-,root,root) %defattr(-,root,root)
%{!?_licensedir:%global license %%doc} %{!?_licensedir:%global license %%doc}
%license COPYING COPYING-GPLV2 COPYING-LGPLV3 %license COPYING COPYING-GPLV2 COPYING-LGPLV3 doc/COPYING-GFDL
%doc README TODO CONTRIBUTING %doc README TODO CONTRIBUTING
%{_bindir}/eu-addr2line %{_bindir}/eu-addr2line
%{_bindir}/eu-ar %{_bindir}/eu-ar
%{_bindir}/eu-elfclassify
%{_bindir}/eu-elfcmp %{_bindir}/eu-elfcmp
%{_bindir}/eu-elfcompress
%{_bindir}/eu-elflint %{_bindir}/eu-elflint
%{_bindir}/eu-findtextrel %{_bindir}/eu-findtextrel
%{_bindir}/eu-make-debug-archive
%{_bindir}/eu-nm %{_bindir}/eu-nm
%{_bindir}/eu-objdump %{_bindir}/eu-objdump
%{_bindir}/eu-ranlib %{_bindir}/eu-ranlib
@ -287,19 +365,16 @@ fi
%{_bindir}/eu-strings %{_bindir}/eu-strings
%{_bindir}/eu-strip %{_bindir}/eu-strip
%{_bindir}/eu-unstrip %{_bindir}/eu-unstrip
%{_bindir}/eu-make-debug-archive %{_mandir}/man1/eu-*.1*
%{_bindir}/eu-elfcompress
%files libs %files libs
%defattr(-,root,root) %defattr(-,root,root)
%{!?_licensedir:%global license %%doc} %{!?_licensedir:%global license %%doc}
%license COPYING-GPLV2 COPYING-LGPLV3 %license COPYING-GPLV2 COPYING-LGPLV3
%{_libdir}/libasm-%{version}.so %{_libdir}/libasm-%{version}.so
%{_libdir}/libasm.so.*
%{_libdir}/libdw-%{version}.so %{_libdir}/libdw-%{version}.so
%{_libdir}/libasm.so.*
%{_libdir}/libdw.so.* %{_libdir}/libdw.so.*
%dir %{_libdir}/elfutils
%{_libdir}/elfutils/lib*.so
%files devel %files devel
%defattr(-,root,root) %defattr(-,root,root)
@ -308,21 +383,17 @@ fi
%{_includedir}/elfutils/elf-knowledge.h %{_includedir}/elfutils/elf-knowledge.h
%{_includedir}/elfutils/known-dwarf.h %{_includedir}/elfutils/known-dwarf.h
%{_includedir}/elfutils/libasm.h %{_includedir}/elfutils/libasm.h
%{_includedir}/elfutils/libebl.h
%{_includedir}/elfutils/libdw.h %{_includedir}/elfutils/libdw.h
%{_includedir}/elfutils/libdwfl.h %{_includedir}/elfutils/libdwfl.h
%{_includedir}/elfutils/libdwelf.h %{_includedir}/elfutils/libdwelf.h
%{_includedir}/elfutils/version.h %{_includedir}/elfutils/version.h
%{_libdir}/libebl.ar
%{_libdir}/libasm.so %{_libdir}/libasm.so
%{_libdir}/libasm.a
%{_libdir}/libasm.ar
%{_libdir}/libdw.so %{_libdir}/libdw.so
%{_libdir}/libdw.a
%{_libdir}/libdw.ar
%{_libdir}/libebl_static_pic.ar
%{_libdir}/libcpu_static_pic.ar
%{_libdir}/pkgconfig/libdw.pc %{_libdir}/pkgconfig/libdw.pc
%{_libdir}/libdw.a
%{_libdir}/libasm.a
%{_libdir}/libdw.ar
%{_libdir}/libasm.ar
%files -f elfutils.lang libelf %files -f elfutils.lang libelf
%defattr(-,root,root) %defattr(-,root,root)
@ -337,9 +408,10 @@ fi
%{_includedir}/gelf.h %{_includedir}/gelf.h
%{_includedir}/nlist.h %{_includedir}/nlist.h
%{_libdir}/libelf.so %{_libdir}/libelf.so
%{_libdir}/pkgconfig/libelf.pc
%{_mandir}/man3/elf_*.3*
%{_libdir}/libelf.a %{_libdir}/libelf.a
%{_libdir}/libelf.ar %{_libdir}/libelf.ar
%{_libdir}/pkgconfig/libelf.pc
%if %{provide_yama_scope} %if %{provide_yama_scope}
%files default-yama-scope %files default-yama-scope
@ -347,8 +419,87 @@ fi
%{_sysctldir}/10-default-yama-scope.conf %{_sysctldir}/10-default-yama-scope.conf
%endif %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
%{_libdir}/libdebuginfod.a
%{_libdir}/libdebuginfod.ar
%files debuginfod
%defattr(-,root,root)
%{_bindir}/debuginfod
%{_mandir}/man8/debuginfod.8*
%changelog %changelog
* Wed May 28 2020 Mark Wielaard <mjw@redhat.com> - 0.176-6 * Fri Sep 3 2021 Mark Wielaard <mjw@redhat.com> - 0.182-6
- Also use __requires_exclude_from for libdw.pc
* Thu Jul 29 2021 Mark Wielaard <mjw@redhat.com> - 0.182-5
- Use __provides_exclude_from instead of filter_from_provides
* Thu Jun 29 2021 Mark Wielaard <mjw@redhat.com> - 0.182-4
- Filter out pkgconfig provides
* Wed Nov 11 2020 Mark Wielaard <mjw@redhat.com> - 0.182-3
- Add -lzstd to libdw.so linker script.
* Mon Nov 2 2020 Mark Wielaard <mjw@redhat.com> - 0.182-2
- Add elfutils-0.182-debuginfod-test-fix.patch.
* Mon Nov 2 2020 Mark Wielaard <mjw@redhat.com> - 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 Nov 2 2020 Mark Wielaard <mjw@redhat.com> - 0.180-2
- Add Requires for -devel packages (#1873413)
* Thu Jun 11 2020 Mark Wielaard <mjw@redhat.com> - 0.180-1
- New upstream release.
* Wed Jun 10 2020 Mark Wielaard <mjw@redhat.com> - 0.178-1
- 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.
- 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.
* Tue Jun 9 2020 Mark Wielaard <mjw@redhat.com> - 0.177-1
- New upstream release.
- elfclassify: New tool to analyze ELF objects.
- readelf: Print DW_AT_data_member_location as decimal offset.
Decode DW_AT_discr_list block attributes.
- libdw: Add DW_AT_GNU_numerator, DW_AT_GNU_denominator and DW_AT_GNU_bias.
- libdwelf: Add dwelf_elf_e_machine_string.
dwelf_elf_begin now only returns NULL when there is an error
reading or decompressing a file. If the file is not an ELF file
an ELF handle of type ELF_K_NONE is returned.
* Wed May 27 2020 Mark Wielaard <mjw@redhat.com> - 0.176-6
- Add elfutils-0.176-pt-gnu-prop.patch - Add elfutils-0.176-pt-gnu-prop.patch
* Fri Jul 5 2019 Mark Wielaard <mjw@redhat.com> - 0.176-5 * Fri Jul 5 2019 Mark Wielaard <mjw@redhat.com> - 0.176-5