summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog66
-rw-r--r--tests/Makefile.am16
-rw-r--r--tests/addsections.c37
-rw-r--r--tests/backtrace-child.c2
-rw-r--r--tests/backtrace-data.c14
-rw-r--r--tests/backtrace-subr.sh1
-rw-r--r--tests/backtrace.c5
-rwxr-xr-xtests/run-annobingroup.sh20
-rwxr-xr-xtests/run-backtrace-data.sh6
-rwxr-xr-xtests/run-readelf-compressed.sh5
-rwxr-xr-xtests/run-readelf-n.sh101
-rwxr-xr-xtests/run-strip-test-many.sh53
-rwxr-xr-xtests/run-strip-version.sh58
-rwxr-xr-xtests/testfile-version.bz2bin0 -> 378 bytes
-rw-r--r--tests/testfile_gnu_props.32be.o.bz2bin0 -> 225 bytes
-rw-r--r--tests/testfile_gnu_props.32le.o.bz2bin0 -> 215 bytes
-rw-r--r--tests/testfile_gnu_props.64be.o.bz2bin0 -> 238 bytes
-rw-r--r--tests/testfile_gnu_props.64le.o.bz2bin0 -> 233 bytes
18 files changed, 324 insertions, 60 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 514229b7..b76c44d9 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,69 @@
+2019-01-24 Mark Wielaard <mark@klomp.org>
+
+ * Makefile.am (system_elf_libelf_test_CPPFLAGS): Guard by
+ !INSTALL_ELFH.
+
+2019-01-31 Mark Wielaard <mark@klomp.org>
+
+ * backtrace-child.c (stdarg): Remove assert (errno == 0).
+ (main): Likewise.
+ * backtrace-data.c (maps_lookup): Likewise.
+ (set_initial_registers): Likewise.
+ (main): Likewise.
+ * backtrace.c (prepare_thread): Likewise.
+ (exec_dump): Likewise.
+
+2019-01-29 Yonghong Song <yhs@fb.com>
+
+ * backtrace-data.c (maps_lookup): Use %*u, not %*x, to parse
+ inode number.
+
+2019-01-18 Ulf Hermann <ulf.hermann@qt.io>
+
+ * run-annobingroup.sh: Use different files for strip output.
+ * run-strip-test-many.sh: Use different files for strip output,
+ check results of strip, unstrip, elflint.
+
+2019-01-24 Mark Wielaard <mark@klomp.org>
+
+ * addsections.c (add_sections): Change the name of the old shstrtab
+ section to ".old_shstrtab" and give the old shstrtab name to the
+ new shstrtab section.
+
+2019-01-09 Ulf Hermann <ulf.hermann@qt.io>
+
+ * run-readelf-compressed.sh: Skip if USE_BZIP2 not found.
+
+2018-12-27 Jim Wilson <jimw@sifive.com>
+
+ * run-readelf-mixed-corenote.sh: Update with new riscv64 output.
+
+2018-12-02 Mark Wielaard <mark@klomp.org>
+
+ * testfile_gnu_props.32le.o.bz2: New testfile.
+ * testfile_gnu_props.64le.o.bz2: Likewise.
+ * testfile_gnu_props.32be.o.bz2: Likewise.
+ * testfile_gnu_props.64be.o.bz2: Likewise.
+ * Makefile (EXTRA_DIST): Add new testfiles.
+ * run-readelf-n.sh: Run tests on new testfiles.
+
+2018-11-28 Mark Wielaard <mark@klomp.org>
+
+ * backtrace-data.c (main): Improve error message.
+ * run-backtrace-data.sh: Skip exit 77 return.
+
+2018-11-21 Mark Wielaard <mark@klomp.org>
+
+ * backtrace-subr.sh (check_unsupported): Call test_cleanup before
+ exit.
+
+2018-11-17 Mark Wielaard <mark@klomp.org>
+
+ * run-strip-version.sh: New test.
+ * testfile-version.bz2: New test file.
+ * Makefile.am (TESTS): Add run-strip-version.sh.
+ (EXTRA_DIST): Add run-strip-version.sh and testfile-version.bz2.
+
2018-11-09 Mark Wielaard <mark@klomp.org>
* run-strip-reloc.sh: Also test testfile-debug-rel-ppc64-z.o
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6258685b..c74a6c1e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -157,7 +157,8 @@ TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \
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-typeiter-many.sh run-strip-test-many.sh \
+ run-strip-version.sh
if !BIARCH
export ELFUTILS_DISABLE_BIARCH = 1
@@ -276,6 +277,10 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \
run-readelf-types.sh \
run-readelf-n.sh \
testfile-gnu-property-note.bz2 testfile-gnu-property-note.o.bz2 \
+ testfile_gnu_props.32le.o.bz2 \
+ testfile_gnu_props.64le.o.bz2 \
+ testfile_gnu_props.32be.o.bz2 \
+ testfile_gnu_props.64be.o.bz2 \
run-allfcts-multi.sh \
test-offset-loop.bz2 test-offset-loop.alt.bz2 \
run-prelink-addr-test.sh \
@@ -416,7 +421,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \
run-typeiter-many.sh run-strip-test-many.sh \
testfile-debug-rel-ppc64-g.o.bz2 \
testfile-debug-rel-ppc64-z.o.bz2 \
- testfile-debug-rel-ppc64.o.bz2
+ testfile-debug-rel-ppc64.o.bz2 \
+ run-strip-version.sh testfile-version.bz2
if USE_VALGRIND
valgrind_cmd='valgrind -q --leak-check=full --error-exitcode=1'
@@ -590,8 +596,12 @@ elfcopy_LDADD = $(libelf)
addsections_LDADD = $(libelf)
# We want to test the libelf header against the system elf.h header.
-# Don't include any -I CPPFLAGS.
+# Don't include any -I CPPFLAGS. Except when we install our own elf.h.
+if !INSTALL_ELFH
system_elf_libelf_test_CPPFLAGS =
+else
+system_elf_libelf_test_CPPFLAGS = -I$(top_srcdir)/libelf
+endif
system_elf_libelf_test_LDADD = $(libelf)
# A lock file used to make sure only one test dumps core at a time
diff --git a/tests/addsections.c b/tests/addsections.c
index 391c5b47..cc8d0655 100644
--- a/tests/addsections.c
+++ b/tests/addsections.c
@@ -92,7 +92,7 @@ add_sections (const char *name, size_t nr, int use_mmap)
/* We will add a new shstrtab section with two new names at the end.
Just get the current shstrtab table and add two entries '.extra'
- and '.new_shstrtab' at the end of the table, so all existing indexes
+ and '.old_shstrtab' at the end of the table, so all existing indexes
are still valid. */
size_t shstrndx;
if (elf_getshdrstrndx (elf, &shstrndx) < 0)
@@ -115,7 +115,7 @@ add_sections (const char *name, size_t nr, int use_mmap)
}
size_t new_shstrtab_size = (shstrtab_data->d_size
+ strlen (".extra") + 1
- + strlen (".new_shstrtab") + 1);
+ + strlen (".old_shstrtab") + 1);
void *new_shstrtab_buf = malloc (new_shstrtab_size);
if (new_shstrtab_buf == NULL)
{
@@ -124,9 +124,30 @@ add_sections (const char *name, size_t nr, int use_mmap)
}
memcpy (new_shstrtab_buf, shstrtab_data->d_buf, shstrtab_data->d_size);
size_t extra_idx = shstrtab_data->d_size;
- size_t new_shstrtab_idx = extra_idx + strlen (".extra") + 1;
+ size_t old_shstrtab_idx = extra_idx + strlen (".extra") + 1;
strcpy (new_shstrtab_buf + extra_idx, ".extra");
- strcpy (new_shstrtab_buf + new_shstrtab_idx, ".new_shstrtab");
+ strcpy (new_shstrtab_buf + old_shstrtab_idx, ".old_shstrtab");
+
+ /* Change the name of the old shstrtab section, because elflint
+ has a strict check on the name/type for .shstrtab. */
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = gelf_getshdr (shstrtab_scn, &shdr_mem);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for old shstrtab section: %s\n",
+ elf_errmsg (-1));
+ exit (1);
+ }
+
+ size_t shstrtab_idx = shdr->sh_name;
+ shdr->sh_name = old_shstrtab_idx;
+
+ if (gelf_update_shdr (shstrtab_scn, shdr) == 0)
+ {
+ printf ("cannot update old shstrtab section header: %s\n",
+ elf_errmsg (-1));
+ exit (1);
+ }
// Add lots of .extra sections...
size_t cnt = 0;
@@ -153,8 +174,7 @@ add_sections (const char *name, size_t nr, int use_mmap)
data->d_type = ELF_T_BYTE;
data->d_align = 1;
- GElf_Shdr shdr_mem;
- GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
+ shdr = gelf_getshdr (scn, &shdr_mem);
if (shdr == NULL)
{
printf ("cannot get header for new section (%zd): %s\n", cnt,
@@ -201,8 +221,7 @@ add_sections (const char *name, size_t nr, int use_mmap)
new_shstrtab_data->d_type = ELF_T_BYTE;
new_shstrtab_data->d_align = 1;
- GElf_Shdr shdr_mem;
- GElf_Shdr *shdr = gelf_getshdr (new_shstrtab_scn, &shdr_mem);
+ shdr = gelf_getshdr (new_shstrtab_scn, &shdr_mem);
if (shdr == NULL)
{
printf ("cannot get header for new shstrtab section: %s\n",
@@ -218,7 +237,7 @@ add_sections (const char *name, size_t nr, int use_mmap)
shdr->sh_addralign = 1;
shdr->sh_entsize = 0;
shdr->sh_size = new_shstrtab_size;
- shdr->sh_name = new_shstrtab_idx;
+ shdr->sh_name = shstrtab_idx;
// Finished new shstrtab section, update the header.
if (gelf_update_shdr (new_shstrtab_scn, shdr) == 0)
diff --git a/tests/backtrace-child.c b/tests/backtrace-child.c
index 9c6ba94f..8bfed478 100644
--- a/tests/backtrace-child.c
+++ b/tests/backtrace-child.c
@@ -164,7 +164,6 @@ stdarg (int f UNUSED, ...)
if (ptraceme)
{
long l = ptrace (PTRACE_TRACEME, 0, NULL, NULL);
- assert (errno == 0);
assert (l == 0);
}
#ifdef RAISE_JMP_PATCHING
@@ -236,7 +235,6 @@ main (int argc UNUSED, char **argv)
{
errno = 0;
long l = ptrace (PTRACE_TRACEME, 0, NULL, NULL);
- assert (errno == 0);
assert (l == 0);
}
if (gencore)
diff --git a/tests/backtrace-data.c b/tests/backtrace-data.c
index 67ecd475..907b4780 100644
--- a/tests/backtrace-data.c
+++ b/tests/backtrace-data.c
@@ -47,7 +47,7 @@
int
main (int argc __attribute__ ((unused)), char **argv)
{
- fprintf (stderr, "%s: Unwinding not supported for this architecture\n",
+ fprintf (stderr, "%s: x86_64 linux only test\n",
argv[0]);
return 77;
}
@@ -96,18 +96,15 @@ maps_lookup (pid_t pid, Dwarf_Addr addr, GElf_Addr *basep)
{
char *fname;
int i = asprintf (&fname, "/proc/%ld/maps", (long) pid);
- assert (errno == 0);
assert (i > 0);
FILE *f = fopen (fname, "r");
- assert (errno == 0);
assert (f);
free (fname);
for (;;)
{
// 37e3c22000-37e3c23000 rw-p 00022000 00:11 49532 /lib64/ld-2.14.90.so */
unsigned long start, end, offset;
- i = fscanf (f, "%lx-%lx %*s %lx %*x:%*x %*x", &start, &end, &offset);
- assert (errno == 0);
+ i = fscanf (f, "%lx-%lx %*s %lx %*x:%*x %*u", &start, &end, &offset);
if (i != 3)
break;
char *filename = strdup ("");
@@ -129,7 +126,6 @@ maps_lookup (pid_t pid, Dwarf_Addr addr, GElf_Addr *basep)
if (start <= addr && addr < end)
{
i = fclose (f);
- assert (errno == 0);
assert (i == 0);
*basep = start - offset;
@@ -183,7 +179,6 @@ set_initial_registers (Dwfl_Thread *thread,
struct user_regs_struct user_regs;
long l = ptrace (PTRACE_GETREGS, child, NULL, &user_regs);
- assert (errno == 0);
assert (l == 0);
Dwarf_Word dwarf_regs[17];
@@ -284,11 +279,9 @@ main (int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)))
switch (child)
{
case -1:
- assert (errno == 0);
assert (0);
case 0:;
long l = ptrace (PTRACE_TRACEME, 0, NULL, NULL);
- assert (errno == 0);
assert (l == 0);
raise (SIGUSR1);
return 0;
@@ -298,7 +291,6 @@ main (int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)))
int status;
pid_t pid = waitpid (child, &status, 0);
- assert (errno == 0);
assert (pid == child);
assert (WIFSTOPPED (status));
assert (WSTOPSIG (status) == SIGUSR1);
@@ -316,7 +308,6 @@ main (int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)))
struct user_regs_struct user_regs;
long l = ptrace (PTRACE_GETREGS, child, NULL, &user_regs);
- assert (errno == 0);
assert (l == 0);
report_module (dwfl, child, user_regs.rip);
@@ -330,7 +321,6 @@ main (int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)))
dwfl_end (dwfl);
kill (child, SIGKILL);
pid = waitpid (child, &status, 0);
- assert (errno == 0);
assert (pid == child);
assert (WIFSIGNALED (status));
assert (WTERMSIG (status) == SIGKILL);
diff --git a/tests/backtrace-subr.sh b/tests/backtrace-subr.sh
index ff42c6ff..53c719df 100644
--- a/tests/backtrace-subr.sh
+++ b/tests/backtrace-subr.sh
@@ -85,6 +85,7 @@ check_unsupported()
testname=$2
if grep -q ': Unwinding not supported for this architecture$' $err; then
echo >&2 $testname: arch not supported
+ test_cleanup
exit 77
fi
}
diff --git a/tests/backtrace.c b/tests/backtrace.c
index 24ab68dd..05e8ef82 100644
--- a/tests/backtrace.c
+++ b/tests/backtrace.c
@@ -281,16 +281,13 @@ prepare_thread (pid_t pid2 __attribute__ ((unused)),
struct user_regs_struct user_regs;
errno = 0;
l = ptrace (PTRACE_GETREGS, pid2, 0, (intptr_t) &user_regs);
- assert (errno == 0);
assert (l == 0);
user_regs.rip = (intptr_t) jmp;
l = ptrace (PTRACE_SETREGS, pid2, 0, (intptr_t) &user_regs);
- assert (errno == 0);
assert (l == 0);
l = ptrace (PTRACE_CONT, pid2, NULL, (void *) (intptr_t) SIGUSR2);
int status;
pid_t got = waitpid (pid2, &status, __WALL);
- assert (errno == 0);
assert (got == pid2);
assert (WIFSTOPPED (status));
assert (WSTOPSIG (status) == SIGUSR1);
@@ -358,7 +355,6 @@ exec_dump (const char *exec)
errno = 0;
int status;
pid_t got = waitpid (pid, &status, 0);
- assert (errno == 0);
assert (got == pid);
assert (WIFSTOPPED (status));
// Main thread will signal SIGUSR2. Other thread will signal SIGUSR1.
@@ -368,7 +364,6 @@ exec_dump (const char *exec)
__WCLONE, probably despite pthread_create already had to be called the new
task is not yet alive enough for waitpid. */
pid_t pid2 = waitpid (-1, &status, __WALL);
- assert (errno == 0);
assert (pid2 > 0);
assert (pid2 != pid);
assert (WIFSTOPPED (status));
diff --git a/tests/run-annobingroup.sh b/tests/run-annobingroup.sh
index fd36e4ac..16b031a1 100755
--- a/tests/run-annobingroup.sh
+++ b/tests/run-annobingroup.sh
@@ -25,7 +25,7 @@
# gcc -g -O2 -fplugin=annobin -c testfile-annobingroup.c
testfiles testfile-annobingroup.o
-tempfiles merged.elf stripped.elf debugfile.elf remerged.elf
+tempfiles merged.elf stripped.elf debugfile1.elf debugfile2.elf debugfile3.elf remerged.elf
testrun_compare ${abs_top_builddir}/src/readelf -g testfile-annobingroup.o << EOF
@@ -35,7 +35,7 @@ Section group [ 1] '.group' with signature '.text.unlikely.group' contains 3 ent
[ 9] .text.unlikely
EOF
-testrun ${abs_top_builddir}/src/strip -o stripped.elf -f debugfile.elf testfile-annobingroup.o
+testrun ${abs_top_builddir}/src/strip -o stripped.elf -f debugfile1.elf testfile-annobingroup.o
testrun_compare ${abs_top_builddir}/src/readelf -g stripped.elf << EOF
@@ -45,7 +45,7 @@ Section group [ 1] '.group' with signature '.text.unlikely.group' contains 3 ent
[ 9] .text.unlikely
EOF
-testrun_compare ${abs_top_builddir}/src/readelf -g debugfile.elf << EOF
+testrun_compare ${abs_top_builddir}/src/readelf -g debugfile1.elf << EOF
Section group [ 1] '.group' with signature '.text.unlikely.group' contains 3 entries:
[ 7] .gnu.build.attributes..text.unlikely
@@ -53,7 +53,7 @@ Section group [ 1] '.group' with signature '.text.unlikely.group' contains 3 ent
[ 9] .text.unlikely
EOF
-testrun ${abs_top_builddir}/src/unstrip -o remerged.elf stripped.elf debugfile.elf
+testrun ${abs_top_builddir}/src/unstrip -o remerged.elf stripped.elf debugfile1.elf
testrun_compare ${abs_top_builddir}/src/readelf -g remerged.elf << EOF
@@ -81,7 +81,7 @@ COMDAT section group [ 2] '.group' with signature '__x86.get_pc_thunk.ax' contai
[13] .text.__x86.get_pc_thunk.ax
EOF
-testrun ${abs_top_builddir}/src/strip -o stripped.elf -f debugfile.elf testfile-annobingroup-i386.o
+testrun ${abs_top_builddir}/src/strip -o stripped.elf -f debugfile2.elf testfile-annobingroup-i386.o
testrun_compare ${abs_top_builddir}/src/readelf -g stripped.elf << EOF
@@ -94,7 +94,7 @@ COMDAT section group [ 2] '.group' with signature '__x86.get_pc_thunk.ax' contai
[13] .text.__x86.get_pc_thunk.ax
EOF
-testrun_compare ${abs_top_builddir}/src/readelf -g debugfile.elf << EOF
+testrun_compare ${abs_top_builddir}/src/readelf -g debugfile2.elf << EOF
Section group [ 1] '.group' with signature '.text.unlikely.group' contains 3 entries:
[ 8] .gnu.build.attributes..text.unlikely
@@ -105,7 +105,7 @@ COMDAT section group [ 2] '.group' with signature '__x86.get_pc_thunk.ax' contai
[13] .text.__x86.get_pc_thunk.ax
EOF
-testrun ${abs_top_builddir}/src/unstrip -o remerged.elf stripped.elf debugfile.elf
+testrun ${abs_top_builddir}/src/unstrip -o remerged.elf stripped.elf debugfile2.elf
testrun_compare ${abs_top_builddir}/src/readelf -g remerged.elf << EOF
@@ -143,13 +143,13 @@ Section group [ 4] '.group' with signature '.text.unlikely..group' contains 1 en
[27] .text.unlikely
EOF
-testrun ${abs_top_builddir}/src/strip -o stripped.elf -f debugfile.elf testfile-annobingroup-x86_64.o
+testrun ${abs_top_builddir}/src/strip -o stripped.elf -f debugfile3.elf testfile-annobingroup-x86_64.o
# This would/should work, except for the unknown NOTEs.
# testrun ${abs_top_builddir}/src/elflint --gnu stripped.elf
-# testrun ${abs_top_builddir}/src/elflint --gnu --debug debugfile.elf
+# testrun ${abs_top_builddir}/src/elflint --gnu --debug debugfile3.elf
-testrun ${abs_top_builddir}/src/unstrip -o remerged.elf stripped.elf debugfile.elf
+testrun ${abs_top_builddir}/src/unstrip -o remerged.elf stripped.elf debugfile3.elf
testrun ${abs_top_builddir}/src/elfcmp testfile-annobingroup-x86_64.o remerged.elf
diff --git a/tests/run-backtrace-data.sh b/tests/run-backtrace-data.sh
index 34a4f01d..3062c304 100755
--- a/tests/run-backtrace-data.sh
+++ b/tests/run-backtrace-data.sh
@@ -22,7 +22,11 @@
unset VALGRIND_CMD
tempfiles data.{bt,err}
-(set +ex; testrun ${abs_builddir}/backtrace-data 1>data.bt 2>data.err; true)
+(set +ex;
+ testrun ${abs_builddir}/backtrace-data 1>data.bt 2>data.err;
+ if test $? == 77; then cat data.{bt,err}; exit 77; fi
+ true)
+
cat data.{bt,err}
check_unsupported data.err data
check_all data.{bt,err} data
diff --git a/tests/run-readelf-compressed.sh b/tests/run-readelf-compressed.sh
index a2a04a2a..861553fe 100755
--- a/tests/run-readelf-compressed.sh
+++ b/tests/run-readelf-compressed.sh
@@ -17,6 +17,11 @@
. $srcdir/test-subr.sh
+if ! grep -q -F '#define USE_BZLIB' ${abs_top_builddir}/config.h; then
+ echo "elfutils built without bzip2 support"
+ exit 77
+fi
+
# See run-strip-reloc.sh
testfiles hello_i386.ko
diff --git a/tests/run-readelf-n.sh b/tests/run-readelf-n.sh
index c2db2ce2..cc7d7f66 100755
--- a/tests/run-readelf-n.sh
+++ b/tests/run-readelf-n.sh
@@ -125,3 +125,104 @@ Note section [22] '.note.gnu.property' of 48 bytes at offset 0x40c:
X86 0xc0000000 data: 00 00 00 00
X86 0xc0000001 data: 00 00 00 00
EOF
+
+#
+# = gnu_props.S
+#
+# #define NT_GNU_PROPERTY_TYPE_0 5
+# #define GNU_PROPERTY_STACK_SIZE 1
+# #define GNU_PROPERTY_NO_COPY_ON_PROTECTED 2
+
+# /* Normal notes always have alignment and padding of 4 bytes,
+# but GNU Property notes use 4 byte words, with 8 byte padding
+# for ELFCLASS64. */
+# #if __SIZEOF_PTRDIFF_T__ == 8
+# # define ALIGN 3
+# #elif __SIZEOF_PTRDIFF_T__ == 4
+# # define ALIGN 2
+# #endif
+#
+# .section ".note.gnu.property", "a"
+# .p2align ALIGN
+# /* First note. */
+# .long 1f - 0f /* name length. */
+# .long 4f - 2f /* data length. */
+# .long NT_GNU_PROPERTY_TYPE_0 /* note type. */
+# 0:
+# .asciz "GNU" /* vendor name. */
+# 1:
+# .p2align ALIGN /* Padding. */
+# 2:
+# .long GNU_PROPERTY_STACK_SIZE /* pr_type. */
+# .long 4f - 3f /* pr_datasz. */
+# 3:
+# .dc.a 0x280000 /* Stack size. */
+# 4:
+# .p2align ALIGN
+#
+# /* Second note. */
+# .long 6f - 5f /* name length. */
+# .long 8f - 7f /* data length. */
+# .long NT_GNU_PROPERTY_TYPE_0 /* note type. */
+# 5:
+# .asciz "GNU" /* vendor name. */
+# 6:
+# .p2align ALIGN /* Padding. */
+# 7:
+# .long GNU_PROPERTY_NO_COPY_ON_PROTECTED /* pr_type. */
+# .long 0 /* pr_datasz. */
+# /* No data. */
+# 8:
+# .p2align ALIGN
+#
+# On x86_64
+# gcc -m64 -c -o testfile_gnu_props_64le.o gnu_props.S
+# gcc -m32 -c -o testfile_gnu_props_32le.o gnu_props.S
+
+testfiles testfile_gnu_props.32le.o testfile_gnu_props.64le.o
+
+testrun_compare ${abs_top_builddir}/src/readelf -n testfile_gnu_props.32le.o << EOF
+
+Note section [ 4] '.note.gnu.property' of 52 bytes at offset 0x34:
+ Owner Data size Type
+ GNU 12 GNU_PROPERTY_TYPE_0
+ STACK_SIZE 0x280000
+ GNU 8 GNU_PROPERTY_TYPE_0
+ NO_COPY_ON_PROTECTION
+EOF
+
+testrun_compare ${abs_top_builddir}/src/readelf -n testfile_gnu_props.64le.o << EOF
+
+Note section [ 4] '.note.gnu.property' of 56 bytes at offset 0x40:
+ Owner Data size Type
+ GNU 16 GNU_PROPERTY_TYPE_0
+ STACK_SIZE 0x280000
+ GNU 8 GNU_PROPERTY_TYPE_0
+ NO_COPY_ON_PROTECTION
+EOF
+
+# On ppc64
+# gcc -m32 -c -o testfile_gnu_props.32be.o gnu_props.S
+# gcc -m64 -c -o testfile_gnu_props.64be.o gnu_props.S
+
+testfiles testfile_gnu_props.32be.o testfile_gnu_props.64be.o
+
+testrun_compare ${abs_top_builddir}/src/readelf -n testfile_gnu_props.32be.o << EOF
+
+Note section [ 4] '.note.gnu.property' of 52 bytes at offset 0x34:
+ Owner Data size Type
+ GNU 12 GNU_PROPERTY_TYPE_0
+ STACK_SIZE 0x280000
+ GNU 8 GNU_PROPERTY_TYPE_0
+ NO_COPY_ON_PROTECTION
+EOF
+
+testrun_compare ${abs_top_builddir}/src/readelf -n testfile_gnu_props.64be.o << EOF
+
+Note section [ 4] '.note.gnu.property' of 56 bytes at offset 0x40:
+ Owner Data size Type
+ GNU 16 GNU_PROPERTY_TYPE_0
+ STACK_SIZE 0x280000
+ GNU 8 GNU_PROPERTY_TYPE_0
+ NO_COPY_ON_PROTECTION
+EOF
diff --git a/tests/run-strip-test-many.sh b/tests/run-strip-test-many.sh
index 9a9657cd..b0cbad8b 100755
--- a/tests/run-strip-test-many.sh
+++ b/tests/run-strip-test-many.sh
@@ -17,50 +17,67 @@
. $srcdir/test-subr.sh
+status=0
+
# Use the original file from run-strip-test.sh but with many sections
testfiles testfile
-tempfiles testfile.strip testfile.debug testfile.unstrip
+tempfiles testfile1.strip testfile2.strip testfile1.debug testfile2.debug testfile.unstrip
echo "Adding sections to testfile"
-testrun ${abs_builddir}/addsections 65535 testfile
+testrun ${abs_builddir}/addsections 65535 testfile ||
+{ echo "*** failure addsections testfile"; status=1; }
echo "Testing strip -o"
-testrun ${abs_top_builddir}/src/strip -o testfile.strip -f testfile.debug testfile
+testrun ${abs_top_builddir}/src/strip -o testfile1.strip -f testfile1.debug testfile ||
+{ echo "*** failure strip -o"; status=1; }
# Do the parts check out?
-echo "elflint testfile.strip"
-testrun ${abs_top_builddir}/src/elflint --gnu -q testfile.strip
-echo "elflint testfile.debug"
-testrun ${abs_top_builddir}/src/elflint --gnu -q -d testfile.debug
+echo "elflint testfile1.strip"
+testrun ${abs_top_builddir}/src/elflint --gnu -q testfile1.strip ||
+{ echo "*** failure elflint testfile1.strip"; status=1; }
+
+echo "elflint testfile1.debug"
+testrun ${abs_top_builddir}/src/elflint --gnu -q -d testfile1.debug ||
+{ echo "*** failure elflint testfile1.debug"; status=1; }
# Now test unstrip recombining those files.
echo "unstrip"
-testrun ${abs_top_builddir}/src/unstrip -o testfile.unstrip testfile.strip testfile.debug
+testrun ${abs_top_builddir}/src/unstrip -o testfile.unstrip testfile1.strip testfile1.debug ||
+{ echo "*** failure unstrip"; status=1; }
+
echo "elfcmp"
-testrun ${abs_top_builddir}/src/elfcmp testfile testfile.unstrip
+testrun ${abs_top_builddir}/src/elfcmp testfile testfile.unstrip ||
+{ echo "*** failure elfcmp"; status=1; }
# test strip -g
echo "Testing strip -g"
-testrun ${abs_top_builddir}/src/strip -g -o testfile.strip -f testfile.debug testfile
+testrun ${abs_top_builddir}/src/strip -g -o testfile2.strip -f testfile2.debug testfile ||
+{ echo "*** failure strip -g"; status=1; }
# Do the parts check out?
-echo "elflint testfile.strip"
-testrun ${abs_top_builddir}/src/elflint --gnu -q testfile.strip
-echo "elflint testfile.debug"
-testrun ${abs_top_builddir}/src/elflint --gnu -q -d testfile.debug
+echo "elflint testfile2.strip"
+testrun ${abs_top_builddir}/src/elflint --gnu -q testfile2.strip ||
+{ echo "*** failure elflint testfile2.strip"; status=1; }
+
+echo "elflint testfile2.debug"
+testrun ${abs_top_builddir}/src/elflint --gnu -q -d testfile2.debug ||
+{ echo "*** failure elflint testfile2.debug"; status=1; }
# Now strip "in-place" and make sure it is smaller.
-echo "TEsting strip in-place"
+echo "Testing strip in-place"
SIZE_original=$(stat -c%s testfile)
echo "original size $SIZE_original"
-testrun ${abs_top_builddir}/src/strip testfile
+testrun ${abs_top_builddir}/src/strip testfile ||
+{ echo "*** failure strip in-place"; status=1; }
+
SIZE_stripped=$(stat -c%s testfile)
echo "stripped size $SIZE_stripped"
test $SIZE_stripped -lt $SIZE_original ||
{ echo "*** failure in-place strip file not smaller $original"; exit 1; }
echo "elflint in-place"
-testrun ${abs_top_builddir}/src/elflint --gnu -q testfile
+testrun ${abs_top_builddir}/src/elflint --gnu -q testfile ||
+{ echo "*** failure elflint in-place"; status=1; }
-exit 0
+exit $status
diff --git a/tests/run-strip-version.sh b/tests/run-strip-version.sh
new file mode 100755
index 00000000..191e0aac
--- /dev/null
+++ b/tests/run-strip-version.sh
@@ -0,0 +1,58 @@
+#! /bin/sh
+# Copyright (C) 2018 Red Hat, Inc.
+# This file is part of elfutils.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# elfutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. $srcdir/test-subr.sh
+
+# Generated on s390x with an older gas (2.29.1) that generates
+# badly aligned version notes.
+#
+# = testfile-version.s =
+#
+# .section ".extra"
+# .byte 42
+#
+# .version "Sliding Snow"
+# .version "Hurr durr 3.1"
+#
+# .globl _start
+#_start:
+#
+# gcc -nostartfiles -nodefaultlibs -o testfile-version testfile-version.s
+
+testfiles testfile-version
+tempfiles debug.out elf.out
+
+testrun ${abs_top_builddir}/src/strip -o elf.out -f debug.out \
+ testfile-version
+
+testrun ${abs_top_builddir}/src/elflint --gnu elf.out
+testrun ${abs_top_builddir}/src/elflint --gnu --debug debug.out
+
+testrun_compare ${abs_top_builddir}/src/readelf -n debug.out <<\EOF
+
+Note section [ 1] '.note.gnu.build-id' of 36 bytes at offset 0xb0:
+ Owner Data size Type
+ GNU 20 GNU_BUILD_ID
+ Build ID: d3c84c0b307c06f50a37c6c0f59c82c4cb10720b
+
+Note section [ 3] '.note' of 56 bytes at offset 0xd5:
+ Owner Data size Type
+ Sliding Snow 0 VERSION
+ Hurr durr 3.1 0 VERSION
+EOF
+
+exit 0
diff --git a/tests/testfile-version.bz2 b/tests/testfile-version.bz2
new file mode 100755
index 00000000..b2c0c0ce
--- /dev/null
+++ b/tests/testfile-version.bz2
Binary files differ
diff --git a/tests/testfile_gnu_props.32be.o.bz2 b/tests/testfile_gnu_props.32be.o.bz2
new file mode 100644
index 00000000..60a39fe5
--- /dev/null
+++ b/tests/testfile_gnu_props.32be.o.bz2
Binary files differ
diff --git a/tests/testfile_gnu_props.32le.o.bz2 b/tests/testfile_gnu_props.32le.o.bz2
new file mode 100644
index 00000000..cb5d23c2
--- /dev/null
+++ b/tests/testfile_gnu_props.32le.o.bz2
Binary files differ
diff --git a/tests/testfile_gnu_props.64be.o.bz2 b/tests/testfile_gnu_props.64be.o.bz2
new file mode 100644
index 00000000..784c98bc
--- /dev/null
+++ b/tests/testfile_gnu_props.64be.o.bz2
Binary files differ
diff --git a/tests/testfile_gnu_props.64le.o.bz2 b/tests/testfile_gnu_props.64le.o.bz2
new file mode 100644
index 00000000..09df3d1e
--- /dev/null
+++ b/tests/testfile_gnu_props.64le.o.bz2
Binary files differ