summaryrefslogtreecommitdiffstats
path: root/tests/run-strip-g.sh
blob: 13038195dbae11ec63652ea8c0ea7f1b1cd265e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
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