diff options
| author | Mark Wielaard <[email protected]> | 2017-07-20 22:34:29 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2017-07-24 12:20:01 +0200 |
| commit | 55cb7dfa7e9afb3660b21e51434641c7287baf11 (patch) | |
| tree | 9fc5ed4d912e682084cf97dca3b655be0905b6c0 /tests | |
| parent | 1609679b1ef3611c71a08900c2f6b94bb97d454d (diff) | |
strip: Deal with ARM data marker symbols pointing to debug sections.
ARM data marker symbols "$d" indicate the start of a sequence of data
items in a section. For data only sections no data marker symbol is
necessary, but may be put pointing to the start of the section.
binutils however has a bug which places a data marker symbol somewhere
inside the section (at least for .debug_frame).
https://sourceware.org/bugzilla/show_bug.cgi?id=21809
When strip finds a symbol pointing to a debug section that would be
put into the .debug file then it will copy over the whole symbol table.
This isn't necessary because the symbol is redundant.
Add an ebl hook to recognize data marker symbols with implementations
for arm and aarch64. Use it in strip to strip such symbols from the
symbol table if they point to a debug section.
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ChangeLog | 6 | ||||
| -rw-r--r-- | tests/Makefile.am | 4 | ||||
| -rwxr-xr-x | tests/run-strip-g.sh | 102 |
3 files changed, 110 insertions, 2 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog index 194d019f..6c70d020 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +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. diff --git a/tests/Makefile.am b/tests/Makefile.am index 368e9263..407c0511 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -81,7 +81,7 @@ 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-test11.sh \ - run-strip-nothing.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-remove-keep.sh \ run-unstrip-test.sh run-unstrip-test2.sh run-unstrip-test3.sh \ @@ -173,7 +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-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 \ diff --git a/tests/run-strip-g.sh b/tests/run-strip-g.sh new file mode 100755 index 00000000..13038195 --- /dev/null +++ b/tests/run-strip-g.sh @@ -0,0 +1,102 @@ +#! /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 + +# arm (with data marker in .debug_frame). See tests/run-addrcfi.sh +testfiles testfilearm + +echo arm strip -g to file with debug file +testrun ${abs_top_builddir}/src/strip -g -o strip.out -f debug.out testfilearm || + { 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 |
