2 # Copyright (C) 2011 Red Hat, Inc.
3 # This file is part of Red Hat elfutils.
5 # Red Hat elfutils is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; version 2 of the License.
9 # Red Hat elfutils is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
14 # You should have received a copy of the GNU General Public License along
15 # with Red Hat elfutils; if not, write to the Free Software Foundation,
16 # Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
18 # Red Hat elfutils is an included package of the Open Invention Network.
19 # An included package of the Open Invention Network is a package for which
20 # Open Invention Network licensees cross-license their patents. No patent
21 # license is granted, either expressly or impliedly, by designation as an
22 # included package. Should you wish to participate in the Open Invention
23 # Network licensing program, please visit www.openinventionnetwork.com
24 # <http://www.openinventionnetwork.com>.
26 . $srcdir/test-subr.sh
31 # int foo() { exit(0); }
33 # gcc -m32 -g -shared testfile52-32.c -o testfile52-32.so
34 # eu-strip -f testfile52-32.so.debug testfile52-32.so
35 # cp testfile52-32.so testfile52-32.prelink.so
36 # prelink -N testfile52-32.prelink.so
37 # cp testfile52-32.so testfile52-32.noshdrs.so
38 # prelink -r 0x42000000 testfile52-32.noshdrs.so
39 # eu-strip --remove-comment --strip-sections testfile52-32.noshdrs.so
41 testfiles testfile52-32.so testfile52-32.so.debug
42 testfiles testfile52-32.prelink.so testfile52-32.noshdrs.so
43 tempfiles testmaps52-32 testfile52-32.noshdrs.so.debug
44 ln -s testfile52-32.so.debug testfile52-32.noshdrs.so.debug
46 cat > testmaps52-32 <<EOF
47 00111000-00112000 r-xp 00000000 fd:01 1 `pwd`/testfile52-32.so
48 00112000-00113000 rw-p 00000000 fd:01 1 `pwd`/testfile52-32.so
49 41000000-41001000 r-xp 00000000 fd:01 2 `pwd`/testfile52-32.prelink.so
50 41001000-41002000 rw-p 00000000 fd:01 2 `pwd`/testfile52-32.prelink.so
51 42000000-42001000 r-xp 00000000 fd:01 3 `pwd`/testfile52-32.noshdrs.so
52 42001000-42002000 rw-p 00000000 fd:01 3 `pwd`/testfile52-32.noshdrs.so
55 # Prior to commit 1743d7f, libdwfl would fail on the second address,
56 # because it didn't notice that prelink added a 0x20-byte offset from
57 # what the .debug file reports.
58 testrun_compare ../src/addr2line -S -M testmaps52-32 \
59 0x11140c 0x4100042d 0x4200040e <<\EOF
61 /home/jistone/src/elfutils/tests/testfile52-32.c:2
63 /home/jistone/src/elfutils/tests/testfile52-32.c:2
65 /home/jistone/src/elfutils/tests/testfile52-32.c:2
68 # Repeat testfile52 for -m64. The particular REL>RELA issue doesn't exist, but
69 # we'll make sure the rest works anyway.
70 testfiles testfile52-64.so testfile52-64.so.debug
71 testfiles testfile52-64.prelink.so testfile52-64.noshdrs.so
72 tempfiles testmaps52-64 testfile52-64.noshdrs.so.debug
73 ln -s testfile52-64.so.debug testfile52-64.noshdrs.so.debug
75 cat > testmaps52-64 <<EOF
76 1000000000-1000001000 r-xp 00000000 fd:11 1 `pwd`/testfile52-64.so
77 1000001000-1000200000 ---p 00001000 fd:11 1 `pwd`/testfile52-64.so
78 1000200000-1000201000 rw-p 00000000 fd:11 1 `pwd`/testfile52-64.so
79 3000000000-3000001000 r-xp 00000000 fd:11 2 `pwd`/testfile52-64.prelink.so
80 3000001000-3000200000 ---p 00001000 fd:11 2 `pwd`/testfile52-64.prelink.so
81 3000200000-3000201000 rw-p 00000000 fd:11 2 `pwd`/testfile52-64.prelink.so
82 3800000000-3800001000 r-xp 00000000 fd:11 3 `pwd`/testfile52-64.noshdrs.so
83 3800001000-3800200000 ---p 00001000 fd:11 3 `pwd`/testfile52-64.noshdrs.so
84 3800200000-3800201000 rw-p 00000000 fd:11 3 `pwd`/testfile52-64.noshdrs.so
87 testrun_compare ../src/addr2line -S -M testmaps52-64 \
88 0x100000056c 0x300000056d 0x380000056e <<\EOF
90 /home/jistone/src/elfutils/tests/testfile52-64.c:2
92 /home/jistone/src/elfutils/tests/testfile52-64.c:2
94 /home/jistone/src/elfutils/tests/testfile52-64.c:2
100 # int main() { return 0; }
102 # gcc -m32 -g testfile53-32.c -o testfile53-32
103 # eu-strip -f testfile53-32.debug testfile53-32
104 # cp testfile53-32 testfile53-32.prelink
105 # prelink -N testfile53-32.prelink
106 testfiles testfile53-32 testfile53-32.debug testfile53-32.prelink
108 testrun_compare ../src/addr2line -S -e testfile53-32 0x8048394 0x8048395 <<\EOF
110 /home/jistone/src/elfutils/tests/testfile53-32.c:2
112 /home/jistone/src/elfutils/tests/testfile53-32.c:2
115 # prelink shuffled some of the sections, but .text is in the same place.
116 testrun_compare ../src/addr2line -S -e testfile53-32.prelink 0x8048396 0x8048397 <<\EOF
118 /home/jistone/src/elfutils/tests/testfile53-32.c:2
120 /home/jistone/src/elfutils/tests/testfile53-32.c:2
123 # Repeat testfile53 in 64-bit, except use foo[0x800] to achieve the same
124 # prelink section shuffling.
125 testfiles testfile53-64 testfile53-64.debug testfile53-64.prelink
127 testrun_compare ../src/addr2line -S -e testfile53-64 0x400474 0x400475 <<\EOF
129 /home/jistone/src/elfutils/tests/testfile53-64.c:2
131 /home/jistone/src/elfutils/tests/testfile53-64.c:2
134 testrun_compare ../src/addr2line -S -e testfile53-64.prelink 0x400476 0x400477 <<\EOF
136 /home/jistone/src/elfutils/tests/testfile53-64.c:2
138 /home/jistone/src/elfutils/tests/testfile53-64.c:2
143 # extern void * stdin;
144 # static void * pstdin = &stdin;
145 # void * const foo = &pstdin;
147 # gcc -m32 -g -shared -nostartfiles testfile54-32.c -o testfile54-32.so
148 # eu-strip -f testfile54-32.so.debug testfile54-32.so
149 # cp testfile54-32.so testfile54-32.prelink.so
150 # prelink -N testfile54-32.prelink.so
151 # cp testfile54-32.so testfile54-32.noshdrs.so
152 # prelink -r 0x42000000 testfile54-32.noshdrs.so
153 # eu-strip --remove-comment --strip-sections testfile54-32.noshdrs.so
154 testfiles testfile54-32.so testfile54-32.so.debug
155 testfiles testfile54-32.prelink.so testfile54-32.noshdrs.so
156 tempfiles testmaps54-32
158 # Note we have no testfile54-32.noshdrs.so.debug link here, so
159 # this is testing finding the symbols in .dynsym via PT_DYNAMIC.
161 cat > testmaps54-32 <<EOF
162 00111000-00112000 r--p 00000000 fd:01 1 `pwd`/testfile54-32.so
163 00112000-00113000 rw-p 00000000 fd:01 1 `pwd`/testfile54-32.so
164 41000000-41001000 r--p 00000000 fd:01 2 `pwd`/testfile54-32.prelink.so
165 41001000-41002000 rw-p 00000000 fd:01 2 `pwd`/testfile54-32.prelink.so
166 42000000-42001000 r--p 00000000 fd:01 3 `pwd`/testfile54-32.noshdrs.so
167 42001000-42002000 rw-p 00000000 fd:01 3 `pwd`/testfile54-32.noshdrs.so
170 testrun_compare ../src/addr2line -S -M testmaps54-32 \
171 0x1111fc 0x1122a4 0x410001fd 0x410012a5 0x420001fe <<\EOF
184 # Repeat testfile64 in 64-bit
185 testfiles testfile54-64.so testfile54-64.so.debug
186 testfiles testfile54-64.prelink.so testfile54-64.noshdrs.so
187 tempfiles testmaps54-64
189 # Note we have no testfile54-64.noshdrs.so.debug link here, so
190 # this is testing finding the symbols in .dynsym via PT_DYNAMIC.
192 cat > testmaps54-64 <<EOF
193 1000000000-1000001000 r--p 00000000 fd:11 1 `pwd`/testfile54-64.so
194 1000001000-1000200000 ---p 00001000 fd:11 1 `pwd`/testfile54-64.so
195 1000200000-1000201000 rw-p 00000000 fd:11 1 `pwd`/testfile54-64.so
196 3000000000-3000001000 r--p 00000000 fd:11 2 `pwd`/testfile54-64.prelink.so
197 3000001000-3000200000 ---p 00001000 fd:11 2 `pwd`/testfile54-64.prelink.so
198 3000200000-3000201000 rw-p 00000000 fd:11 2 `pwd`/testfile54-64.prelink.so
199 3800000000-3800001000 r--p 00000000 fd:11 3 `pwd`/testfile54-64.noshdrs.so
200 3800001000-3800200000 ---p 00001000 fd:11 3 `pwd`/testfile54-64.noshdrs.so
201 3800200000-3800201000 rw-p 00000000 fd:11 3 `pwd`/testfile54-64.noshdrs.so
204 testrun_compare ../src/addr2line -S -M testmaps54-64 \
205 0x10000002f8 0x1000200448 0x30000002f9 0x3000200449 0x38000002fa <<\EOF
220 # extern void *stdin;
221 # int main() { return !stdin; }
223 # gcc -m32 -g testfile55-32.c -o testfile55-32
224 # eu-strip -f testfile55-32.debug testfile55-32
225 # cp testfile55-32 testfile55-32.prelink
226 # prelink -N testfile55-32.prelink
227 testfiles testfile55-32 testfile55-32.debug testfile55-32.prelink
229 testrun_compare ../src/addr2line -S -e testfile55-32 0x80483b4 0x80483b5 <<\EOF
231 /home/jistone/src/elfutils/tests/testfile55-32.c:2
233 /home/jistone/src/elfutils/tests/testfile55-32.c:2
236 # prelink splits .bss into .dynbss+.bss, so the start of .bss changes, but the
237 # total size remains the same, and .text doesn't move at all.
238 testrun_compare ../src/addr2line -S -e testfile55-32.prelink 0x80483b6 0x80483b7 <<\EOF
240 /home/jistone/src/elfutils/tests/testfile55-32.c:2
242 /home/jistone/src/elfutils/tests/testfile55-32.c:2
245 # Repeat testfile55 in 64-bit
246 testfiles testfile55-64 testfile55-64.debug testfile55-64.prelink
248 testrun_compare ../src/addr2line -S -e testfile55-64 0x4004b4 0x4004b5 <<\EOF
250 /home/jistone/src/elfutils/tests/testfile55-64.c:2
252 /home/jistone/src/elfutils/tests/testfile55-64.c:2
255 testrun_compare ../src/addr2line -S -e testfile55-64.prelink 0x4004b6 0x4004b7 <<\EOF
257 /home/jistone/src/elfutils/tests/testfile55-64.c:2
259 /home/jistone/src/elfutils/tests/testfile55-64.c:2