2 # Copyright (C) 2017 Red Hat, Inc.
3 # This file is part of elfutils.
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.
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.
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/>.
18 .
$srcdir/test-subr.sh
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.
25 tempfiles a.out strip.out debug.out readelf.out
27 echo Create debug a.out.
28 echo "int main() { return 1; }" |
${CC} -g -xc -
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; }
35 testrun
${abs_top_builddir}/src
/readelf
-S strip.out
> readelf.out
36 grep SYMTAB readelf.out || status
=$?
38 if test $status -ne 0; then
39 echo no symtab found
in strip.out
44 testrun
${abs_top_builddir}/src
/readelf
-S debug.out
> readelf.out
45 grep SYMTAB readelf.out || status
=$?
47 if test $status -ne 1; then
48 echo symtab found
in debug.out
52 # arm (with data marker in .debug_frame). See tests/run-addrcfi.sh
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; }
60 testrun
${abs_top_builddir}/src
/readelf
-S strip.out
> readelf.out
61 grep SYMTAB readelf.out || status
=$?
63 if test $status -ne 0; then
64 echo no symtab found
in strip.out
69 testrun
${abs_top_builddir}/src
/readelf
-S debug.out
> readelf.out
70 grep SYMTAB readelf.out || status
=$?
72 if test $status -ne 1; then
73 echo symtab found
in debug.out
77 # aarch64 (with data marker in .debug_frame). See tests/run-addrcfi.sh
78 testfiles testfileaarch64
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; }
85 testrun
${abs_top_builddir}/src
/readelf
-S strip.out
> readelf.out
86 grep SYMTAB readelf.out || status
=$?
88 if test $status -ne 0; then
89 echo no symtab found
in strip.out
94 testrun
${abs_top_builddir}/src
/readelf
-S debug.out
> readelf.out
95 grep SYMTAB readelf.out || status
=$?
97 if test $status -ne 1; then
98 echo symtab found
in debug.out