summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog93
-rw-r--r--tests/Makefile.am30
-rw-r--r--tests/backtrace-child.c2
-rw-r--r--tests/backtrace-data.c16
-rw-r--r--tests/backtrace-dwarf.c2
-rw-r--r--tests/backtrace-subr.sh16
-rw-r--r--tests/backtrace.aarch64.fp.core.bz2bin0 -> 8437 bytes
-rw-r--r--tests/backtrace.aarch64.fp.exec.bz2bin0 -> 394972 bytes
-rw-r--r--tests/backtrace.c12
-rw-r--r--tests/backtrace.i386.fp.core.bz2bin0 -> 8532 bytes
-rwxr-xr-xtests/backtrace.i386.fp.exec.bz2bin0 -> 357436 bytes
-rw-r--r--tests/backtrace.ppc.core.bz2bin46357 -> 44482 bytes
-rw-r--r--tests/backtrace.ppc.exec.bz2bin352898 -> 352197 bytes
-rw-r--r--tests/backtrace.x86_64.fp.core.bz2bin0 -> 11072 bytes
-rw-r--r--tests/backtrace.x86_64.fp.exec.bz2bin0 -> 434645 bytes
-rw-r--r--tests/elfstrmerge.c1
-rw-r--r--tests/fillfile.c448
-rw-r--r--tests/peel_type.c119
-rwxr-xr-xtests/run-backtrace-core-ppc.sh9
-rwxr-xr-xtests/run-backtrace-fp-core-aarch64.sh28
-rwxr-xr-xtests/run-backtrace-fp-core-i386.sh29
-rwxr-xr-xtests/run-backtrace-fp-core-x86_64.sh29
-rwxr-xr-xtests/run-elflint-self.sh3
-rwxr-xr-xtests/run-elflint-test.sh15
-rwxr-xr-xtests/run-peel-type.sh62
-rwxr-xr-xtests/run-readelf-A.sh19
-rwxr-xr-xtests/run-readelf-dwz-multi.sh30
-rwxr-xr-xtests/run-readelf-zdebug-rel.sh6
-rw-r--r--tests/test-subr.sh20
-rw-r--r--tests/testfileppc64attrs.o.bz2bin0 -> 222 bytes
30 files changed, 952 insertions, 37 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 7031cf57..5b0d486e 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,96 @@
+2017-02-13 Ulf Hermann <[email protected]>
+ Mark Wielaard <[email protected]>
+
+ * Makefile.am: Add test for unwinding with frame pointers on aarch64
+ * backtrace.aarch64.fp.core.bz2: New file
+ * backtrace.aarch64.fp.exec.bz2: New file
+ * run-backtrace-fp-core-aarch64.sh: New file
+ * backtrace-subr.sh (check_err): Allow Invalid register.
+ * backtrace.c (callback_verify): Allow duplicate_sigusr2 frames.
+
+2017-04-06 Mark Wielaard <[email protected]>
+
+ * run-backtrace-fp-core-i386.sh: New test.
+ * backtrace.i386.fp.core.bz2: New test file.
+ * backtrace.i386.fp.exec.bz2: New testfile.
+ * Makefile.am (TESTS): Add run-backtrace-fp-core-i386.sh.
+ (EXTRA_DIST): Add run-backtrace-fp-core-i386.sh,
+ backtrace.i386.fp.core.bz2 and backtrace.i386.fp.exec.bz2.
+
+2017-02-09 Ulf Hermann <[email protected]>
+
+ * Makefile.am: Add test for unwinding with frame pointers on x86_64
+ * backtrace.x86_64.fp.core.bz2: New file
+ * backtrace.x86_64.fp.exec.bz2: New file
+ * run-backtrace-fp-core-x86_64.sh: New file
+
+2017-04-25 Mark Wielaard <[email protected]>
+
+ * backtrace-subr.sh (check_backtracegen): New function.
+ (check_core): Add check_backtracegen call.
+ * backtrace.ppc.exec.bz2: Regenerated.
+ * backtrace.ppc.core.bz2: Likewise.
+
+2017-04-24 Mark Wielaard <[email protected]>
+
+ * backtrace.c: Remove option to allow unknown symbols in the trace.
+ * backtrace-substr.sh: Remove option to allow unknown symbols
+ to check_core() and allow failed symbol lookups in check_err().
+
+2017-04-20 Ulf Hermann <[email protected]>
+
+ * run-readelf-dwz-multi.sh: Expect readelf to output "yes" for flags
+ that are set.
+ * run-readelf-zdebug-rel.sh: Likewise.
+
+2017-04-20 Ulf Hermann <[email protected]>
+
+ * backtrace-child.c: Include sys/ptrace.h only on linux.
+ * backtrace-dwarf.c: Likewise.
+
+2017-04-05 Mark Wielaard <[email protected]>
+
+ * test-subr.sh (testrun_on_self_compressed): New function.
+ * run-elflint-self.sh: Call testrun_on_self_compressed.
+ * run-elflint-test.sh: Add testfile42z and testfile-s390x-hash-bothz.
+
+2017-03-30 Mark Wielaard <[email protected]>
+
+ * peel_type.c: New file.
+ * run-peel-type.sh: New test.
+ * Makefile.am (check_PROGRAMS): Add peel_type.c.
+ (TESTS): Add run-peel-type.sh.
+ (EXTRA_DIST): Likewise.
+ (peel_type_LDADD): New variable.
+
+2017-03-27 Mark Wielaard <[email protected]>
+
+ * fillfile.c: New file.
+ * Makefile.am (check_PROGRAMS): Add fillfile.
+ (TESTS): Likewise.
+ (fillfile_LDADD): New variable.
+
+2017-02-15 Mark Wielaard <[email protected]>
+
+ * Makefile.am (EXTRA_DIST): Add testfileppc64attrs.o.bz2.
+ * run-readelf-A.sh: Add testfileppc64.o test.
+
+2017-02-15 Ulf Hermann <[email protected]>
+
+ * elfstrmerge.c: Include system.h.
+
+2017-02-09 Ulf Hermann <[email protected]>
+
+ * backtrace.c: Add an option to allow unknown symbols in the trace
+ * backtrace-substr.sh: Add an option to allow unknown symbols
+ to check_core() and allow failed symbol lookups in check_err()
+
+2017-02-09 Ulf Hermann <[email protected]>
+
+ * backtrace-data.c: Don't assert that symbols are found.
+ The unwinder is allowed to ask for invalid addresses. We deny
+ such requests, rather than make the test fail.
+
2016-11-17 Mark Wielaard <[email protected]>
* run-readelf-s.sh: Add --symbols=.dynsym and --symbols=.symtab tests.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 307d966a..d17ffd47 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,6 +1,6 @@
## Process this file with automake to create Makefile.in
##
-## Copyright (C) 1996-2016 Red Hat, Inc.
+## Copyright (C) 1996-2017 Red Hat, Inc.
## This file is part of elfutils.
##
## This file is free software; you can redistribute it and/or modify
@@ -50,10 +50,12 @@ check_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \
test-elf_cntl_gelf_getshdr dwflsyms dwfllines \
dwfl-report-elf-align varlocs backtrace backtrace-child \
backtrace-data backtrace-dwarf debuglink debugaltlink \
- buildid deleted deleted-lib.so aggregate_size vdsosyms \
+ buildid deleted deleted-lib.so aggregate_size peel_type \
+ vdsosyms \
getsrc_die strptr newdata elfstrtab dwfl-proc-attach \
elfshphehdr elfstrmerge dwelfgnucompressed elfgetchdr \
- elfgetzdata elfputzdata zstrptr emptyfile vendorelf
+ elfgetzdata elfputzdata zstrptr emptyfile vendorelf \
+ fillfile
asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \
asm-tst6 asm-tst7 asm-tst8 asm-tst9
@@ -113,21 +115,25 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
run-backtrace-native.sh run-backtrace-data.sh run-backtrace-dwarf.sh \
run-backtrace-native-biarch.sh run-backtrace-native-core.sh \
run-backtrace-native-core-biarch.sh run-backtrace-core-x86_64.sh \
+ run-backtrace-fp-core-x86_64.sh \
+ run-backtrace-fp-core-aarch64.sh \
run-backtrace-core-x32.sh \
- run-backtrace-core-i386.sh run-backtrace-core-ppc.sh \
+ run-backtrace-core-i386.sh run-backtrace-fp-core-i386.sh \
+ run-backtrace-core-ppc.sh \
run-backtrace-core-s390x.sh run-backtrace-core-s390.sh \
run-backtrace-core-aarch64.sh run-backtrace-core-sparc.sh \
run-backtrace-demangle.sh run-stack-d-test.sh run-stack-i-test.sh \
run-stack-demangled-test.sh run-readelf-zx.sh run-readelf-zp.sh \
run-readelf-dwz-multi.sh run-allfcts-multi.sh run-deleted.sh \
- run-linkmap-cut.sh run-aggregate-size.sh vdsosyms run-readelf-A.sh \
+ run-linkmap-cut.sh run-aggregate-size.sh run-peel-type.sh \
+ vdsosyms run-readelf-A.sh \
run-getsrc-die.sh run-strptr.sh newdata elfstrtab dwfl-proc-attach \
elfshphehdr run-lfs-symbols.sh run-dwelfgnucompressed.sh \
run-elfgetchdr.sh \
run-elfgetzdata.sh run-elfputzdata.sh run-zstrptr.sh \
run-compress-test.sh \
run-readelf-zdebug.sh run-readelf-zdebug-rel.sh \
- emptyfile vendorelf
+ emptyfile vendorelf fillfile
if !BIARCH
export ELFUTILS_DISABLE_BIARCH = 1
@@ -290,9 +296,15 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
run-backtrace-native.sh run-backtrace-native-biarch.sh \
run-backtrace-native-core.sh run-backtrace-native-core-biarch.sh \
run-backtrace-core-x86_64.sh run-backtrace-core-i386.sh \
+ run-backtrace-fp-core-x86_64.sh \
run-backtrace-core-x32.sh \
+ run-backtrace-fp-core-aarch64.sh \
+ backtrace.aarch64.fp.core.bz2 backtrace.aarch64.fp.exec.bz2 \
backtrace-subr.sh backtrace.i386.core.bz2 backtrace.i386.exec.bz2 \
+ run-backtrace-fp-core-i386.sh \
+ backtrace.i386.fp.core.bz2 backtrace.i386.fp.exec.bz2 \
backtrace.x86_64.core.bz2 backtrace.x86_64.exec.bz2 \
+ backtrace.x86_64.fp.core.bz2 backtrace.x86_64.fp.exec.bz2 \
backtrace.ppc.core.bz2 backtrace.ppc.exec.bz2 \
run-backtrace-core-ppc.sh testfile66.bz2 testfile66.core.bz2 \
backtrace.s390x.core.bz2 backtrace.s390x.exec.bz2 \
@@ -315,9 +327,9 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
run-deleted.sh run-linkmap-cut.sh linkmap-cut-lib.so.bz2 \
linkmap-cut.bz2 linkmap-cut.core.bz2 \
run-aggregate-size.sh testfile-sizes1.o.bz2 testfile-sizes2.o.bz2 \
- testfile-sizes3.o.bz2 \
+ testfile-sizes3.o.bz2 run-peel-type.sh \
run-readelf-A.sh testfileppc32attrs.o.bz2 \
- testfilesparc64attrs.o.bz2 \
+ testfilesparc64attrs.o.bz2 testfileppc64attrs.o.bz2 \
testfile-debug-types.bz2 \
run-getsrc-die.sh run-strptr.sh \
testfile-x32-core.bz2 testfile-x32.bz2 \
@@ -475,6 +487,7 @@ deleted_LDADD = ./deleted-lib.so
deleted_lib_so_LDFLAGS = -shared -rdynamic
deleted_lib_so_CFLAGS = -fPIC -fasynchronous-unwind-tables
aggregate_size_LDADD = $(libdw) $(libelf) $(argp_LDADD)
+peel_type_LDADD = $(libdw) $(libelf) $(argp_LDADD)
vdsosyms_LDADD = $(libdw) $(libelf)
getsrc_die_LDADD = $(libdw) $(libelf)
strptr_LDADD = $(libelf)
@@ -491,6 +504,7 @@ elfputzdata_LDADD = $(libelf)
zstrptr_LDADD = $(libelf)
emptyfile_LDADD = $(libelf)
vendorelf_LDADD = $(libelf)
+fillfile_LDADD = $(libelf)
# We want to test the libelf header against the system elf.h header.
# Don't include any -I CPPFLAGS.
diff --git a/tests/backtrace-child.c b/tests/backtrace-child.c
index cf4547ca..2c27414f 100644
--- a/tests/backtrace-child.c
+++ b/tests/backtrace-child.c
@@ -83,7 +83,6 @@
#include <stdlib.h>
#include <signal.h>
#include <errno.h>
-#include <sys/ptrace.h>
#include <string.h>
#include <pthread.h>
#include <stdio.h>
@@ -100,6 +99,7 @@ main (int argc __attribute__ ((unused)), char **argv)
}
#else /* __linux__ */
+#include <sys/ptrace.h>
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
#define NOINLINE_NOCLONE __attribute__ ((noinline, noclone))
diff --git a/tests/backtrace-data.c b/tests/backtrace-data.c
index b7158dae..a387d8ff 100644
--- a/tests/backtrace-data.c
+++ b/tests/backtrace-data.c
@@ -76,10 +76,15 @@ memory_read (Dwfl *dwfl, Dwarf_Addr addr, Dwarf_Word *result,
errno = 0;
long l = ptrace (PTRACE_PEEKDATA, child, (void *) (uintptr_t) addr, NULL);
- assert (errno == 0);
+
+ // The unwinder can ask for an invalid address.
+ // Don't assert on that but just politely refuse.
+ if (errno != 0) {
+ errno = 0;
+ return false;
+ }
*result = l;
- /* We could also return false for failed ptrace. */
return true;
}
@@ -103,7 +108,8 @@ maps_lookup (pid_t pid, Dwarf_Addr addr, GElf_Addr *basep)
unsigned long start, end, offset;
i = fscanf (f, "%lx-%lx %*s %lx %*x:%*x %*x", &start, &end, &offset);
assert (errno == 0);
- assert (i == 3);
+ if (i != 3)
+ break;
char *filename = strdup ("");
assert (filename);
size_t filename_len = 0;
@@ -131,6 +137,8 @@ maps_lookup (pid_t pid, Dwarf_Addr addr, GElf_Addr *basep)
}
free (filename);
}
+ *basep = 0;
+ return NULL;
}
/* Add module containing ADDR to the DWFL address space.
@@ -145,6 +153,8 @@ report_module (Dwfl *dwfl, pid_t child, Dwarf_Addr addr)
{
GElf_Addr base;
char *long_name = maps_lookup (child, addr, &base);
+ if (!long_name)
+ return NULL; // not found
Dwfl_Module *mod = dwfl_report_elf (dwfl, long_name, long_name, -1,
base, false /* add_p_vaddr */);
assert (mod);
diff --git a/tests/backtrace-dwarf.c b/tests/backtrace-dwarf.c
index a644c8ab..2dc8a9a2 100644
--- a/tests/backtrace-dwarf.c
+++ b/tests/backtrace-dwarf.c
@@ -24,7 +24,6 @@
#include <errno.h>
#include <error.h>
#include <unistd.h>
-#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
#include ELFUTILS_HEADER(dwfl)
@@ -40,6 +39,7 @@ main (int argc __attribute__ ((unused)), char **argv)
}
#else /* __linux__ */
+#include <sys/ptrace.h>
#define main cleanup_13_main
#include "cleanup-13.c"
diff --git a/tests/backtrace-subr.sh b/tests/backtrace-subr.sh
index 790b4f44..9731c43a 100644
--- a/tests/backtrace-subr.sh
+++ b/tests/backtrace-subr.sh
@@ -40,13 +40,26 @@ check_gsignal()
false
}
+
+# Makes sure we saw the function that initiated the backtrace
+# when the core was generated through the tests backtrace --gencore.
+# This might disappear when frame pointer chasing gone bad.
+check_backtracegen()
+{
+ if grep -w backtracegen $1; then
+ return
+ fi
+ echo >&2 $2: no backtracegen
+ false
+}
+
# Verify the STDERR output does not contain unexpected errors.
# In some cases we cannot reliably find out we got behind _start as some
# operating system do not properly terminate CFI by undefined PC.
# Ignore it here as it is a bug of OS, not a bug of elfutils.
check_err()
{
- if [ $(egrep -v <$1 'dwfl_thread_getframes: (No DWARF information found|no matching address range)$' \
+ if [ $(egrep -v <$1 'dwfl_thread_getframes: (No DWARF information found|no matching address range|address out of range|Invalid register)$' \
| wc -c) \
-eq 0 ]
then
@@ -105,6 +118,7 @@ check_core()
cat backtrace.$arch.{bt,err}
check_unsupported backtrace.$arch.err backtrace.$arch.core
check_all backtrace.$arch.{bt,err} backtrace.$arch.core
+ check_backtracegen backtrace.$arch.bt backtrace.$arch.core
}
# Backtrace live process.
diff --git a/tests/backtrace.aarch64.fp.core.bz2 b/tests/backtrace.aarch64.fp.core.bz2
new file mode 100644
index 00000000..ff867881
--- /dev/null
+++ b/tests/backtrace.aarch64.fp.core.bz2
Binary files differ
diff --git a/tests/backtrace.aarch64.fp.exec.bz2 b/tests/backtrace.aarch64.fp.exec.bz2
new file mode 100644
index 00000000..9d06db1e
--- /dev/null
+++ b/tests/backtrace.aarch64.fp.exec.bz2
Binary files differ
diff --git a/tests/backtrace.c b/tests/backtrace.c
index 1ff6353c..21abe8af 100644
--- a/tests/backtrace.c
+++ b/tests/backtrace.c
@@ -90,6 +90,10 @@ callback_verify (pid_t tid, unsigned frameno, Dwarf_Addr pc,
return;
}
Dwfl_Module *mod;
+ /* See case 4. Special case to help out simple frame pointer unwinders. */
+ static bool duplicate_sigusr2 = false;
+ if (duplicate_sigusr2)
+ frameno--;
static bool reduce_frameno = false;
if (reduce_frameno)
frameno--;
@@ -125,6 +129,14 @@ callback_verify (pid_t tid, unsigned frameno, Dwarf_Addr pc,
}
/* FALLTHRU */
case 4:
+ /* Some simple frame unwinders get this wrong and think sigusr2
+ is calling itself again. Allow it and just pretend there is
+ an extra sigusr2 frame. */
+ if (symname != NULL && strcmp (symname, "sigusr2") == 0)
+ {
+ duplicate_sigusr2 = true;
+ break;
+ }
assert (symname != NULL && strcmp (symname, "stdarg") == 0);
break;
case 5:
diff --git a/tests/backtrace.i386.fp.core.bz2 b/tests/backtrace.i386.fp.core.bz2
new file mode 100644
index 00000000..3c49e247
--- /dev/null
+++ b/tests/backtrace.i386.fp.core.bz2
Binary files differ
diff --git a/tests/backtrace.i386.fp.exec.bz2 b/tests/backtrace.i386.fp.exec.bz2
new file mode 100755
index 00000000..cb4d32ef
--- /dev/null
+++ b/tests/backtrace.i386.fp.exec.bz2
Binary files differ
diff --git a/tests/backtrace.ppc.core.bz2 b/tests/backtrace.ppc.core.bz2
index f20cd9f3..3a025d28 100644
--- a/tests/backtrace.ppc.core.bz2
+++ b/tests/backtrace.ppc.core.bz2
Binary files differ
diff --git a/tests/backtrace.ppc.exec.bz2 b/tests/backtrace.ppc.exec.bz2
index 057c25a6..333c6be9 100644
--- a/tests/backtrace.ppc.exec.bz2
+++ b/tests/backtrace.ppc.exec.bz2
Binary files differ
diff --git a/tests/backtrace.x86_64.fp.core.bz2 b/tests/backtrace.x86_64.fp.core.bz2
new file mode 100644
index 00000000..e773ca21
--- /dev/null
+++ b/tests/backtrace.x86_64.fp.core.bz2
Binary files differ
diff --git a/tests/backtrace.x86_64.fp.exec.bz2 b/tests/backtrace.x86_64.fp.exec.bz2
new file mode 100644
index 00000000..06958452
--- /dev/null
+++ b/tests/backtrace.x86_64.fp.exec.bz2
Binary files differ
diff --git a/tests/elfstrmerge.c b/tests/elfstrmerge.c
index c2c3fb97..8d5b53cb 100644
--- a/tests/elfstrmerge.c
+++ b/tests/elfstrmerge.c
@@ -29,6 +29,7 @@
#include <inttypes.h>
#include <unistd.h>
+#include <system.h>
#include <gelf.h>
#include ELFUTILS_HEADER(dwelf)
#include "elf-knowledge.h"
diff --git a/tests/fillfile.c b/tests/fillfile.c
new file mode 100644
index 00000000..915e249d
--- /dev/null
+++ b/tests/fillfile.c
@@ -0,0 +1,448 @@
+/* Test program for changing data in one section (but not others) with gaps.
+ Copyright (C) 2017 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>
+
+
+/* Index of last string added. Returned by add_string (). */
+static size_t stridx = 0;
+
+/* Adds a string and returns the offset in the section. */
+static size_t
+add_strtab_entry (Elf_Scn *strtab, const char *str)
+{
+ size_t lastidx = stridx;
+ size_t size = strlen (str) + 1;
+
+ Elf_Data *data = elf_newdata (strtab);
+ if (data == NULL)
+ {
+ printf ("cannot create data SHSTRTAB section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ data->d_buf = (char *) str; /* Discards const, but we will not change. */
+ data->d_type = ELF_T_BYTE;
+ data->d_size = size;
+ data->d_align = 1;
+ data->d_version = EV_CURRENT;
+
+ stridx += size;
+ printf ("add_string: '%s', stridx: %zd, lastidx: %zd\n",
+ str, stridx, lastidx);
+ return lastidx;
+}
+
+static Elf_Scn *
+create_strtab (Elf *elf)
+{
+ // Create strtab section.
+ Elf_Scn *scn = elf_newscn (elf);
+ if (scn == NULL)
+ {
+ printf ("cannot create strings section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Add an empty string to the table as NUL entry for section zero.
+ add_strtab_entry (scn, "");
+
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for new strtab section: %s\n",
+ elf_errmsg (-1));
+ exit (1);
+ }
+
+ shdr->sh_type = SHT_STRTAB;
+ shdr->sh_flags = 0;
+ shdr->sh_addr = 0;
+ shdr->sh_link = SHN_UNDEF;
+ shdr->sh_info = SHN_UNDEF;
+ shdr->sh_addralign = 1;
+ shdr->sh_entsize = 0;
+ shdr->sh_name = add_strtab_entry (scn, ".strtab");
+
+ // We have to store the section strtab index in the ELF header.
+ // So sections have actual names.
+ GElf_Ehdr ehdr_mem;
+ GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
+ if (ehdr == NULL)
+ {
+ printf ("cannot get ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ int ndx = elf_ndxscn (scn);
+ ehdr->e_shstrndx = ndx;
+
+ if (gelf_update_ehdr (elf, ehdr) == 0)
+ {
+ printf ("cannot update ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Finished strtab section, update the header.
+ if (gelf_update_shdr (scn, shdr) == 0)
+ {
+ printf ("cannot update STRTAB section header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ return scn;
+}
+
+static char sec_data[] = { 1, 2, 3, 4, 5 };
+static char new_data[] = { 5, 4, 3, 2, 1 };
+
+static void
+add_data_section (Elf *elf, Elf_Scn *strtab, const char *sname)
+{
+ printf ("Add data section %s\n", sname);
+ Elf_Scn *scn = elf_newscn (elf);
+ if (scn == NULL)
+ {
+ printf ("cannot create strings section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for new %s section: %s\n",
+ sname, elf_errmsg (-1));
+ exit (1);
+ }
+
+ shdr->sh_type = SHT_PROGBITS;
+ shdr->sh_flags = 0;
+ shdr->sh_addr = 0;
+ shdr->sh_link = SHN_UNDEF;
+ shdr->sh_info = SHN_UNDEF;
+ shdr->sh_addralign = 128; // Large alignment to force gap between sections.
+ shdr->sh_entsize = 1;
+ shdr->sh_name = add_strtab_entry (strtab, sname);
+
+ if (gelf_update_shdr (scn, shdr) == 0)
+ {
+ printf ("cannot update %s section header: %s\n", sname, elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* Add some data, but less than alignment. */
+ Elf_Data *data = elf_newdata (scn);
+ if (data == NULL)
+ {
+ printf ("cannot update %s section header: %s\n", sname, elf_errmsg (-1));
+ exit (1);
+ }
+ data->d_buf = sec_data;
+ data->d_size = 5;
+}
+
+static void
+check_data (const char *sname, Elf_Data *data, char *buf)
+{
+ printf ("check data %s [", sname);
+ for (int i = 0; i < 5; i++)
+ printf ("%d%s", buf[i], i < 4 ? "," : "");
+ printf ("]\n");
+ if (data == NULL || data->d_buf == NULL)
+ {
+ printf ("No data in section %s\n", sname);
+ exit (1);
+ }
+
+ if (data->d_size != 5 || memcmp (data->d_buf, buf, 5) != 0)
+ {
+ printf ("Wrong data in section %s [", sname);
+ for (size_t i = 0; i < data->d_size; i++)
+ printf ("%d%s", ((char *)data->d_buf)[i],
+ i < data->d_size - 1 ? "," : "");
+ printf ("]\n");
+ exit(1);
+ }
+}
+
+static void
+check_elf (const char *fname, int class, int use_mmap)
+{
+ printf ("\nfname: %s\n", fname);
+ stridx = 0; // Reset strtab strings index
+
+ int fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ if (fd == -1)
+ {
+ printf ("cannot open `%s': %s\n", fname, strerror (errno));
+ exit (1);
+ }
+
+ Elf *elf = elf_begin (fd, use_mmap ? ELF_C_WRITE_MMAP : ELF_C_WRITE, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Create an ELF header.
+ if (gelf_newehdr (elf, class) == 0)
+ {
+ printf ("cannot create ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ GElf_Ehdr ehdr_mem;
+ GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem);
+ if (ehdr == NULL)
+ {
+ printf ("cannot get ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Initialize header.
+ ehdr->e_ident[EI_DATA] = class == ELFCLASS64 ? ELFDATA2LSB : ELFDATA2MSB;
+ ehdr->e_ident[EI_OSABI] = ELFOSABI_GNU;
+ ehdr->e_type = ET_NONE;
+ ehdr->e_machine = EM_X86_64;
+ ehdr->e_version = EV_CURRENT;
+
+ if (gelf_update_ehdr (elf, ehdr) == 0)
+ {
+ printf ("cannot update ELF header: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ Elf_Scn *strtab = create_strtab (elf);
+ add_data_section (elf, strtab, ".data1");
+ add_data_section (elf, strtab, ".data2");
+ add_data_section (elf, strtab, ".data3");
+ add_data_section (elf, strtab, ".data4");
+
+ // Write everything to disk.
+ if (elf_update (elf, ELF_C_WRITE) < 0)
+ {
+ printf ("failure in elf_update(WRITE): %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ close (fd);
+
+ /* Reread the ELF from disk now. */
+ printf ("Rereading %s\n", fname);
+ fd = open (fname, O_RDWR, 0666);
+ if (fd == -1)
+ {
+ printf ("cannot (re)open `%s': %s\n", fname, strerror (errno));
+ exit (1);
+ }
+
+ elf = elf_begin (fd, use_mmap ? ELF_C_RDWR_MMAP : ELF_C_RDWR, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor read-only: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ /* We are going to change some data (in-place), but want the layout
+ to stay exactly the same. */
+ elf_flagelf (elf, ELF_C_SET, ELF_F_LAYOUT);
+
+ size_t shdrstrndx;
+ if (elf_getshdrstrndx (elf, &shdrstrndx) != 0)
+ {
+ printf ("cannot get shdr str ndx\n");
+ exit (1);
+ }
+ printf ("shdrstrndx: %zd\n", shdrstrndx);
+
+ // Get third data section and change it.
+ Elf_Scn *checkscn = NULL;
+ Elf_Scn *scn = elf_nextscn (elf, NULL);
+ while (scn != NULL)
+ {
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+ const char *sname = elf_strptr (elf, shdrstrndx, shdr->sh_name);
+ if (sname != NULL && strcmp (".data3", sname) == 0)
+ checkscn = scn;
+
+ // Get all data, but don't really use it
+ // (this triggered the original bug).
+ Elf_Data *data = elf_getdata (scn, NULL);
+ if (data != NULL && data->d_buf != NULL && data->d_size == 0)
+ {
+ printf ("Bad data...n");
+ exit (1);
+ }
+ scn = elf_nextscn (elf, scn);
+ }
+
+ if (checkscn == NULL)
+ {
+ printf ("ELF file doesn't have a .data3 section\n");
+ exit (1);
+ }
+
+ Elf_Data *data = elf_getdata (checkscn, NULL);
+ check_data (".data3", data, sec_data);
+ memcpy (data->d_buf, new_data, 5);
+ elf_flagdata (data, ELF_C_SET, ELF_F_DIRTY);
+
+ // Write everything to disk.
+ if (elf_update (elf, ELF_C_WRITE) < 0)
+ {
+ printf ("failure in elf_update(WRITE): %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ close (fd);
+
+ // And read it in one last time.
+ printf ("Rereading %s again\n", fname);
+ fd = open (fname, O_RDONLY, 0666);
+ if (fd == -1)
+ {
+ printf ("cannot open `%s' read-only: %s\n", fname, strerror (errno));
+ exit (1);
+ }
+
+ elf = elf_begin (fd, use_mmap ? ELF_C_READ_MMAP : ELF_C_READ, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor read-only: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ // Get all .data sections and check them.
+ Elf_Scn *scn1 = NULL;
+ Elf_Scn *scn2 = NULL;
+ Elf_Scn *scn3 = NULL;
+ Elf_Scn *scn4 = NULL;
+ scn = elf_nextscn (elf, NULL);
+ while (scn != NULL)
+ {
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for section: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+ const char *sname = elf_strptr (elf, shdrstrndx, shdr->sh_name);
+ if (sname != NULL && strcmp (".data1", sname) == 0)
+ scn1 = scn;
+ else if (sname != NULL && strcmp (".data2", sname) == 0)
+ scn2 = scn;
+ else if (sname != NULL && strcmp (".data3", sname) == 0)
+ scn3 = scn;
+ else if (sname != NULL && strcmp (".data4", sname) == 0)
+ scn4 = scn;
+ scn = elf_nextscn (elf, scn);
+ }
+
+ if (scn1 == NULL)
+ {
+ printf ("ELF file doesn't have a .data1 section\n");
+ exit (1);
+ }
+ data = elf_getdata (scn1, NULL);
+ check_data (".data1", data, sec_data);
+
+ if (scn2 == NULL)
+ {
+ printf ("ELF file doesn't have a .data2 section\n");
+ exit (1);
+ }
+ data = elf_getdata (scn2, NULL);
+ check_data (".data2", data, sec_data);
+
+ if (scn3 == NULL)
+ {
+ printf ("ELF file doesn't have a .data3 section\n");
+ exit (1);
+ }
+ data = elf_getdata (scn3, NULL);
+ check_data (".data3", data, new_data);
+
+ if (scn4 == NULL)
+ {
+ printf ("ELF file doesn't have a .data4 section\n");
+ exit (1);
+ }
+ data = elf_getdata (scn4, NULL);
+ check_data (".data4", data, sec_data);
+
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ exit (1);
+ }
+
+ close (fd);
+
+ unlink (fname);
+}
+
+int
+main (int argc __attribute__ ((unused)),
+ char *argv[] __attribute__ ((unused)))
+{
+ elf_version (EV_CURRENT);
+
+ elf_fill (0xA);
+
+ check_elf ("fill.elf.32", ELFCLASS32, 0);
+ check_elf ("fill.elf.32.mmap", ELFCLASS32, 1);
+ check_elf ("fill.elf.64", ELFCLASS64, 0);
+ check_elf ("fill.elf.64.mmap", ELFCLASS64, 1);
+
+ return 0;
+}
diff --git a/tests/peel_type.c b/tests/peel_type.c
new file mode 100644
index 00000000..bccce32e
--- /dev/null
+++ b/tests/peel_type.c
@@ -0,0 +1,119 @@
+/* Test program for dwarf_peel_type. Peels type of top-level vars.
+ Copyright (C) 2017 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 <assert.h>
+#include <argp.h>
+#include <inttypes.h>
+#include <fcntl.h>
+#include ELFUTILS_HEADER(dw)
+#include ELFUTILS_HEADER(dwfl)
+#include <stdio.h>
+#include <unistd.h>
+#include <dwarf.h>
+
+#include "../libdw/known-dwarf.h"
+
+static const char *
+dwarf_tag_string (unsigned int tag)
+{
+ switch (tag)
+ {
+#define DWARF_ONE_KNOWN_DW_TAG(NAME, CODE) case CODE: return #NAME;
+ DWARF_ALL_KNOWN_DW_TAG
+#undef DWARF_ONE_KNOWN_DW_TAG
+ default:
+ return NULL;
+ }
+}
+
+void
+print_var_raw_type (Dwarf_Die *var)
+{
+ Dwarf_Attribute attr_mem;
+ Dwarf_Die type_mem;
+ Dwarf_Die *type;
+ const char *name = dwarf_diename (var);
+
+ type = dwarf_formref_die (dwarf_attr (var, DW_AT_type, &attr_mem),
+ &type_mem);
+ if (type != NULL)
+ {
+ /* Test twice, once with a separate result DIE. Then with the
+ DIE itself. The resulting tag should be the same. */
+ Dwarf_Die result_mem;
+ Dwarf_Die *result = &result_mem;
+ int res = dwarf_peel_type (type, result);
+ if (res < 0)
+ printf ("%s error peeling type: %s\n", name, dwarf_errmsg (-1));
+ else if (res > 0)
+ printf ("%s missing DW_TAG_TYPE, could peel further: %s\n",
+ name, dwarf_tag_string (dwarf_tag (result)));
+ else
+ {
+ int tag = dwarf_tag (result);
+ printf ("%s raw type %s\n", name, dwarf_tag_string (tag));
+ res = dwarf_peel_type (type, type);
+ if (res < 0)
+ printf ("%s cannot peel type itself: %s\n", name,
+ dwarf_errmsg (-1));
+ else if (res > 0)
+ printf ("%s missing DW_TAG_TYPE, could peel type further: %s\n",
+ name, dwarf_tag_string (dwarf_tag (type)));
+ else if (dwarf_tag (type) != tag)
+ printf ("%s doesn't resolve the same: %s != %s\n", name,
+ dwarf_tag_string (tag),
+ dwarf_tag_string (dwarf_tag (type)));
+ }
+ }
+ else
+ printf ("%s has no type.\n", name);
+}
+
+int
+main (int argc, char *argv[])
+{
+
+ int remaining;
+ Dwfl *dwfl;
+ (void) argp_parse (dwfl_standard_argp (), argc, argv, 0, &remaining,
+ &dwfl);
+ assert (dwfl != NULL);
+
+ Dwarf_Die *cu = NULL;
+ Dwarf_Addr dwbias;
+ while ((cu = dwfl_nextcu (dwfl, cu, &dwbias)) != NULL)
+ {
+ Dwarf_Die die_mem;
+ Dwarf_Die *die = &die_mem;
+ dwarf_child (cu, &die_mem);
+
+ while (1)
+ {
+ if (dwarf_tag (die) == DW_TAG_variable)
+ print_var_raw_type (die);
+
+ if (dwarf_siblingof (die, &die_mem) != 0)
+ break;
+ }
+ }
+
+ dwfl_end (dwfl);
+}
diff --git a/tests/run-backtrace-core-ppc.sh b/tests/run-backtrace-core-ppc.sh
index 65c92795..555ac352 100755
--- a/tests/run-backtrace-core-ppc.sh
+++ b/tests/run-backtrace-core-ppc.sh
@@ -17,4 +17,13 @@
. $srcdir/backtrace-subr.sh
+# executable generated by:
+#
+# gcc -D_GNU_SOURCE -I. -I.. -I../lib -m32 -pthread -static -g \
+# -o backtrace.ppc.exec backtrace-child.c
+#
+# core generated by:
+#
+# ./backtrace.ppc.exec --gencore
+
check_core ppc
diff --git a/tests/run-backtrace-fp-core-aarch64.sh b/tests/run-backtrace-fp-core-aarch64.sh
new file mode 100755
index 00000000..fda88d37
--- /dev/null
+++ b/tests/run-backtrace-fp-core-aarch64.sh
@@ -0,0 +1,28 @@
+#! /bin/bash
+# Copyright (C) 2017 The Qt Company
+# 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/backtrace-subr.sh
+
+# The binary is generated by compiling with eh_frame CFI, but with frame
+# pointers.
+#
+# gcc -static -O2 -fno-omit-frame-pointer -fno-asynchronous-unwind-tables \
+# -D_GNU_SOURCE -pthread -o tests/backtrace.aarch64.fp.exec -I. -Ilib \
+# tests/backtrace-child.c
+# The core is generated by calling the binary with --gencore
+
+check_core aarch64.fp
diff --git a/tests/run-backtrace-fp-core-i386.sh b/tests/run-backtrace-fp-core-i386.sh
new file mode 100755
index 00000000..c58ff532
--- /dev/null
+++ b/tests/run-backtrace-fp-core-i386.sh
@@ -0,0 +1,29 @@
+#! /bin/bash
+# Copyright (C) 2017 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/backtrace-subr.sh
+
+# The binary is generated by compiling backtrace-child without unwind
+# information, but with -fno-omit-frame-pointer.
+#
+# gcc -static -O2 -fno-omit-frame-pointer -fno-asynchronous-unwind-tables \
+# -D_GNU_SOURCE -pthread -o tests/backtrace.i386.fp.exec -I. -Ilib \
+# tests/backtrace-child.c
+#
+# The core is generated by calling tests/backtrace.i386.fp.exec --gencore
+
+check_core i386.fp
diff --git a/tests/run-backtrace-fp-core-x86_64.sh b/tests/run-backtrace-fp-core-x86_64.sh
new file mode 100755
index 00000000..348eb183
--- /dev/null
+++ b/tests/run-backtrace-fp-core-x86_64.sh
@@ -0,0 +1,29 @@
+#! /bin/bash
+# Copyright (C) 2017 The Qt Company
+# 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/backtrace-subr.sh
+
+# The binary is generated by compiling with eh_frame CFI, but with frame
+# pointers.
+#
+# gcc -static -O2 -fno-omit-frame-pointer -fno-asynchronous-unwind-tables \
+# -D_GNU_SOURCE -pthread -o tests/backtrace.x86_64.fp.exec -I. -Ilib \
+# tests/backtrace-child.c
+#
+# The core is generated by calling the binary with --gencore
+
+check_core x86_64.fp
diff --git a/tests/run-elflint-self.sh b/tests/run-elflint-self.sh
index 013109db..58fa7d0f 100755
--- a/tests/run-elflint-self.sh
+++ b/tests/run-elflint-self.sh
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2005, 2007 Red Hat, Inc.
+# Copyright (C) 2005, 2007, 2017 Red Hat, Inc.
# This file is part of elfutils.
# Written by Ulrich Drepper <[email protected]>, 2005.
#
@@ -19,3 +19,4 @@
. $srcdir/test-subr.sh
testrun_on_self ${abs_top_builddir}/src/elflint --quiet --gnu-ld
+testrun_on_self_compressed ${abs_top_builddir}/src/elflint --quiet --gnu-ld
diff --git a/tests/run-elflint-test.sh b/tests/run-elflint-test.sh
index 659d3de4..bd886119 100755
--- a/tests/run-elflint-test.sh
+++ b/tests/run-elflint-test.sh
@@ -30,6 +30,16 @@ testrun ${abs_top_builddir}/src/elflint -q testfile32
testfiles testfile33
testrun ${abs_top_builddir}/src/elflint -q testfile33
+testfiles testfile42
+# sparc unsupported
+#testrun ${abs_top_builddir}/src/elflint -q --gnu-ld testfile42
+
+# Contains debuginfo, compress it, recheck
+tempfiles testfile42z
+testrun ${abs_top_builddir}/src/elfcompress -f -q -o testfile42z testfile42
+# sparc unsupported
+#testrun ${abs_top_builddir}/src/elflint -q --gnu-ld testfile42z
+
testfiles testfile46
testrun ${abs_top_builddir}/src/elflint -q testfile46
@@ -44,4 +54,9 @@ testrun ${abs_top_builddir}/src/elflint -q --gnu-ld testlib_dynseg.so
testfiles testfile-s390x-hash-both
testrun ${abs_top_builddir}/src/elflint -q --gnu-ld testfile-s390x-hash-both
+# Compress the symtab/strtab just because and recheck
+tempfiles testfile-s390x-hash-bothz
+testrun ${abs_top_builddir}/src/elfcompress -f -q --name='.s??tab' -o testfile-s390x-hash-bothz testfile-s390x-hash-both
+testrun ${abs_top_builddir}/src/elflint -q --gnu-ld testfile-s390x-hash-bothz
+
exit 0
diff --git a/tests/run-peel-type.sh b/tests/run-peel-type.sh
new file mode 100755
index 00000000..7fd96e84
--- /dev/null
+++ b/tests/run-peel-type.sh
@@ -0,0 +1,62 @@
+#! /bin/sh
+# Copyright (C) 2017 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
+
+# See run-aggregate-size.sh for how to generate testfiles.
+
+testfiles testfile-sizes1.o testfile-sizes2.o testfile-sizes3.o
+
+testrun_compare ${abs_builddir}/peel_type -e testfile-sizes1.o <<\EOF
+c raw type base_type
+i raw type base_type
+l raw type base_type
+v raw type pointer_type
+s raw type structure_type
+ca raw type array_type
+ia raw type array_type
+va raw type array_type
+sa raw type array_type
+EOF
+
+testrun_compare ${abs_builddir}/peel_type -e testfile-sizes2.o <<\EOF
+c raw type base_type
+i raw type base_type
+l raw type base_type
+v raw type pointer_type
+s raw type structure_type
+ca raw type array_type
+ia raw type array_type
+va raw type array_type
+sa raw type array_type
+EOF
+
+testrun_compare ${abs_builddir}/peel_type -e testfile-sizes3.o <<\EOF
+c raw type base_type
+i raw type base_type
+l raw type base_type
+v raw type pointer_type
+s raw type structure_type
+ca raw type array_type
+ia raw type array_type
+va raw type array_type
+sa raw type array_type
+f raw type base_type
+b raw type base_type
+EOF
+
+exit 0
diff --git a/tests/run-readelf-A.sh b/tests/run-readelf-A.sh
index 933292e4..46e7a428 100755
--- a/tests/run-readelf-A.sh
+++ b/tests/run-readelf-A.sh
@@ -18,15 +18,19 @@
. $srcdir/test-subr.sh
-# See run-addrcfi.sh for testfilearm.
-
# = testfileppc32attrs.s =
# .gnu_attribute 8,1
# .gnu_attribute 12,1
#
# gcc -m32 -c testfileppc32attrs.s
-testfiles testfileppc32attrs.o
+# = testfileppc64attrs.s =
+# .gnu_attribute 4,3
+#
+# gcc -c testfileppc64attrs.s
+
+
+testfiles testfileppc32attrs.o testfileppc64attrs.o
testrun_compare ${abs_top_builddir}/src/readelf -A testfileppc32attrs.o <<\EOF
@@ -38,4 +42,13 @@ Object attributes section [ 4] '.gnu.attributes' of 18 bytes at offset 0x34:
GNU_Power_ABI_Struct_Return: r3/r4
EOF
+testrun_compare ${abs_top_builddir}/src/readelf -A testfileppc64attrs.o <<\EOF
+
+Object attributes section [ 4] '.gnu.attributes' of 16 bytes at offset 0x40:
+ Owner Size
+ gnu 15
+ File: 7
+ GNU_Power_ABI_FP: Single-precision hard float
+EOF
+
exit 0
diff --git a/tests/run-readelf-dwz-multi.sh b/tests/run-readelf-dwz-multi.sh
index 27e0f38c..23ca944c 100755
--- a/tests/run-readelf-dwz-multi.sh
+++ b/tests/run-readelf-dwz-multi.sh
@@ -98,17 +98,17 @@ DWARF section [28] '.debug_info' at offset 0x1078:
byte_size (data1) 8
type (GNU_ref_alt) [ 53]
[ 31] subprogram
- external (flag_present)
+ external (flag_present) yes
name (strp) "main"
decl_file (data1) 1
decl_line (data1) 3
- prototyped (flag_present)
+ prototyped (flag_present) yes
type (GNU_ref_alt) [ 3e]
low_pc (addr) 0x00000000004006ac <main>
high_pc (udata) 44 (0x00000000004006d8)
frame_base (exprloc)
[ 0] call_frame_cfa
- GNU_all_tail_call_sites (flag_present)
+ GNU_all_tail_call_sites (flag_present) yes
sibling (ref_udata) [ 6e]
[ 48] formal_parameter
name (strp) "argc"
@@ -159,17 +159,17 @@ DWARF section [28] '.debug_info' at offset 0x1078:
byte_size (data1) 8
type (GNU_ref_alt) [ 53]
[ 31] subprogram
- external (flag_present)
+ external (flag_present) yes
name (strp) "main"
decl_file (data1) 1
decl_line (data1) 3
- prototyped (flag_present)
+ prototyped (flag_present) yes
type (GNU_ref_alt) [ 3e]
low_pc (addr) 0x00000000004006ac <main>
high_pc (udata) 44 (0x00000000004006d8)
frame_base (exprloc)
[ 0] call_frame_cfa
- GNU_all_tail_call_sites (flag_present)
+ GNU_all_tail_call_sites (flag_present) yes
sibling (ref_udata) [ 6e]
[ 48] formal_parameter
name (strp) "argc"
@@ -216,17 +216,17 @@ DWARF section [25] '.debug_info' at offset 0x106c:
[ 26] imported_unit
import (GNU_ref_alt) [ b]
[ 2b] subprogram
- external (flag_present)
+ external (flag_present) yes
name (strp) "call_foo"
decl_file (data1) 1
decl_line (data1) 3
- prototyped (flag_present)
+ prototyped (flag_present) yes
type (GNU_ref_alt) [ 3e]
low_pc (addr) +0x0000000000000670 <call_foo>
high_pc (udata) 23 (+0x0000000000000687)
frame_base (exprloc)
[ 0] call_frame_cfa
- GNU_all_call_sites (flag_present)
+ GNU_all_call_sites (flag_present) yes
[ 41] formal_parameter
name (string) "fb"
decl_file (data1) 1
@@ -256,17 +256,17 @@ DWARF section [25] '.debug_info' at offset 0x106c:
[ 26] imported_unit
import (GNU_ref_alt) [ b]
[ 2b] subprogram
- external (flag_present)
+ external (flag_present) yes
name (strp) "call_foo"
decl_file (data1) 1
decl_line (data1) 3
- prototyped (flag_present)
+ prototyped (flag_present) yes
type (GNU_ref_alt) [ 3e]
low_pc (addr) +0x0000000000000670 <call_foo>
high_pc (udata) 23 (+0x0000000000000687)
frame_base (exprloc)
[ 0] call_frame_cfa
- GNU_all_call_sites (flag_present)
+ GNU_all_call_sites (flag_present) yes
[ 41] formal_parameter
name (string) "fb"
decl_file (data1) 1
@@ -295,17 +295,17 @@ DWARF section [28] '.debug_info' at offset 0x1088:
[ 26] imported_unit
import (GNU_ref_alt) [ b]
[ 2b] subprogram
- external (flag_present)
+ external (flag_present) yes
name (GNU_strp_alt) "main"
decl_file (data1) 1
decl_line (data1) 8
- prototyped (flag_present)
+ prototyped (flag_present) yes
type (GNU_ref_alt) [ 30]
low_pc (addr) 0x00000000004004ec <main>
high_pc (udata) 18 (0x00000000004004fe)
frame_base (exprloc)
[ 0] call_frame_cfa
- GNU_all_call_sites (flag_present)
+ GNU_all_call_sites (flag_present) yes
[ 41] formal_parameter
name (GNU_strp_alt) "argc"
decl_file (data1) 1
diff --git a/tests/run-readelf-zdebug-rel.sh b/tests/run-readelf-zdebug-rel.sh
index 88ea5bf2..1232d63b 100755
--- a/tests/run-readelf-zdebug-rel.sh
+++ b/tests/run-readelf-zdebug-rel.sh
@@ -60,17 +60,17 @@ DWARF section [ 4] '.debug_info' at offset 0x58:
high_pc (data8) 24 (0x0000000000000018)
stmt_list (sec_offset) 0
[ 2d] subprogram
- external (flag_present)
+ external (flag_present) yes
name (strp) "main"
decl_file (data1) 1
decl_line (data1) 4
- prototyped (flag_present)
+ prototyped (flag_present) yes
type (ref4) [ 80]
low_pc (addr) 000000000000000000
high_pc (data8) 24 (0x0000000000000018)
frame_base (exprloc)
[ 0] call_frame_cfa
- GNU_all_call_sites (flag_present)
+ GNU_all_call_sites (flag_present) yes
sibling (ref4) [ 80]
[ 4e] formal_parameter
name (strp) "argc"
diff --git a/tests/test-subr.sh b/tests/test-subr.sh
index f397aed1..a765db63 100644
--- a/tests/test-subr.sh
+++ b/tests/test-subr.sh
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2005-2015 Red Hat, Inc.
+# Copyright (C) 2005-2015, 2017 Red Hat, Inc.
# This file is part of elfutils.
#
# This file is free software; you can redistribute it and/or modify
@@ -139,6 +139,24 @@ testrun_on_self()
if test $exit_status != 0; then exit $exit_status; fi
}
+# Compress the files first. Compress both debug sections and symtab.
+testrun_on_self_compressed()
+{
+ exit_status=0
+
+ for file in $self_test_files; do
+ tempfiles ${file}z
+ testrun ${abs_top_builddir}/src/elfcompress -f -q -o ${file}z ${file}
+ testrun ${abs_top_builddir}/src/elfcompress -f -q --name='.s??tab' ${file}z
+
+ testrun $* ${file}z \
+ || { echo "*** failure in $* ${file}z"; exit_status=1; }
+ done
+
+ # Only exit if something failed
+ if test $exit_status != 0; then exit $exit_status; fi
+}
+
# Same as above, but redirects stdout to /dev/null
testrun_on_self_quiet()
{
diff --git a/tests/testfileppc64attrs.o.bz2 b/tests/testfileppc64attrs.o.bz2
new file mode 100644
index 00000000..5af2ab6f
--- /dev/null
+++ b/tests/testfileppc64attrs.o.bz2
Binary files differ