Brian Silverman | 8649792 | 2018-02-10 19:28:39 -0500 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | # Copyright (C) 2017 Red Hat, Inc. |
| 3 | # This file is part of elfutils. |
| 4 | # |
| 5 | # This file is free software; you can redistribute it and/or modify |
| 6 | # it under the terms of the GNU General Public License as published by |
| 7 | # the Free Software Foundation; either version 3 of the License, or |
| 8 | # (at your option) any later version. |
| 9 | # |
| 10 | # elfutils is distributed in the hope that it will be useful, but |
| 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | # GNU General Public License for more details. |
| 14 | # |
| 15 | # You should have received a copy of the GNU General Public License |
| 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | . $srcdir/test-subr.sh |
| 19 | |
| 20 | # When stripping just the debug sections/symbols we keep the symtab |
| 21 | # in the main ELF file. There should be no symbols pointing into the |
| 22 | # debug sections and so there should not be a copy in the debug file |
| 23 | # except for a NOBITS one. |
| 24 | |
| 25 | tempfiles a.out strip.out debug.out readelf.out |
| 26 | |
| 27 | echo Create debug a.out. |
| 28 | echo "int main() { return 1; }" | gcc -g -xc - |
| 29 | |
| 30 | echo strip -g to file with debug file |
| 31 | testrun ${abs_top_builddir}/src/strip -g -o strip.out -f debug.out || |
| 32 | { echo "*** failed to strip -g -o strip.out -f debug.out a.out"; exit -1; } |
| 33 | |
| 34 | status=0 |
| 35 | testrun ${abs_top_builddir}/src/readelf -S strip.out > readelf.out |
| 36 | grep SYMTAB readelf.out || status=$? |
| 37 | echo $status |
| 38 | if test $status -ne 0; then |
| 39 | echo no symtab found in strip.out |
| 40 | exit 1 |
| 41 | fi |
| 42 | |
| 43 | status=0 |
| 44 | testrun ${abs_top_builddir}/src/readelf -S debug.out > readelf.out |
| 45 | grep SYMTAB readelf.out || status=$? |
| 46 | echo $status |
| 47 | if test $status -ne 1; then |
| 48 | echo symtab found in debug.out |
| 49 | exit 1 |
| 50 | fi |
| 51 | |
| 52 | # arm (with data marker in .debug_frame). See tests/run-addrcfi.sh |
| 53 | testfiles testfilearm |
| 54 | |
| 55 | echo arm strip -g to file with debug file |
| 56 | testrun ${abs_top_builddir}/src/strip -g -o strip.out -f debug.out testfilearm || |
| 57 | { echo "*** failed to strip -g -o strip.out -f debug.out a.out"; exit -1; } |
| 58 | |
| 59 | status=0 |
| 60 | testrun ${abs_top_builddir}/src/readelf -S strip.out > readelf.out |
| 61 | grep SYMTAB readelf.out || status=$? |
| 62 | echo $status |
| 63 | if test $status -ne 0; then |
| 64 | echo no symtab found in strip.out |
| 65 | exit 1 |
| 66 | fi |
| 67 | |
| 68 | status=0 |
| 69 | testrun ${abs_top_builddir}/src/readelf -S debug.out > readelf.out |
| 70 | grep SYMTAB readelf.out || status=$? |
| 71 | echo $status |
| 72 | if test $status -ne 1; then |
| 73 | echo symtab found in debug.out |
| 74 | exit 1 |
| 75 | fi |
| 76 | |
| 77 | # aarch64 (with data marker in .debug_frame). See tests/run-addrcfi.sh |
| 78 | testfiles testfileaarch64 |
| 79 | |
| 80 | echo aarch64 strip -g to file with debug file |
| 81 | testrun ${abs_top_builddir}/src/strip -g -o strip.out -f debug.out testfileaarch64 || |
| 82 | { echo "*** failed to strip -g -o strip.out -f debug.out a.out"; exit -1; } |
| 83 | |
| 84 | status=0 |
| 85 | testrun ${abs_top_builddir}/src/readelf -S strip.out > readelf.out |
| 86 | grep SYMTAB readelf.out || status=$? |
| 87 | echo $status |
| 88 | if test $status -ne 0; then |
| 89 | echo no symtab found in strip.out |
| 90 | exit 1 |
| 91 | fi |
| 92 | |
| 93 | status=0 |
| 94 | testrun ${abs_top_builddir}/src/readelf -S debug.out > readelf.out |
| 95 | grep SYMTAB readelf.out || status=$? |
| 96 | echo $status |
| 97 | if test $status -ne 1; then |
| 98 | echo symtab found in debug.out |
| 99 | exit 1 |
| 100 | fi |
| 101 | |
| 102 | exit 0 |