summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog60
-rw-r--r--tests/Makefile.am17
-rw-r--r--tests/backtrace-subr.sh2
-rw-r--r--tests/backtrace.ppc64le.fp.core.bz2bin0 -> 37786 bytes
-rwxr-xr-xtests/backtrace.ppc64le.fp.exec.bz2bin0 -> 383808 bytes
-rw-r--r--tests/dwarf-getmacros.c10
-rw-r--r--tests/dwarf_default_lower_bound.c83
-rw-r--r--tests/elfshphehdr.c2
-rw-r--r--tests/get-lines.c23
-rwxr-xr-xtests/run-addrcfi.sh18
-rwxr-xr-xtests/run-allregs.sh12
-rwxr-xr-xtests/run-backtrace-fp-core-ppc64le.sh29
-rwxr-xr-xtests/run-strip-g.sh77
-rwxr-xr-xtests/run-strip-nothing.sh62
-rwxr-xr-xtests/run-strip-remove-keep.sh688
-rwxr-xr-xtests/run-strip-test.sh8
16 files changed, 1062 insertions, 29 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 5b0d486e..04efdc81 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,63 @@
+2017-07-26 Mark Wielaard <[email protected]>
+
+ * dwarf-getmacros.c (mac): Use DW_MACRO names instead of DW_MACRO_GNU.
+
+2016-10-27 Mark Wielaard <[email protected]>
+
+ * dwarf_default_lower_bound.c: New test.
+ * Makefile.am (check_PROGRAMS): Add dwarf_default_lower_bound.
+ (TESTS): Likewise.
+ (dwarf_default_lower_bound_LDADD): New variable.
+
+2017-07-21 Mark Wielaard <[email protected]>
+
+ * get-lines.c (main): Add dwarf_line_file test.
+
+2017-07-19 Gustavo Romero <[email protected]>
+
+ * run-addrcfi.sh: Update generic SPRs names to HTM SPRs names
+ * run-allregs.sh: Update generic SPRs names to HTM SPRs names
+
+2017-07-20 Mark Wielaard <[email protected]>
+
+ * run-strip-g.sh: New test.
+ * Makefile.am (TESTS): Add run-strip-g.sh.
+ (EXTRA_DIST): Likewise.
+
+2017-07-18 Mark Wielaard <[email protected]>
+
+ * Makefile.am (TESTS): Always add run-disasm-bpf.sh if HAVE_LIBASM.
+
+2017-05-04 Ulf Hermann <[email protected]>
+
+ * elfshphehdr.c: For writing, use /dev/null rather than /dev/zero.
+
+2017-07-14 Mark Wielaard <[email protected]>
+
+ * run-strip-remove-keep.sh: New test.
+ * Makefile.am (TESTS): Add run-strip-remove-keep.sh.
+ (EXTRA_DIST): Likewise.
+
+2017-06-07 Mark Wielaard <[email protected]>
+
+ * run-strip-nothing.sh: New test.
+ * Makefile.am (TESTS): Add run-strip-nothing.sh.
+ (EXTRA_DIST): Likewise.
+
+2017-06-06 Mark Wielaard <[email protected]>
+
+ * run-strip-test.sh: Test strip -g doesn't introduce extra .shstrtab.
+
+2017-05-30 Mark Wielaard <[email protected]>
+
+ * run-backtrace-fp-core-ppc64le.sh: New test.
+ * backtrace.ppc64le.fp.core.bz2: New test file.
+ * backtrace.ppc64le.fp.exec.bz2: New testfile.
+ * backtrace-subr.sh (check_backtracegen): Accept '(null)'.
+ * Makefile.am (TESTS): Add run-backtrace-fp-core-ppc64le.sh.
+ (EXTRA_DIST): Add run-backtrace-fp-core-ppc64le.sh,
+ backtrace.ppc64le.fp.core.bz2 and backtrace.ppc64le.fp.exec.bz2.
+
2017-02-13 Ulf Hermann <[email protected]>
Mark Wielaard <[email protected]>
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d17ffd47..483f3878 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -55,7 +55,7 @@ check_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \
getsrc_die strptr newdata elfstrtab dwfl-proc-attach \
elfshphehdr elfstrmerge dwelfgnucompressed elfgetchdr \
elfgetzdata elfputzdata zstrptr emptyfile vendorelf \
- fillfile
+ fillfile dwarf_default_lower_bound
asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \
asm-tst6 asm-tst7 asm-tst8 asm-tst9
@@ -81,8 +81,9 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
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-test9.sh run-strip-test10.sh \
+ run-strip-nothing.sh run-strip-g.sh \
run-strip-groups.sh run-strip-reloc.sh run-strip-strmerge.sh \
- run-strip-nobitsalign.sh \
+ run-strip-nobitsalign.sh run-strip-remove-keep.sh \
run-unstrip-test.sh run-unstrip-test2.sh run-unstrip-test3.sh \
run-unstrip-test4.sh run-unstrip-M.sh run-elfstrmerge-test.sh \
run-ecp-test.sh run-ecp-test2.sh run-alldts.sh \
@@ -117,6 +118,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
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-fp-core-ppc64le.sh \
run-backtrace-core-x32.sh \
run-backtrace-core-i386.sh run-backtrace-fp-core-i386.sh \
run-backtrace-core-ppc.sh \
@@ -133,7 +135,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
run-elfgetzdata.sh run-elfputzdata.sh run-zstrptr.sh \
run-compress-test.sh \
run-readelf-zdebug.sh run-readelf-zdebug-rel.sh \
- emptyfile vendorelf fillfile
+ emptyfile vendorelf fillfile dwarf_default_lower_bound
if !BIARCH
export ELFUTILS_DISABLE_BIARCH = 1
@@ -154,10 +156,7 @@ endif
if HAVE_LIBASM
check_PROGRAMS += $(asm_TESTS)
-TESTS += $(asm_TESTS)
-if HAVE_LINUX_BPF_H
-TESTS += run-disasm-bpf.sh
-endif
+TESTS += $(asm_TESTS) run-disasm-bpf.sh
endif
EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
@@ -174,6 +173,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
run-strip-test4.sh run-strip-test5.sh run-strip-test6.sh \
run-strip-test7.sh run-strip-test8.sh run-strip-groups.sh \
run-strip-test9.sh run-strip-test10.sh run-strip-test11.sh \
+ run-strip-nothing.sh run-strip-remove-keep.sh run-strip-g.sh \
run-strip-strmerge.sh run-strip-nobitsalign.sh \
testfile-nobitsalign.bz2 testfile-nobitsalign.strip.bz2 \
run-strip-reloc.sh hello_i386.ko.bz2 hello_x86_64.ko.bz2 \
@@ -303,6 +303,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
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 \
+ run-backtrace-fp-core-ppc64le.sh \
+ backtrace.ppc64le.fp.core.bz2 backtrace.ppc64le.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 \
@@ -505,6 +507,7 @@ zstrptr_LDADD = $(libelf)
emptyfile_LDADD = $(libelf)
vendorelf_LDADD = $(libelf)
fillfile_LDADD = $(libelf)
+dwarf_default_lower_bound_LDADD = $(libdw)
# We want to test the libelf header against the system elf.h header.
# Don't include any -I CPPFLAGS.
diff --git a/tests/backtrace-subr.sh b/tests/backtrace-subr.sh
index 9731c43a..c1f31569 100644
--- a/tests/backtrace-subr.sh
+++ b/tests/backtrace-subr.sh
@@ -59,7 +59,7 @@ check_backtracegen()
# 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|address out of range|Invalid register)$' \
+ if [ $(egrep -v <$1 'dwfl_thread_getframes: (No DWARF information found|no matching address range|address out of range|Invalid register|\(null\))$' \
| wc -c) \
-eq 0 ]
then
diff --git a/tests/backtrace.ppc64le.fp.core.bz2 b/tests/backtrace.ppc64le.fp.core.bz2
new file mode 100644
index 00000000..e63babf3
--- /dev/null
+++ b/tests/backtrace.ppc64le.fp.core.bz2
Binary files differ
diff --git a/tests/backtrace.ppc64le.fp.exec.bz2 b/tests/backtrace.ppc64le.fp.exec.bz2
new file mode 100755
index 00000000..ed1352af
--- /dev/null
+++ b/tests/backtrace.ppc64le.fp.exec.bz2
Binary files differ
diff --git a/tests/dwarf-getmacros.c b/tests/dwarf-getmacros.c
index 92e093ca..ac70248d 100644
--- a/tests/dwarf-getmacros.c
+++ b/tests/dwarf-getmacros.c
@@ -38,7 +38,7 @@ mac (Dwarf_Macro *macro, void *dbg)
dwarf_macro_opcode (macro, &opcode);
switch (opcode)
{
- case DW_MACRO_GNU_transparent_include:
+ case DW_MACRO_import:
{
Dwarf_Attribute at;
int r = dwarf_macro_param (macro, 0, &at);
@@ -56,7 +56,7 @@ mac (Dwarf_Macro *macro, void *dbg)
break;
}
- case DW_MACRO_GNU_start_file:
+ case DW_MACRO_start_file:
{
Dwarf_Files *files;
size_t nfiles;
@@ -73,7 +73,7 @@ mac (Dwarf_Macro *macro, void *dbg)
break;
}
- case DW_MACRO_GNU_end_file:
+ case DW_MACRO_end_file:
{
--level;
printf ("%*s/file\n", level, "");
@@ -81,7 +81,7 @@ mac (Dwarf_Macro *macro, void *dbg)
}
case DW_MACINFO_define:
- case DW_MACRO_GNU_define_indirect:
+ case DW_MACRO_define_strp:
{
const char *value;
dwarf_macro_param2 (macro, NULL, &value);
@@ -90,7 +90,7 @@ mac (Dwarf_Macro *macro, void *dbg)
}
case DW_MACINFO_undef:
- case DW_MACRO_GNU_undef_indirect:
+ case DW_MACRO_undef_strp:
break;
default:
diff --git a/tests/dwarf_default_lower_bound.c b/tests/dwarf_default_lower_bound.c
new file mode 100644
index 00000000..d57424fc
--- /dev/null
+++ b/tests/dwarf_default_lower_bound.c
@@ -0,0 +1,83 @@
+/* Test all DW_LANG constants are handled by dwarf_default_lower_bound.
+
+ Copyright (C) 2016 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 <dwarf.h>
+#include ELFUTILS_HEADER(dw)
+#include "../libdw/known-dwarf.h"
+
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static void
+test_lang (const char *name, int lang)
+{
+ Dwarf_Sword low;
+ int res = dwarf_default_lower_bound (lang, &low);
+
+ /* Assembler is special, it doesn't really have arrays. */
+ if (lang == DW_LANG_Mips_Assembler)
+ {
+ if (res == 0)
+ {
+ printf ("%s shouldn't have a known lower bound\n", name);
+ exit (-1);
+ }
+ printf ("%s: <unknown>\n", name);
+ return;
+ }
+
+ if (res != 0)
+ {
+ printf ("dwarf_default_lower_bound failed (%d) for %s\n", res, name);
+ exit (-1);
+ }
+
+ /* All currently known lower bounds are either zero or one, but
+ they don't have to. Update test once one is a different value. */
+ if (low != 0 && low != 1)
+ {
+ printf ("unexpected lower bound %" PRId64 " for %s\n", low, name);
+ exit (-1);
+ }
+
+ printf ("%s: %" PRId64 "\n", name, low);
+}
+
+int
+main (int argc __attribute__ ((unused)), char *argv[] __attribute__ ((unused)))
+{
+ Dwarf_Sword low;
+ /* Bad language code must fail. */
+ if (dwarf_default_lower_bound (-1, &low) == 0)
+ {
+ printf ("Bad lang code -1 succeeded (%" PRId64 ")\n", low);
+ exit (-1);
+ }
+
+ /* Test all known language codes. */
+#define DWARF_ONE_KNOWN_DW_LANG(NAME, CODE) test_lang (#NAME, CODE);
+ DWARF_ALL_KNOWN_DW_LANG
+#undef DWARF_ONE_KNOWN_DW_LANG
+
+ return 0;
+}
diff --git a/tests/elfshphehdr.c b/tests/elfshphehdr.c
index 5a297e0d..8183937c 100644
--- a/tests/elfshphehdr.c
+++ b/tests/elfshphehdr.c
@@ -152,7 +152,7 @@ main (int argc __attribute__ ((unused)), char **argv __attribute ((unused)))
{
elf_version (EV_CURRENT);
- int fd = fd = open("/dev/zero", O_WRONLY);
+ int fd = open("/dev/null", O_WRONLY);
check ("open", fd >= 0);
Elf *elf;
diff --git a/tests/get-lines.c b/tests/get-lines.c
index c361a2c3..188d0162 100644
--- a/tests/get-lines.c
+++ b/tests/get-lines.c
@@ -24,6 +24,7 @@
#include <libelf.h>
#include ELFUTILS_HEADER(dw)
#include <stdio.h>
+#include <string.h>
#include <unistd.h>
@@ -100,6 +101,28 @@ main (int argc, char *argv[])
printf ("%" PRIx64 ": %s:%d:", (uint64_t) addr,
file ?: "???", line);
+ /* Getting the file path through the Dwarf_Files should
+ result in the same path. */
+ Dwarf_Files *files;
+ size_t idx;
+ if (dwarf_line_file (l, &files, &idx) != 0)
+ {
+ printf ("%s: cannot get file from line (%zd): %s\n",
+ argv[cnt], i, dwarf_errmsg (-1));
+ result = 1;
+ break;
+ }
+ const char *path = dwarf_filesrc (files, idx, NULL, NULL);
+ if ((path == NULL && file != NULL)
+ || (path != NULL && file == NULL)
+ || (strcmp (file, path) != 0))
+ {
+ printf ("%s: line %zd srcline (%s) != file srcline (%s)\n",
+ argv[cnt], i, file ?: "???", path ?: "???");
+ result = 1;
+ break;
+ }
+
int column;
if (dwarf_linecol (l, &column) != 0)
column = 0;
diff --git a/tests/run-addrcfi.sh b/tests/run-addrcfi.sh
index 2691091b..7fc46e58 100755
--- a/tests/run-addrcfi.sh
+++ b/tests/run-addrcfi.sh
@@ -397,9 +397,9 @@ dwarf_cfi_addrframe (.eh_frame): no matching address range
privileged reg111 (spr11): undefined
privileged reg112 (spr12): undefined
privileged reg113 (spr13): undefined
- privileged reg114 (spr14): undefined
- privileged reg115 (spr15): undefined
- privileged reg116 (spr16): undefined
+ privileged reg114 (tfhar): undefined
+ privileged reg115 (tfiar): undefined
+ privileged reg116 (texasr): undefined
privileged reg117 (spr17): undefined
privileged reg118 (dsisr): undefined
privileged reg119 (dar): undefined
@@ -1419,9 +1419,9 @@ testrun_compare ${abs_builddir}/addrcfi -e testfileppc32 0x100004d2 <<\EOF
privileged reg111 (spr11): undefined
privileged reg112 (spr12): undefined
privileged reg113 (spr13): undefined
- privileged reg114 (spr14): undefined
- privileged reg115 (spr15): undefined
- privileged reg116 (spr16): undefined
+ privileged reg114 (tfhar): undefined
+ privileged reg115 (tfiar): undefined
+ privileged reg116 (texasr): undefined
privileged reg117 (spr17): undefined
privileged reg118 (dsisr): undefined
privileged reg119 (dar): undefined
@@ -2447,9 +2447,9 @@ dwarf_cfi_addrframe (.eh_frame): no matching address range
privileged reg111 (spr11): undefined
privileged reg112 (spr12): undefined
privileged reg113 (spr13): undefined
- privileged reg114 (spr14): undefined
- privileged reg115 (spr15): undefined
- privileged reg116 (spr16): undefined
+ privileged reg114 (tfhar): undefined
+ privileged reg115 (tfiar): undefined
+ privileged reg116 (texasr): undefined
privileged reg117 (spr17): undefined
privileged reg118 (dsisr): undefined
privileged reg119 (dar): undefined
diff --git a/tests/run-allregs.sh b/tests/run-allregs.sh
index a56e6126..0d2eb524 100755
--- a/tests/run-allregs.sh
+++ b/tests/run-allregs.sh
@@ -253,9 +253,9 @@ privileged registers:
111: spr11 (spr11), unsigned 32 bits
112: spr12 (spr12), unsigned 32 bits
113: spr13 (spr13), unsigned 32 bits
- 114: spr14 (spr14), unsigned 32 bits
- 115: spr15 (spr15), unsigned 32 bits
- 116: spr16 (spr16), unsigned 32 bits
+ 114: tfhar (tfhar), unsigned 32 bits
+ 115: tfiar (tfiar), unsigned 32 bits
+ 116: texasr (texasr), unsigned 32 bits
117: spr17 (spr17), unsigned 32 bits
118: dsisr (dsisr), unsigned 32 bits
119: dar (dar), unsigned 32 bits
@@ -1276,9 +1276,9 @@ privileged registers:
111: spr11 (spr11), unsigned 64 bits
112: spr12 (spr12), unsigned 64 bits
113: spr13 (spr13), unsigned 64 bits
- 114: spr14 (spr14), unsigned 64 bits
- 115: spr15 (spr15), unsigned 64 bits
- 116: spr16 (spr16), unsigned 64 bits
+ 114: tfhar (tfhar), unsigned 64 bits
+ 115: tfiar (tfiar), unsigned 64 bits
+ 116: texasr (texasr), unsigned 64 bits
117: spr17 (spr17), unsigned 64 bits
118: dsisr (dsisr), unsigned 64 bits
119: dar (dar), unsigned 64 bits
diff --git a/tests/run-backtrace-fp-core-ppc64le.sh b/tests/run-backtrace-fp-core-ppc64le.sh
new file mode 100755
index 00000000..326ca342
--- /dev/null
+++ b/tests/run-backtrace-fp-core-ppc64le.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.ppc64le.fp.exec -I. -Ilib \
+# tests/backtrace-child.c
+#
+# The core is generated by calling tests/backtrace.ppc64le.fp.exec --gencore
+
+check_core ppc64le.fp
diff --git a/tests/run-strip-g.sh b/tests/run-strip-g.sh
new file mode 100755
index 00000000..8024aa52
--- /dev/null
+++ b/tests/run-strip-g.sh
@@ -0,0 +1,77 @@
+#! /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
+
+# When stripping just the debug sections/symbols we keep the symtab
+# in the main ELF file. There should be no symbols pointing into the
+# debug sections and so there should not be a copy in the debug file
+# except for a NOBITS one.
+
+tempfiles a.out strip.out debug.out readelf.out
+
+echo Create debug a.out.
+echo "int main() { return 1; }" | gcc -g -xc -
+
+echo strip -g to file with debug file
+testrun ${abs_top_builddir}/src/strip -g -o strip.out -f debug.out ||
+ { echo "*** failed to strip -g -o strip.out -f debug.out a.out"; exit -1; }
+
+status=0
+testrun ${abs_top_builddir}/src/readelf -S strip.out > readelf.out
+grep SYMTAB readelf.out || status=$?
+echo $status
+if test $status -ne 0; then
+ echo no symtab found in strip.out
+ exit 1
+fi
+
+status=0
+testrun ${abs_top_builddir}/src/readelf -S debug.out > readelf.out
+grep SYMTAB readelf.out || status=$?
+echo $status
+if test $status -ne 1; then
+ echo symtab found in debug.out
+ exit 1
+fi
+
+# aarch64 (with data marker in .debug_frame). See tests/run-addrcfi.sh
+testfiles testfileaarch64
+
+echo aarch64 strip -g to file with debug file
+testrun ${abs_top_builddir}/src/strip -g -o strip.out -f debug.out testfileaarch64 ||
+ { echo "*** failed to strip -g -o strip.out -f debug.out a.out"; exit -1; }
+
+status=0
+testrun ${abs_top_builddir}/src/readelf -S strip.out > readelf.out
+grep SYMTAB readelf.out || status=$?
+echo $status
+if test $status -ne 0; then
+ echo no symtab found in strip.out
+ exit 1
+fi
+
+status=0
+testrun ${abs_top_builddir}/src/readelf -S debug.out > readelf.out
+grep SYMTAB readelf.out || status=$?
+echo $status
+if test $status -ne 1; then
+ echo symtab found in debug.out
+ exit 1
+fi
+
+exit 0
diff --git a/tests/run-strip-nothing.sh b/tests/run-strip-nothing.sh
new file mode 100755
index 00000000..e80bd906
--- /dev/null
+++ b/tests/run-strip-nothing.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
+
+# If there is nothing to strip then -o output should be identical to input.
+# And there should not be an (empty) -f debug file.
+
+tempfiles a.out strip.out debug.out
+
+# Create no-debug a.out.
+echo "int main() { return 1; }" | gcc -xc -
+
+# strip to file
+testrun ${abs_top_builddir}/src/strip -g -o strip.out ||
+ { echo "*** failed to strip -g -o strip.out a.out"; exit -1; }
+
+testrun ${abs_top_builddir}/src/elfcmp a.out strip.out ||
+ { echo "*** failed strip.out different from a.out"; exit -1; }
+
+# strip original
+testrun ${abs_top_builddir}/src/strip -g ||
+ { echo "*** failed to strip -g a.out"; exit -1; }
+
+testrun ${abs_top_builddir}/src/elfcmp strip.out a.out ||
+ { echo "*** failed a.out different from strip.out"; exit -1; }
+
+# strip to file with debug file
+testrun ${abs_top_builddir}/src/strip -g -o strip.out -f debug.out ||
+ { echo "*** failed to strip -g -o strip.out -f debug.out a.out"; exit -1; }
+
+testrun ${abs_top_builddir}/src/elfcmp a.out strip.out ||
+ { echo "*** failed strip.out different from a.out (with debug)"; exit -1; }
+
+test ! -f debug.out ||
+ { echo "*** failed strip.out and debug.out exist"; exit -1; }
+
+# strip original with debug file
+testrun ${abs_top_builddir}/src/strip -g -f debug.out ||
+ { echo "*** failed to strip -g -f debug.out a.out"; exit -1; }
+
+testrun ${abs_top_builddir}/src/elfcmp strip.out a.out ||
+ { echo "*** failed a.out different from strip.out (with debug)"; exit -1; }
+
+test ! -f debug.out ||
+ { echo "*** failed a.out and debug.out exist"; exit -1; }
+
+exit 0
diff --git a/tests/run-strip-remove-keep.sh b/tests/run-strip-remove-keep.sh
new file mode 100755
index 00000000..92647fa7
--- /dev/null
+++ b/tests/run-strip-remove-keep.sh
@@ -0,0 +1,688 @@
+#! /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
+
+# strip -o output and -f debug files
+tempfiles testfile.elf testfile.debug
+
+# A random 32bit testfile
+testfiles testfile
+
+# Explicitly keep .strtab (but not .symtab, so .strtab will be in both). 32bit
+echo strip --keep-section=.strtab testfile
+testrun ${abs_top_builddir}/src/strip --keep-section=.strtab -o testfile.elf -f testfile.debug testfile
+echo elflint testfile.elf
+testrun ${abs_top_builddir}/src/elflint --gnu testfile.elf
+echo elflint testfile.debug
+testrun ${abs_top_builddir}/src/elflint --gnu -d testfile.debug
+echo readelf testfile.elf
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.elf <<\EOF
+There are 27 section headers, starting at offset 0xaf8:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 00000000 000000 000000 0 0 0 0
+[ 1] .interp PROGBITS 080480f4 0000f4 000013 0 A 0 0 1
+[ 2] .note.ABI-tag NOTE 08048108 000108 000020 0 A 0 0 4
+[ 3] .hash HASH 08048128 000128 000030 4 A 4 0 4
+[ 4] .dynsym DYNSYM 08048158 000158 000070 16 A 5 1 4
+[ 5] .dynstr STRTAB 080481c8 0001c8 00008e 0 A 0 0 1
+[ 6] .gnu.version GNU_versym 08048256 000256 00000e 2 A 4 0 2
+[ 7] .gnu.version_r GNU_verneed 08048264 000264 000030 0 A 5 1 4
+[ 8] .rel.got REL 08048294 000294 000008 8 A 4 19 4
+[ 9] .rel.plt REL 0804829c 00029c 000020 8 A 4 11 4
+[10] .init PROGBITS 080482bc 0002bc 000018 0 AX 0 0 4
+[11] .plt PROGBITS 080482d4 0002d4 000050 4 AX 0 0 4
+[12] .text PROGBITS 08048330 000330 00018c 0 AX 0 0 16
+[13] .fini PROGBITS 080484bc 0004bc 00001e 0 AX 0 0 4
+[14] .rodata PROGBITS 080484dc 0004dc 000008 0 A 0 0 4
+[15] .data PROGBITS 080494e4 0004e4 000010 0 WA 0 0 4
+[16] .eh_frame PROGBITS 080494f4 0004f4 000004 0 WA 0 0 4
+[17] .ctors PROGBITS 080494f8 0004f8 000008 0 WA 0 0 4
+[18] .dtors PROGBITS 08049500 000500 000008 0 WA 0 0 4
+[19] .got PROGBITS 08049508 000508 000020 4 WA 0 0 4
+[20] .dynamic DYNAMIC 08049528 000528 0000a0 8 WA 5 0 4
+[21] .bss NOBITS 080495c8 0005c8 00001c 0 WA 0 0 4
+[22] .comment PROGBITS 00000000 0005c8 000170 0 0 0 1
+[23] .note NOTE 00000000 000738 0000a0 0 0 0 1
+[24] .strtab STRTAB 00000000 0007d8 000235 0 0 0 1
+[25] .gnu_debuglink PROGBITS 00000000 000a10 000014 0 0 0 4
+[26] .shstrtab STRTAB 00000000 000a24 0000d1 0 0 0 1
+
+EOF
+echo readelf testfile.debug
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.debug <<\EOF
+There are 35 section headers, starting at offset 0x463c:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 00000000 000000 000000 0 0 0 0
+[ 1] .interp NOBITS 080480f4 0000f4 000013 0 A 0 0 1
+[ 2] .note.ABI-tag NOTE 08048108 0000f4 000020 0 A 0 0 4
+[ 3] .hash NOBITS 08048128 000114 000030 4 A 4 0 4
+[ 4] .dynsym NOBITS 08048158 000114 000070 16 A 5 1 4
+[ 5] .dynstr NOBITS 080481c8 000114 00008e 0 A 0 0 1
+[ 6] .gnu.version NOBITS 08048256 000114 00000e 2 A 4 0 2
+[ 7] .gnu.version_r NOBITS 08048264 000114 000030 0 A 5 1 4
+[ 8] .rel.got NOBITS 08048294 000114 000008 8 A 4 19 4
+[ 9] .rel.plt NOBITS 0804829c 000114 000020 8 A 4 11 4
+[10] .init NOBITS 080482bc 000114 000018 0 AX 0 0 4
+[11] .plt NOBITS 080482d4 000114 000050 4 AX 0 0 4
+[12] .text NOBITS 08048330 000120 00018c 0 AX 0 0 16
+[13] .fini NOBITS 080484bc 000120 00001e 0 AX 0 0 4
+[14] .rodata NOBITS 080484dc 000120 000008 0 A 0 0 4
+[15] .data NOBITS 080494e4 000120 000010 0 WA 0 0 4
+[16] .eh_frame NOBITS 080494f4 000120 000004 0 WA 0 0 4
+[17] .ctors NOBITS 080494f8 000120 000008 0 WA 0 0 4
+[18] .dtors NOBITS 08049500 000120 000008 0 WA 0 0 4
+[19] .got NOBITS 08049508 000120 000020 4 WA 0 0 4
+[20] .dynamic NOBITS 08049528 000120 0000a0 8 WA 5 0 4
+[21] .sbss PROGBITS 080495c8 000120 000000 0 W 0 0 1
+[22] .bss NOBITS 080495c8 000120 00001c 0 WA 0 0 4
+[23] .stab PROGBITS 00000000 000120 000720 12 24 0 4
+[24] .stabstr STRTAB 00000000 000840 001934 0 0 0 1
+[25] .comment NOBITS 00000000 002174 000170 0 0 0 1
+[26] .debug_aranges PROGBITS 00000000 002174 000060 0 0 0 1
+[27] .debug_pubnames PROGBITS 00000000 0021d4 000055 0 0 0 1
+[28] .debug_info PROGBITS 00000000 002229 001678 0 0 0 1
+[29] .debug_abbrev PROGBITS 00000000 0038a1 0001d2 0 0 0 1
+[30] .debug_line PROGBITS 00000000 003a73 000223 0 0 0 1
+[31] .note NOTE 00000000 003c96 0000a0 0 0 0 1
+[32] .shstrtab STRTAB 00000000 003d36 00012e 0 0 0 1
+[33] .symtab SYMTAB 00000000 003e64 0005a0 16 34 68 4
+[34] .strtab STRTAB 00000000 004404 000235 0 0 0 1
+
+EOF
+
+# Explicitly keep .symtab (pulls in .strtab, so they will both be in elf). 32bit
+echo strip --keep-section=.symtab testfile
+testrun ${abs_top_builddir}/src/strip --keep-section=.symtab -o testfile.elf -f testfile.debug testfile
+echo elflint testfile.elf
+testrun ${abs_top_builddir}/src/elflint --gnu testfile.elf
+echo elflint testfile.debug
+testrun ${abs_top_builddir}/src/elflint --gnu -d testfile.debug
+echo readelf testfile.elf
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.elf <<\EOF
+There are 28 section headers, starting at offset 0x1010:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 00000000 000000 000000 0 0 0 0
+[ 1] .interp PROGBITS 080480f4 0000f4 000013 0 A 0 0 1
+[ 2] .note.ABI-tag NOTE 08048108 000108 000020 0 A 0 0 4
+[ 3] .hash HASH 08048128 000128 000030 4 A 4 0 4
+[ 4] .dynsym DYNSYM 08048158 000158 000070 16 A 5 1 4
+[ 5] .dynstr STRTAB 080481c8 0001c8 00008e 0 A 0 0 1
+[ 6] .gnu.version GNU_versym 08048256 000256 00000e 2 A 4 0 2
+[ 7] .gnu.version_r GNU_verneed 08048264 000264 000030 0 A 5 1 4
+[ 8] .rel.got REL 08048294 000294 000008 8 A 4 19 4
+[ 9] .rel.plt REL 0804829c 00029c 000020 8 A 4 11 4
+[10] .init PROGBITS 080482bc 0002bc 000018 0 AX 0 0 4
+[11] .plt PROGBITS 080482d4 0002d4 000050 4 AX 0 0 4
+[12] .text PROGBITS 08048330 000330 00018c 0 AX 0 0 16
+[13] .fini PROGBITS 080484bc 0004bc 00001e 0 AX 0 0 4
+[14] .rodata PROGBITS 080484dc 0004dc 000008 0 A 0 0 4
+[15] .data PROGBITS 080494e4 0004e4 000010 0 WA 0 0 4
+[16] .eh_frame PROGBITS 080494f4 0004f4 000004 0 WA 0 0 4
+[17] .ctors PROGBITS 080494f8 0004f8 000008 0 WA 0 0 4
+[18] .dtors PROGBITS 08049500 000500 000008 0 WA 0 0 4
+[19] .got PROGBITS 08049508 000508 000020 4 WA 0 0 4
+[20] .dynamic DYNAMIC 08049528 000528 0000a0 8 WA 5 0 4
+[21] .bss NOBITS 080495c8 0005c8 00001c 0 WA 0 0 4
+[22] .comment PROGBITS 00000000 0005c8 000170 0 0 0 1
+[23] .note NOTE 00000000 000738 0000a0 0 0 0 1
+[24] .symtab SYMTAB 00000000 0007d8 000510 16 25 59 4
+[25] .strtab STRTAB 00000000 000ce8 000235 0 0 0 1
+[26] .gnu_debuglink PROGBITS 00000000 000f20 000014 0 0 0 4
+[27] .shstrtab STRTAB 00000000 000f34 0000d9 0 0 0 1
+
+EOF
+echo readelf testfile.debug
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.debug <<\EOF
+There are 35 section headers, starting at offset 0x3e64:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 00000000 000000 000000 0 0 0 0
+[ 1] .interp NOBITS 080480f4 0000f4 000013 0 A 0 0 1
+[ 2] .note.ABI-tag NOTE 08048108 0000f4 000020 0 A 0 0 4
+[ 3] .hash NOBITS 08048128 000114 000030 4 A 4 0 4
+[ 4] .dynsym NOBITS 08048158 000114 000070 16 A 5 1 4
+[ 5] .dynstr NOBITS 080481c8 000114 00008e 0 A 0 0 1
+[ 6] .gnu.version NOBITS 08048256 000114 00000e 2 A 4 0 2
+[ 7] .gnu.version_r NOBITS 08048264 000114 000030 0 A 5 1 4
+[ 8] .rel.got NOBITS 08048294 000114 000008 8 A 4 19 4
+[ 9] .rel.plt NOBITS 0804829c 000114 000020 8 A 4 11 4
+[10] .init NOBITS 080482bc 000114 000018 0 AX 0 0 4
+[11] .plt NOBITS 080482d4 000114 000050 4 AX 0 0 4
+[12] .text NOBITS 08048330 000120 00018c 0 AX 0 0 16
+[13] .fini NOBITS 080484bc 000120 00001e 0 AX 0 0 4
+[14] .rodata NOBITS 080484dc 000120 000008 0 A 0 0 4
+[15] .data NOBITS 080494e4 000120 000010 0 WA 0 0 4
+[16] .eh_frame NOBITS 080494f4 000120 000004 0 WA 0 0 4
+[17] .ctors NOBITS 080494f8 000120 000008 0 WA 0 0 4
+[18] .dtors NOBITS 08049500 000120 000008 0 WA 0 0 4
+[19] .got NOBITS 08049508 000120 000020 4 WA 0 0 4
+[20] .dynamic NOBITS 08049528 000120 0000a0 8 WA 5 0 4
+[21] .sbss PROGBITS 080495c8 000120 000000 0 W 0 0 1
+[22] .bss NOBITS 080495c8 000120 00001c 0 WA 0 0 4
+[23] .stab PROGBITS 00000000 000120 000720 12 24 0 4
+[24] .stabstr STRTAB 00000000 000840 001934 0 0 0 1
+[25] .comment NOBITS 00000000 002174 000170 0 0 0 1
+[26] .debug_aranges PROGBITS 00000000 002174 000060 0 0 0 1
+[27] .debug_pubnames PROGBITS 00000000 0021d4 000055 0 0 0 1
+[28] .debug_info PROGBITS 00000000 002229 001678 0 0 0 1
+[29] .debug_abbrev PROGBITS 00000000 0038a1 0001d2 0 0 0 1
+[30] .debug_line PROGBITS 00000000 003a73 000223 0 0 0 1
+[31] .note NOTE 00000000 003c96 0000a0 0 0 0 1
+[32] .shstrtab STRTAB 00000000 003d36 00012e 0 0 0 1
+[33] .symtab NOBITS 00000000 003e64 0005a0 16 34 68 4
+[34] .strtab NOBITS 00000000 003e64 000235 0 0 0 1
+
+EOF
+
+# A random 64bit testfile
+testfiles testfile69.so
+# Explicitly keep .strtab (but not .symtab, so .strtab will be in both). 64bit
+echo strip --keep-section=.strtab testfile69.so
+testrun ${abs_top_builddir}/src/strip --keep-section=.strtab -o testfile.elf -f testfile.debug testfile69.so
+echo elflint testfile.elf
+testrun ${abs_top_builddir}/src/elflint --gnu testfile.elf
+echo elflint testfile.debug
+testrun ${abs_top_builddir}/src/elflint --gnu -d testfile.debug
+echo readelf testfile.elf
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.elf <<\EOF
+There are 27 section headers, starting at offset 0xad8:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 0000000000000000 00000000 00000000 0 0 0 0
+[ 1] .note.gnu.build-id NOTE 0000000000000190 00000190 00000024 0 A 0 0 4
+[ 2] .gnu.hash GNU_HASH 00000000000001b8 000001b8 0000003c 0 A 3 0 8
+[ 3] .dynsym DYNSYM 00000000000001f8 000001f8 00000108 24 A 4 2 8
+[ 4] .dynstr STRTAB 0000000000000300 00000300 00000077 0 A 0 0 1
+[ 5] .gnu.version GNU_versym 0000000000000378 00000378 00000016 2 A 3 0 2
+[ 6] .gnu.version_r GNU_verneed 0000000000000390 00000390 00000020 0 A 4 1 8
+[ 7] .rela.dyn RELA 00000000000003b0 000003b0 00000060 24 A 3 0 8
+[ 8] .rela.plt RELA 0000000000000410 00000410 00000018 24 A 3 10 8
+[ 9] .init PROGBITS 0000000000000428 00000428 00000018 0 AX 0 0 4
+[10] .plt PROGBITS 0000000000000440 00000440 00000020 16 AX 0 0 16
+[11] .text PROGBITS 0000000000000460 00000460 00000128 0 AX 0 0 16
+[12] .fini PROGBITS 0000000000000588 00000588 0000000e 0 AX 0 0 4
+[13] .eh_frame_hdr PROGBITS 0000000000000598 00000598 00000024 0 A 0 0 4
+[14] .eh_frame PROGBITS 00000000000005c0 000005c0 00000084 0 A 0 0 8
+[15] .ctors PROGBITS 0000000000200648 00000648 00000010 0 WA 0 0 8
+[16] .dtors PROGBITS 0000000000200658 00000658 00000010 0 WA 0 0 8
+[17] .jcr PROGBITS 0000000000200668 00000668 00000008 0 WA 0 0 8
+[18] .data.rel.ro PROGBITS 0000000000200670 00000670 00000008 0 WA 0 0 8
+[19] .dynamic DYNAMIC 0000000000200678 00000678 00000180 16 WA 4 0 8
+[20] .got PROGBITS 00000000002007f8 000007f8 00000018 8 WA 0 0 8
+[21] .got.plt PROGBITS 0000000000200810 00000810 00000020 8 WA 0 0 8
+[22] .bss NOBITS 0000000000200830 00000830 00000010 0 WA 0 0 8
+[23] .comment PROGBITS 0000000000000000 00000830 0000002c 1 MS 0 0 1
+[24] .strtab STRTAB 0000000000000000 0000085c 00000175 0 0 0 1
+[25] .gnu_debuglink PROGBITS 0000000000000000 000009d4 00000014 0 0 0 4
+[26] .shstrtab STRTAB 0000000000000000 000009e8 000000ee 0 0 0 1
+
+EOF
+echo readelf testfile.debug
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.debug <<\EOF
+There are 27 section headers, starting at offset 0x918:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 0000000000000000 00000000 00000000 0 0 0 0
+[ 1] .note.gnu.build-id NOTE 0000000000000190 00000190 00000024 0 A 0 0 4
+[ 2] .gnu.hash NOBITS 00000000000001b8 000001b8 0000003c 0 A 3 0 8
+[ 3] .dynsym NOBITS 00000000000001f8 000001b8 00000108 24 A 4 2 8
+[ 4] .dynstr NOBITS 0000000000000300 000001b8 00000077 0 A 0 0 1
+[ 5] .gnu.version NOBITS 0000000000000378 000001b8 00000016 2 A 3 0 2
+[ 6] .gnu.version_r NOBITS 0000000000000390 000001b8 00000020 0 A 4 1 8
+[ 7] .rela.dyn NOBITS 00000000000003b0 000001b8 00000060 24 A 3 0 8
+[ 8] .rela.plt NOBITS 0000000000000410 000001b8 00000018 24 A 3 10 8
+[ 9] .init NOBITS 0000000000000428 000001b8 00000018 0 AX 0 0 4
+[10] .plt NOBITS 0000000000000440 000001c0 00000020 16 AX 0 0 16
+[11] .text NOBITS 0000000000000460 000001c0 00000128 0 AX 0 0 16
+[12] .fini NOBITS 0000000000000588 000001c0 0000000e 0 AX 0 0 4
+[13] .eh_frame_hdr NOBITS 0000000000000598 000001c0 00000024 0 A 0 0 4
+[14] .eh_frame NOBITS 00000000000005c0 000001c0 00000084 0 A 0 0 8
+[15] .ctors NOBITS 0000000000200648 000001c0 00000010 0 WA 0 0 8
+[16] .dtors NOBITS 0000000000200658 000001c0 00000010 0 WA 0 0 8
+[17] .jcr NOBITS 0000000000200668 000001c0 00000008 0 WA 0 0 8
+[18] .data.rel.ro NOBITS 0000000000200670 000001c0 00000008 0 WA 0 0 8
+[19] .dynamic NOBITS 0000000000200678 000001c0 00000180 16 WA 4 0 8
+[20] .got NOBITS 00000000002007f8 000001c0 00000018 8 WA 0 0 8
+[21] .got.plt NOBITS 0000000000200810 000001c0 00000020 8 WA 0 0 8
+[22] .bss NOBITS 0000000000200830 000001c0 00000010 0 WA 0 0 8
+[23] .comment NOBITS 0000000000000000 000001c0 0000002c 1 MS 0 0 1
+[24] .shstrtab STRTAB 0000000000000000 000001c0 000000e7 0 0 0 1
+[25] .symtab SYMTAB 0000000000000000 000002a8 000004f8 24 26 44 8
+[26] .strtab STRTAB 0000000000000000 000007a0 00000175 0 0 0 1
+
+EOF
+
+# Explicitly keep .symtab (pulls in .strtab, so they will both be in elf). 64bit
+# Use --remove-comment to make sure testfile.debug isn't empty.
+echo strip --keep-section=.symtab --remove-comment testfile69.so
+testrun ${abs_top_builddir}/src/strip --keep-section=.symtab --remove-comment -o testfile.elf -f testfile.debug testfile69.so
+echo elflint testfile.elf
+testrun ${abs_top_builddir}/src/elflint --gnu testfile.elf
+echo elflint testfile.debug
+testrun ${abs_top_builddir}/src/elflint --gnu -d testfile.debug
+echo readelf testfile.elf
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.elf <<\EOF
+There are 27 section headers, starting at offset 0xf90:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 0000000000000000 00000000 00000000 0 0 0 0
+[ 1] .note.gnu.build-id NOTE 0000000000000190 00000190 00000024 0 A 0 0 4
+[ 2] .gnu.hash GNU_HASH 00000000000001b8 000001b8 0000003c 0 A 3 0 8
+[ 3] .dynsym DYNSYM 00000000000001f8 000001f8 00000108 24 A 4 2 8
+[ 4] .dynstr STRTAB 0000000000000300 00000300 00000077 0 A 0 0 1
+[ 5] .gnu.version GNU_versym 0000000000000378 00000378 00000016 2 A 3 0 2
+[ 6] .gnu.version_r GNU_verneed 0000000000000390 00000390 00000020 0 A 4 1 8
+[ 7] .rela.dyn RELA 00000000000003b0 000003b0 00000060 24 A 3 0 8
+[ 8] .rela.plt RELA 0000000000000410 00000410 00000018 24 A 3 10 8
+[ 9] .init PROGBITS 0000000000000428 00000428 00000018 0 AX 0 0 4
+[10] .plt PROGBITS 0000000000000440 00000440 00000020 16 AX 0 0 16
+[11] .text PROGBITS 0000000000000460 00000460 00000128 0 AX 0 0 16
+[12] .fini PROGBITS 0000000000000588 00000588 0000000e 0 AX 0 0 4
+[13] .eh_frame_hdr PROGBITS 0000000000000598 00000598 00000024 0 A 0 0 4
+[14] .eh_frame PROGBITS 00000000000005c0 000005c0 00000084 0 A 0 0 8
+[15] .ctors PROGBITS 0000000000200648 00000648 00000010 0 WA 0 0 8
+[16] .dtors PROGBITS 0000000000200658 00000658 00000010 0 WA 0 0 8
+[17] .jcr PROGBITS 0000000000200668 00000668 00000008 0 WA 0 0 8
+[18] .data.rel.ro PROGBITS 0000000000200670 00000670 00000008 0 WA 0 0 8
+[19] .dynamic DYNAMIC 0000000000200678 00000678 00000180 16 WA 4 0 8
+[20] .got PROGBITS 00000000002007f8 000007f8 00000018 8 WA 0 0 8
+[21] .got.plt PROGBITS 0000000000200810 00000810 00000020 8 WA 0 0 8
+[22] .bss NOBITS 0000000000200830 00000830 00000010 0 WA 0 0 8
+[23] .symtab SYMTAB 0000000000000000 00000830 000004e0 24 24 43 8
+[24] .strtab STRTAB 0000000000000000 00000d10 00000175 0 0 0 1
+[25] .gnu_debuglink PROGBITS 0000000000000000 00000e88 00000014 0 0 0 4
+[26] .shstrtab STRTAB 0000000000000000 00000e9c 000000ed 0 0 0 1
+
+EOF
+echo readelf testfile.debug
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.debug <<\EOF
+There are 27 section headers, starting at offset 0x2d8:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 0000000000000000 00000000 00000000 0 0 0 0
+[ 1] .note.gnu.build-id NOTE 0000000000000190 00000190 00000024 0 A 0 0 4
+[ 2] .gnu.hash NOBITS 00000000000001b8 000001b8 0000003c 0 A 3 0 8
+[ 3] .dynsym NOBITS 00000000000001f8 000001b8 00000108 24 A 4 2 8
+[ 4] .dynstr NOBITS 0000000000000300 000001b8 00000077 0 A 0 0 1
+[ 5] .gnu.version NOBITS 0000000000000378 000001b8 00000016 2 A 3 0 2
+[ 6] .gnu.version_r NOBITS 0000000000000390 000001b8 00000020 0 A 4 1 8
+[ 7] .rela.dyn NOBITS 00000000000003b0 000001b8 00000060 24 A 3 0 8
+[ 8] .rela.plt NOBITS 0000000000000410 000001b8 00000018 24 A 3 10 8
+[ 9] .init NOBITS 0000000000000428 000001b8 00000018 0 AX 0 0 4
+[10] .plt NOBITS 0000000000000440 000001c0 00000020 16 AX 0 0 16
+[11] .text NOBITS 0000000000000460 000001c0 00000128 0 AX 0 0 16
+[12] .fini NOBITS 0000000000000588 000001c0 0000000e 0 AX 0 0 4
+[13] .eh_frame_hdr NOBITS 0000000000000598 000001c0 00000024 0 A 0 0 4
+[14] .eh_frame NOBITS 00000000000005c0 000001c0 00000084 0 A 0 0 8
+[15] .ctors NOBITS 0000000000200648 000001c0 00000010 0 WA 0 0 8
+[16] .dtors NOBITS 0000000000200658 000001c0 00000010 0 WA 0 0 8
+[17] .jcr NOBITS 0000000000200668 000001c0 00000008 0 WA 0 0 8
+[18] .data.rel.ro NOBITS 0000000000200670 000001c0 00000008 0 WA 0 0 8
+[19] .dynamic NOBITS 0000000000200678 000001c0 00000180 16 WA 4 0 8
+[20] .got NOBITS 00000000002007f8 000001c0 00000018 8 WA 0 0 8
+[21] .got.plt NOBITS 0000000000200810 000001c0 00000020 8 WA 0 0 8
+[22] .bss NOBITS 0000000000200830 000001c0 00000010 0 WA 0 0 8
+[23] .comment PROGBITS 0000000000000000 000001c0 0000002c 1 MS 0 0 1
+[24] .shstrtab STRTAB 0000000000000000 000001ec 000000e7 0 0 0 1
+[25] .symtab NOBITS 0000000000000000 000002d8 000004f8 24 26 44 8
+[26] .strtab NOBITS 0000000000000000 000002d8 00000175 0 0 0 1
+
+EOF
+
+# Explicitly remove .symtab (but not .strtab, so it will be in both). 32bit
+echo strip -g --remove-section=.symtab testfile
+testrun ${abs_top_builddir}/src/strip -g --remove-section=.symtab -o testfile.elf -f testfile.debug testfile
+echo elflint testfile.elf
+testrun ${abs_top_builddir}/src/elflint --gnu testfile.elf
+echo elflint testfile.debug
+testrun ${abs_top_builddir}/src/elflint --gnu -d testfile.debug
+echo readelf testfile.elf
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.elf <<\EOF
+There are 28 section headers, starting at offset 0xafc:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 00000000 000000 000000 0 0 0 0
+[ 1] .interp PROGBITS 080480f4 0000f4 000013 0 A 0 0 1
+[ 2] .note.ABI-tag NOTE 08048108 000108 000020 0 A 0 0 4
+[ 3] .hash HASH 08048128 000128 000030 4 A 4 0 4
+[ 4] .dynsym DYNSYM 08048158 000158 000070 16 A 5 1 4
+[ 5] .dynstr STRTAB 080481c8 0001c8 00008e 0 A 0 0 1
+[ 6] .gnu.version GNU_versym 08048256 000256 00000e 2 A 4 0 2
+[ 7] .gnu.version_r GNU_verneed 08048264 000264 000030 0 A 5 1 4
+[ 8] .rel.got REL 08048294 000294 000008 8 A 4 19 4
+[ 9] .rel.plt REL 0804829c 00029c 000020 8 A 4 11 4
+[10] .init PROGBITS 080482bc 0002bc 000018 0 AX 0 0 4
+[11] .plt PROGBITS 080482d4 0002d4 000050 4 AX 0 0 4
+[12] .text PROGBITS 08048330 000330 00018c 0 AX 0 0 16
+[13] .fini PROGBITS 080484bc 0004bc 00001e 0 AX 0 0 4
+[14] .rodata PROGBITS 080484dc 0004dc 000008 0 A 0 0 4
+[15] .data PROGBITS 080494e4 0004e4 000010 0 WA 0 0 4
+[16] .eh_frame PROGBITS 080494f4 0004f4 000004 0 WA 0 0 4
+[17] .ctors PROGBITS 080494f8 0004f8 000008 0 WA 0 0 4
+[18] .dtors PROGBITS 08049500 000500 000008 0 WA 0 0 4
+[19] .got PROGBITS 08049508 000508 000020 4 WA 0 0 4
+[20] .dynamic DYNAMIC 08049528 000528 0000a0 8 WA 5 0 4
+[21] .sbss PROGBITS 080495c8 0005c8 000000 0 W 0 0 1
+[22] .bss NOBITS 080495c8 0005c8 00001c 0 WA 0 0 4
+[23] .comment PROGBITS 00000000 0005c8 000170 0 0 0 1
+[24] .note NOTE 00000000 000738 0000a0 0 0 0 1
+[25] .strtab STRTAB 00000000 0007d8 000235 0 0 0 1
+[26] .gnu_debuglink PROGBITS 00000000 000a10 000014 0 0 0 4
+[27] .shstrtab STRTAB 00000000 000a24 0000d7 0 0 0 1
+
+EOF
+echo readelf testfile.debug
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.debug <<\EOF
+There are 35 section headers, starting at offset 0x463c:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 00000000 000000 000000 0 0 0 0
+[ 1] .interp NOBITS 080480f4 0000f4 000013 0 A 0 0 1
+[ 2] .note.ABI-tag NOTE 08048108 0000f4 000020 0 A 0 0 4
+[ 3] .hash NOBITS 08048128 000114 000030 4 A 4 0 4
+[ 4] .dynsym NOBITS 08048158 000114 000070 16 A 5 1 4
+[ 5] .dynstr NOBITS 080481c8 000114 00008e 0 A 0 0 1
+[ 6] .gnu.version NOBITS 08048256 000114 00000e 2 A 4 0 2
+[ 7] .gnu.version_r NOBITS 08048264 000114 000030 0 A 5 1 4
+[ 8] .rel.got NOBITS 08048294 000114 000008 8 A 4 19 4
+[ 9] .rel.plt NOBITS 0804829c 000114 000020 8 A 4 11 4
+[10] .init NOBITS 080482bc 000114 000018 0 AX 0 0 4
+[11] .plt NOBITS 080482d4 000114 000050 4 AX 0 0 4
+[12] .text NOBITS 08048330 000120 00018c 0 AX 0 0 16
+[13] .fini NOBITS 080484bc 000120 00001e 0 AX 0 0 4
+[14] .rodata NOBITS 080484dc 000120 000008 0 A 0 0 4
+[15] .data NOBITS 080494e4 000120 000010 0 WA 0 0 4
+[16] .eh_frame NOBITS 080494f4 000120 000004 0 WA 0 0 4
+[17] .ctors NOBITS 080494f8 000120 000008 0 WA 0 0 4
+[18] .dtors NOBITS 08049500 000120 000008 0 WA 0 0 4
+[19] .got NOBITS 08049508 000120 000020 4 WA 0 0 4
+[20] .dynamic NOBITS 08049528 000120 0000a0 8 WA 5 0 4
+[21] .sbss NOBITS 080495c8 000120 000000 0 W 0 0 1
+[22] .bss NOBITS 080495c8 000120 00001c 0 WA 0 0 4
+[23] .stab PROGBITS 00000000 000120 000720 12 24 0 4
+[24] .stabstr STRTAB 00000000 000840 001934 0 0 0 1
+[25] .comment NOBITS 00000000 002174 000170 0 0 0 1
+[26] .debug_aranges PROGBITS 00000000 002174 000060 0 0 0 1
+[27] .debug_pubnames PROGBITS 00000000 0021d4 000055 0 0 0 1
+[28] .debug_info PROGBITS 00000000 002229 001678 0 0 0 1
+[29] .debug_abbrev PROGBITS 00000000 0038a1 0001d2 0 0 0 1
+[30] .debug_line PROGBITS 00000000 003a73 000223 0 0 0 1
+[31] .note NOTE 00000000 003c96 0000a0 0 0 0 1
+[32] .shstrtab STRTAB 00000000 003d36 00012e 0 0 0 1
+[33] .symtab SYMTAB 00000000 003e64 0005a0 16 34 68 4
+[34] .strtab STRTAB 00000000 004404 000235 0 0 0 1
+
+EOF
+
+# Explicitly remove both .symtab and .strtab. Keep .stab and .stabstr 32bit
+echo strip -g --remove-section=".s[yt][mr]tab" --keep-section=".stab*" testfile
+testrun ${abs_top_builddir}/src/strip -g --remove-section=".s[yt][mr]tab" --keep-section=".stab*" -o testfile.elf -f testfile.debug testfile
+echo elflint testfile.elf
+testrun ${abs_top_builddir}/src/elflint --gnu testfile.elf
+echo elflint testfile.debug
+testrun ${abs_top_builddir}/src/elflint --gnu -d testfile.debug
+echo readelf testfile.elf
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.elf <<\EOF
+There are 29 section headers, starting at offset 0x2920:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 00000000 000000 000000 0 0 0 0
+[ 1] .interp PROGBITS 080480f4 0000f4 000013 0 A 0 0 1
+[ 2] .note.ABI-tag NOTE 08048108 000108 000020 0 A 0 0 4
+[ 3] .hash HASH 08048128 000128 000030 4 A 4 0 4
+[ 4] .dynsym DYNSYM 08048158 000158 000070 16 A 5 1 4
+[ 5] .dynstr STRTAB 080481c8 0001c8 00008e 0 A 0 0 1
+[ 6] .gnu.version GNU_versym 08048256 000256 00000e 2 A 4 0 2
+[ 7] .gnu.version_r GNU_verneed 08048264 000264 000030 0 A 5 1 4
+[ 8] .rel.got REL 08048294 000294 000008 8 A 4 19 4
+[ 9] .rel.plt REL 0804829c 00029c 000020 8 A 4 11 4
+[10] .init PROGBITS 080482bc 0002bc 000018 0 AX 0 0 4
+[11] .plt PROGBITS 080482d4 0002d4 000050 4 AX 0 0 4
+[12] .text PROGBITS 08048330 000330 00018c 0 AX 0 0 16
+[13] .fini PROGBITS 080484bc 0004bc 00001e 0 AX 0 0 4
+[14] .rodata PROGBITS 080484dc 0004dc 000008 0 A 0 0 4
+[15] .data PROGBITS 080494e4 0004e4 000010 0 WA 0 0 4
+[16] .eh_frame PROGBITS 080494f4 0004f4 000004 0 WA 0 0 4
+[17] .ctors PROGBITS 080494f8 0004f8 000008 0 WA 0 0 4
+[18] .dtors PROGBITS 08049500 000500 000008 0 WA 0 0 4
+[19] .got PROGBITS 08049508 000508 000020 4 WA 0 0 4
+[20] .dynamic DYNAMIC 08049528 000528 0000a0 8 WA 5 0 4
+[21] .sbss PROGBITS 080495c8 0005c8 000000 0 W 0 0 1
+[22] .bss NOBITS 080495c8 0005c8 00001c 0 WA 0 0 4
+[23] .stab PROGBITS 00000000 0005c8 000720 12 24 0 4
+[24] .stabstr STRTAB 00000000 000ce8 001934 0 0 0 1
+[25] .comment PROGBITS 00000000 00261c 000170 0 0 0 1
+[26] .note NOTE 00000000 00278c 0000a0 0 0 0 1
+[27] .gnu_debuglink PROGBITS 00000000 00282c 000014 0 0 0 4
+[28] .shstrtab STRTAB 00000000 002840 0000de 0 0 0 1
+
+EOF
+echo readelf testfile.debug
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.debug <<\EOF
+There are 35 section headers, starting at offset 0x25e8:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 00000000 000000 000000 0 0 0 0
+[ 1] .interp NOBITS 080480f4 0000f4 000013 0 A 0 0 1
+[ 2] .note.ABI-tag NOTE 08048108 0000f4 000020 0 A 0 0 4
+[ 3] .hash NOBITS 08048128 000114 000030 4 A 4 0 4
+[ 4] .dynsym NOBITS 08048158 000114 000070 16 A 5 1 4
+[ 5] .dynstr NOBITS 080481c8 000114 00008e 0 A 0 0 1
+[ 6] .gnu.version NOBITS 08048256 000114 00000e 2 A 4 0 2
+[ 7] .gnu.version_r NOBITS 08048264 000114 000030 0 A 5 1 4
+[ 8] .rel.got NOBITS 08048294 000114 000008 8 A 4 19 4
+[ 9] .rel.plt NOBITS 0804829c 000114 000020 8 A 4 11 4
+[10] .init NOBITS 080482bc 000114 000018 0 AX 0 0 4
+[11] .plt NOBITS 080482d4 000114 000050 4 AX 0 0 4
+[12] .text NOBITS 08048330 000120 00018c 0 AX 0 0 16
+[13] .fini NOBITS 080484bc 000120 00001e 0 AX 0 0 4
+[14] .rodata NOBITS 080484dc 000120 000008 0 A 0 0 4
+[15] .data NOBITS 080494e4 000120 000010 0 WA 0 0 4
+[16] .eh_frame NOBITS 080494f4 000120 000004 0 WA 0 0 4
+[17] .ctors NOBITS 080494f8 000120 000008 0 WA 0 0 4
+[18] .dtors NOBITS 08049500 000120 000008 0 WA 0 0 4
+[19] .got NOBITS 08049508 000120 000020 4 WA 0 0 4
+[20] .dynamic NOBITS 08049528 000120 0000a0 8 WA 5 0 4
+[21] .sbss NOBITS 080495c8 000120 000000 0 W 0 0 1
+[22] .bss NOBITS 080495c8 000120 00001c 0 WA 0 0 4
+[23] .stab NOBITS 00000000 000120 000720 12 24 0 4
+[24] .stabstr NOBITS 00000000 000120 001934 0 0 0 1
+[25] .comment NOBITS 00000000 000120 000170 0 0 0 1
+[26] .debug_aranges PROGBITS 00000000 000120 000060 0 0 0 1
+[27] .debug_pubnames PROGBITS 00000000 000180 000055 0 0 0 1
+[28] .debug_info PROGBITS 00000000 0001d5 001678 0 0 0 1
+[29] .debug_abbrev PROGBITS 00000000 00184d 0001d2 0 0 0 1
+[30] .debug_line PROGBITS 00000000 001a1f 000223 0 0 0 1
+[31] .note NOTE 00000000 001c42 0000a0 0 0 0 1
+[32] .shstrtab STRTAB 00000000 001ce2 00012e 0 0 0 1
+[33] .symtab SYMTAB 00000000 001e10 0005a0 16 34 68 4
+[34] .strtab STRTAB 00000000 0023b0 000235 0 0 0 1
+
+EOF
+
+# Explicitly remove .symtab (but not .strtab, so it will be in both). 64bit
+echo strip -g --remove-section=.symtab testfile69.so
+testrun ${abs_top_builddir}/src/strip -g --remove-section=.symtab -o testfile.elf -f testfile.debug testfile69.so
+echo elflint testfile.elf
+testrun ${abs_top_builddir}/src/elflint --gnu testfile.elf
+echo elflint testfile.debug
+testrun ${abs_top_builddir}/src/elflint --gnu -d testfile.debug
+echo readelf testfile.elf
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.elf <<\EOF
+There are 27 section headers, starting at offset 0xad8:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 0000000000000000 00000000 00000000 0 0 0 0
+[ 1] .note.gnu.build-id NOTE 0000000000000190 00000190 00000024 0 A 0 0 4
+[ 2] .gnu.hash GNU_HASH 00000000000001b8 000001b8 0000003c 0 A 3 0 8
+[ 3] .dynsym DYNSYM 00000000000001f8 000001f8 00000108 24 A 4 2 8
+[ 4] .dynstr STRTAB 0000000000000300 00000300 00000077 0 A 0 0 1
+[ 5] .gnu.version GNU_versym 0000000000000378 00000378 00000016 2 A 3 0 2
+[ 6] .gnu.version_r GNU_verneed 0000000000000390 00000390 00000020 0 A 4 1 8
+[ 7] .rela.dyn RELA 00000000000003b0 000003b0 00000060 24 A 3 0 8
+[ 8] .rela.plt RELA 0000000000000410 00000410 00000018 24 A 3 10 8
+[ 9] .init PROGBITS 0000000000000428 00000428 00000018 0 AX 0 0 4
+[10] .plt PROGBITS 0000000000000440 00000440 00000020 16 AX 0 0 16
+[11] .text PROGBITS 0000000000000460 00000460 00000128 0 AX 0 0 16
+[12] .fini PROGBITS 0000000000000588 00000588 0000000e 0 AX 0 0 4
+[13] .eh_frame_hdr PROGBITS 0000000000000598 00000598 00000024 0 A 0 0 4
+[14] .eh_frame PROGBITS 00000000000005c0 000005c0 00000084 0 A 0 0 8
+[15] .ctors PROGBITS 0000000000200648 00000648 00000010 0 WA 0 0 8
+[16] .dtors PROGBITS 0000000000200658 00000658 00000010 0 WA 0 0 8
+[17] .jcr PROGBITS 0000000000200668 00000668 00000008 0 WA 0 0 8
+[18] .data.rel.ro PROGBITS 0000000000200670 00000670 00000008 0 WA 0 0 8
+[19] .dynamic DYNAMIC 0000000000200678 00000678 00000180 16 WA 4 0 8
+[20] .got PROGBITS 00000000002007f8 000007f8 00000018 8 WA 0 0 8
+[21] .got.plt PROGBITS 0000000000200810 00000810 00000020 8 WA 0 0 8
+[22] .bss NOBITS 0000000000200830 00000830 00000010 0 WA 0 0 8
+[23] .comment PROGBITS 0000000000000000 00000830 0000002c 1 MS 0 0 1
+[24] .strtab STRTAB 0000000000000000 0000085c 00000175 0 0 0 1
+[25] .gnu_debuglink PROGBITS 0000000000000000 000009d4 00000014 0 0 0 4
+[26] .shstrtab STRTAB 0000000000000000 000009e8 000000ee 0 0 0 1
+
+EOF
+echo readelf testfile.debug
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.debug <<\EOF
+There are 27 section headers, starting at offset 0x918:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 0000000000000000 00000000 00000000 0 0 0 0
+[ 1] .note.gnu.build-id NOTE 0000000000000190 00000190 00000024 0 A 0 0 4
+[ 2] .gnu.hash NOBITS 00000000000001b8 000001b8 0000003c 0 A 3 0 8
+[ 3] .dynsym NOBITS 00000000000001f8 000001b8 00000108 24 A 4 2 8
+[ 4] .dynstr NOBITS 0000000000000300 000001b8 00000077 0 A 0 0 1
+[ 5] .gnu.version NOBITS 0000000000000378 000001b8 00000016 2 A 3 0 2
+[ 6] .gnu.version_r NOBITS 0000000000000390 000001b8 00000020 0 A 4 1 8
+[ 7] .rela.dyn NOBITS 00000000000003b0 000001b8 00000060 24 A 3 0 8
+[ 8] .rela.plt NOBITS 0000000000000410 000001b8 00000018 24 A 3 10 8
+[ 9] .init NOBITS 0000000000000428 000001b8 00000018 0 AX 0 0 4
+[10] .plt NOBITS 0000000000000440 000001c0 00000020 16 AX 0 0 16
+[11] .text NOBITS 0000000000000460 000001c0 00000128 0 AX 0 0 16
+[12] .fini NOBITS 0000000000000588 000001c0 0000000e 0 AX 0 0 4
+[13] .eh_frame_hdr NOBITS 0000000000000598 000001c0 00000024 0 A 0 0 4
+[14] .eh_frame NOBITS 00000000000005c0 000001c0 00000084 0 A 0 0 8
+[15] .ctors NOBITS 0000000000200648 000001c0 00000010 0 WA 0 0 8
+[16] .dtors NOBITS 0000000000200658 000001c0 00000010 0 WA 0 0 8
+[17] .jcr NOBITS 0000000000200668 000001c0 00000008 0 WA 0 0 8
+[18] .data.rel.ro NOBITS 0000000000200670 000001c0 00000008 0 WA 0 0 8
+[19] .dynamic NOBITS 0000000000200678 000001c0 00000180 16 WA 4 0 8
+[20] .got NOBITS 00000000002007f8 000001c0 00000018 8 WA 0 0 8
+[21] .got.plt NOBITS 0000000000200810 000001c0 00000020 8 WA 0 0 8
+[22] .bss NOBITS 0000000000200830 000001c0 00000010 0 WA 0 0 8
+[23] .comment NOBITS 0000000000000000 000001c0 0000002c 1 MS 0 0 1
+[24] .shstrtab STRTAB 0000000000000000 000001c0 000000e7 0 0 0 1
+[25] .symtab SYMTAB 0000000000000000 000002a8 000004f8 24 26 44 8
+[26] .strtab STRTAB 0000000000000000 000007a0 00000175 0 0 0 1
+
+EOF
+
+# Explicitly remove both .symtab and .strtab. Keep .comment section. 64bit
+echo strip -g --remove-section=".s[yt][mr]tab" --keep-section=.comment testfile69.so
+testrun ${abs_top_builddir}/src/strip -g --remove-section=".s[yt][mr]tab" --keep-section=.comment -o testfile.elf -f testfile.debug testfile69.so
+echo elflint testfile.elf
+testrun ${abs_top_builddir}/src/elflint --gnu testfile.elf
+echo elflint testfile.debug
+testrun ${abs_top_builddir}/src/elflint --gnu -d testfile.debug
+echo readelf testfile.elf
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.elf <<\EOF
+There are 26 section headers, starting at offset 0x958:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 0000000000000000 00000000 00000000 0 0 0 0
+[ 1] .note.gnu.build-id NOTE 0000000000000190 00000190 00000024 0 A 0 0 4
+[ 2] .gnu.hash GNU_HASH 00000000000001b8 000001b8 0000003c 0 A 3 0 8
+[ 3] .dynsym DYNSYM 00000000000001f8 000001f8 00000108 24 A 4 2 8
+[ 4] .dynstr STRTAB 0000000000000300 00000300 00000077 0 A 0 0 1
+[ 5] .gnu.version GNU_versym 0000000000000378 00000378 00000016 2 A 3 0 2
+[ 6] .gnu.version_r GNU_verneed 0000000000000390 00000390 00000020 0 A 4 1 8
+[ 7] .rela.dyn RELA 00000000000003b0 000003b0 00000060 24 A 3 0 8
+[ 8] .rela.plt RELA 0000000000000410 00000410 00000018 24 A 3 10 8
+[ 9] .init PROGBITS 0000000000000428 00000428 00000018 0 AX 0 0 4
+[10] .plt PROGBITS 0000000000000440 00000440 00000020 16 AX 0 0 16
+[11] .text PROGBITS 0000000000000460 00000460 00000128 0 AX 0 0 16
+[12] .fini PROGBITS 0000000000000588 00000588 0000000e 0 AX 0 0 4
+[13] .eh_frame_hdr PROGBITS 0000000000000598 00000598 00000024 0 A 0 0 4
+[14] .eh_frame PROGBITS 00000000000005c0 000005c0 00000084 0 A 0 0 8
+[15] .ctors PROGBITS 0000000000200648 00000648 00000010 0 WA 0 0 8
+[16] .dtors PROGBITS 0000000000200658 00000658 00000010 0 WA 0 0 8
+[17] .jcr PROGBITS 0000000000200668 00000668 00000008 0 WA 0 0 8
+[18] .data.rel.ro PROGBITS 0000000000200670 00000670 00000008 0 WA 0 0 8
+[19] .dynamic DYNAMIC 0000000000200678 00000678 00000180 16 WA 4 0 8
+[20] .got PROGBITS 00000000002007f8 000007f8 00000018 8 WA 0 0 8
+[21] .got.plt PROGBITS 0000000000200810 00000810 00000020 8 WA 0 0 8
+[22] .bss NOBITS 0000000000200830 00000830 00000010 0 WA 0 0 8
+[23] .comment PROGBITS 0000000000000000 00000830 0000002c 1 MS 0 0 1
+[24] .gnu_debuglink PROGBITS 0000000000000000 0000085c 00000014 0 0 0 4
+[25] .shstrtab STRTAB 0000000000000000 00000870 000000e6 0 0 0 1
+
+EOF
+echo readelf testfile.debug
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile.debug <<\EOF
+There are 27 section headers, starting at offset 0x918:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 0000000000000000 00000000 00000000 0 0 0 0
+[ 1] .note.gnu.build-id NOTE 0000000000000190 00000190 00000024 0 A 0 0 4
+[ 2] .gnu.hash NOBITS 00000000000001b8 000001b8 0000003c 0 A 3 0 8
+[ 3] .dynsym NOBITS 00000000000001f8 000001b8 00000108 24 A 4 2 8
+[ 4] .dynstr NOBITS 0000000000000300 000001b8 00000077 0 A 0 0 1
+[ 5] .gnu.version NOBITS 0000000000000378 000001b8 00000016 2 A 3 0 2
+[ 6] .gnu.version_r NOBITS 0000000000000390 000001b8 00000020 0 A 4 1 8
+[ 7] .rela.dyn NOBITS 00000000000003b0 000001b8 00000060 24 A 3 0 8
+[ 8] .rela.plt NOBITS 0000000000000410 000001b8 00000018 24 A 3 10 8
+[ 9] .init NOBITS 0000000000000428 000001b8 00000018 0 AX 0 0 4
+[10] .plt NOBITS 0000000000000440 000001c0 00000020 16 AX 0 0 16
+[11] .text NOBITS 0000000000000460 000001c0 00000128 0 AX 0 0 16
+[12] .fini NOBITS 0000000000000588 000001c0 0000000e 0 AX 0 0 4
+[13] .eh_frame_hdr NOBITS 0000000000000598 000001c0 00000024 0 A 0 0 4
+[14] .eh_frame NOBITS 00000000000005c0 000001c0 00000084 0 A 0 0 8
+[15] .ctors NOBITS 0000000000200648 000001c0 00000010 0 WA 0 0 8
+[16] .dtors NOBITS 0000000000200658 000001c0 00000010 0 WA 0 0 8
+[17] .jcr NOBITS 0000000000200668 000001c0 00000008 0 WA 0 0 8
+[18] .data.rel.ro NOBITS 0000000000200670 000001c0 00000008 0 WA 0 0 8
+[19] .dynamic NOBITS 0000000000200678 000001c0 00000180 16 WA 4 0 8
+[20] .got NOBITS 00000000002007f8 000001c0 00000018 8 WA 0 0 8
+[21] .got.plt NOBITS 0000000000200810 000001c0 00000020 8 WA 0 0 8
+[22] .bss NOBITS 0000000000200830 000001c0 00000010 0 WA 0 0 8
+[23] .comment NOBITS 0000000000000000 000001c0 0000002c 1 MS 0 0 1
+[24] .shstrtab STRTAB 0000000000000000 000001c0 000000e7 0 0 0 1
+[25] .symtab SYMTAB 0000000000000000 000002a8 000004f8 24 26 44 8
+[26] .strtab STRTAB 0000000000000000 000007a0 00000175 0 0 0 1
+
+EOF
+
+exit 0
diff --git a/tests/run-strip-test.sh b/tests/run-strip-test.sh
index 42aa9888..280814e6 100755
--- a/tests/run-strip-test.sh
+++ b/tests/run-strip-test.sh
@@ -49,6 +49,14 @@ testrun ${abs_top_builddir}/src/unstrip -o testfile.unstrip testfile.temp testfi
testrun ${abs_top_builddir}/src/elfcmp --hash-inexact $original testfile.unstrip
}
+# test strip -g
+testrun ${abs_top_builddir}/src/strip -g -o testfile.temp $original
+
+# Buggy eu-strip created multiple .shstrtab sections
+shstrtab_SECS=$(testrun ${abs_top_builddir}/src/readelf -S testfile.temp | grep '.shstrtab' | wc --lines)
+test $shstrtab_SECS -eq 1 ||
+ { echo "*** failure not just one '.shstrtab' testfile.temp ($shstrtab_SECS)"; status=1; }
+
# Now strip in-place and make sure it is smaller.
SIZE_original=$(stat -c%s $original)
testrun ${abs_top_builddir}/src/strip $original