Josh Stone | ffa0200 | 2011-01-10 21:28:46 -0800 | [diff] [blame] | 1 | #! /bin/sh |
Roland McGrath | 3f9256d | 2013-01-07 15:13:46 -0800 | [diff] [blame] | 2 | # Copyright (C) 2011-2013 Red Hat, Inc. |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 3 | # This file is part of elfutils. |
Josh Stone | ffa0200 | 2011-01-10 21:28:46 -0800 | [diff] [blame] | 4 | # |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 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. |
Josh Stone | ffa0200 | 2011-01-10 21:28:46 -0800 | [diff] [blame] | 9 | # |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 10 | # elfutils is distributed in the hope that it will be useful, but |
Josh Stone | ffa0200 | 2011-01-10 21:28:46 -0800 | [diff] [blame] | 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | # GNU General Public License for more details. |
Josh Stone | ffa0200 | 2011-01-10 21:28:46 -0800 | [diff] [blame] | 14 | # |
Mark Wielaard | de2ed97 | 2012-06-05 17:15:16 +0200 | [diff] [blame] | 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/>. |
Josh Stone | ffa0200 | 2011-01-10 21:28:46 -0800 | [diff] [blame] | 17 | |
| 18 | . $srcdir/test-subr.sh |
| 19 | |
| 20 | |
| 21 | # testfile52.c: |
| 22 | # #include <stdlib.h> |
| 23 | # int foo() { exit(0); } |
| 24 | # |
Josh Stone | d41d9a6 | 2011-01-11 19:16:57 -0800 | [diff] [blame] | 25 | # gcc -m32 -g -shared testfile52-32.c -o testfile52-32.so |
| 26 | # eu-strip -f testfile52-32.so.debug testfile52-32.so |
| 27 | # cp testfile52-32.so testfile52-32.prelink.so |
| 28 | # prelink -N testfile52-32.prelink.so |
| 29 | # cp testfile52-32.so testfile52-32.noshdrs.so |
| 30 | # prelink -r 0x42000000 testfile52-32.noshdrs.so |
| 31 | # eu-strip --remove-comment --strip-sections testfile52-32.noshdrs.so |
Josh Stone | ffa0200 | 2011-01-10 21:28:46 -0800 | [diff] [blame] | 32 | |
Josh Stone | d41d9a6 | 2011-01-11 19:16:57 -0800 | [diff] [blame] | 33 | testfiles testfile52-32.so testfile52-32.so.debug |
| 34 | testfiles testfile52-32.prelink.so testfile52-32.noshdrs.so |
Roland McGrath | 32520bd | 2011-01-12 10:43:32 -0800 | [diff] [blame] | 35 | tempfiles testmaps52-32 testfile52-32.noshdrs.so.debug |
Roland McGrath | 3f9256d | 2013-01-07 15:13:46 -0800 | [diff] [blame] | 36 | ln -snf testfile52-32.so.debug testfile52-32.noshdrs.so.debug |
Josh Stone | ffa0200 | 2011-01-10 21:28:46 -0800 | [diff] [blame] | 37 | |
Josh Stone | d41d9a6 | 2011-01-11 19:16:57 -0800 | [diff] [blame] | 38 | cat > testmaps52-32 <<EOF |
| 39 | 00111000-00112000 r-xp 00000000 fd:01 1 `pwd`/testfile52-32.so |
| 40 | 00112000-00113000 rw-p 00000000 fd:01 1 `pwd`/testfile52-32.so |
| 41 | 41000000-41001000 r-xp 00000000 fd:01 2 `pwd`/testfile52-32.prelink.so |
| 42 | 41001000-41002000 rw-p 00000000 fd:01 2 `pwd`/testfile52-32.prelink.so |
| 43 | 42000000-42001000 r-xp 00000000 fd:01 3 `pwd`/testfile52-32.noshdrs.so |
| 44 | 42001000-42002000 rw-p 00000000 fd:01 3 `pwd`/testfile52-32.noshdrs.so |
Josh Stone | ffa0200 | 2011-01-10 21:28:46 -0800 | [diff] [blame] | 45 | EOF |
| 46 | |
| 47 | # Prior to commit 1743d7f, libdwfl would fail on the second address, |
| 48 | # because it didn't notice that prelink added a 0x20-byte offset from |
| 49 | # what the .debug file reports. |
Mark Wielaard | 86be792 | 2013-04-26 23:44:25 +0200 | [diff] [blame] | 50 | testrun_compare ${abs_top_builddir}/src/addr2line -S -M testmaps52-32 \ |
Josh Stone | d41d9a6 | 2011-01-11 19:16:57 -0800 | [diff] [blame] | 51 | 0x11140c 0x4100042d 0x4200040e <<\EOF |
Josh Stone | ffa0200 | 2011-01-10 21:28:46 -0800 | [diff] [blame] | 52 | foo |
Josh Stone | d41d9a6 | 2011-01-11 19:16:57 -0800 | [diff] [blame] | 53 | /home/jistone/src/elfutils/tests/testfile52-32.c:2 |
Josh Stone | ffa0200 | 2011-01-10 21:28:46 -0800 | [diff] [blame] | 54 | foo+0x1 |
Josh Stone | d41d9a6 | 2011-01-11 19:16:57 -0800 | [diff] [blame] | 55 | /home/jistone/src/elfutils/tests/testfile52-32.c:2 |
| 56 | foo+0x2 |
Roland McGrath | 32520bd | 2011-01-12 10:43:32 -0800 | [diff] [blame] | 57 | /home/jistone/src/elfutils/tests/testfile52-32.c:2 |
Josh Stone | d41d9a6 | 2011-01-11 19:16:57 -0800 | [diff] [blame] | 58 | EOF |
| 59 | |
| 60 | # Repeat testfile52 for -m64. The particular REL>RELA issue doesn't exist, but |
| 61 | # we'll make sure the rest works anyway. |
| 62 | testfiles testfile52-64.so testfile52-64.so.debug |
| 63 | testfiles testfile52-64.prelink.so testfile52-64.noshdrs.so |
Roland McGrath | 32520bd | 2011-01-12 10:43:32 -0800 | [diff] [blame] | 64 | tempfiles testmaps52-64 testfile52-64.noshdrs.so.debug |
Roland McGrath | 3f9256d | 2013-01-07 15:13:46 -0800 | [diff] [blame] | 65 | ln -snf testfile52-64.so.debug testfile52-64.noshdrs.so.debug |
Josh Stone | d41d9a6 | 2011-01-11 19:16:57 -0800 | [diff] [blame] | 66 | |
| 67 | cat > testmaps52-64 <<EOF |
| 68 | 1000000000-1000001000 r-xp 00000000 fd:11 1 `pwd`/testfile52-64.so |
| 69 | 1000001000-1000200000 ---p 00001000 fd:11 1 `pwd`/testfile52-64.so |
| 70 | 1000200000-1000201000 rw-p 00000000 fd:11 1 `pwd`/testfile52-64.so |
| 71 | 3000000000-3000001000 r-xp 00000000 fd:11 2 `pwd`/testfile52-64.prelink.so |
| 72 | 3000001000-3000200000 ---p 00001000 fd:11 2 `pwd`/testfile52-64.prelink.so |
| 73 | 3000200000-3000201000 rw-p 00000000 fd:11 2 `pwd`/testfile52-64.prelink.so |
| 74 | 3800000000-3800001000 r-xp 00000000 fd:11 3 `pwd`/testfile52-64.noshdrs.so |
| 75 | 3800001000-3800200000 ---p 00001000 fd:11 3 `pwd`/testfile52-64.noshdrs.so |
| 76 | 3800200000-3800201000 rw-p 00000000 fd:11 3 `pwd`/testfile52-64.noshdrs.so |
| 77 | EOF |
| 78 | |
Mark Wielaard | 86be792 | 2013-04-26 23:44:25 +0200 | [diff] [blame] | 79 | testrun_compare ${abs_top_builddir}/src/addr2line -S -M testmaps52-64 \ |
Josh Stone | d41d9a6 | 2011-01-11 19:16:57 -0800 | [diff] [blame] | 80 | 0x100000056c 0x300000056d 0x380000056e <<\EOF |
| 81 | foo |
| 82 | /home/jistone/src/elfutils/tests/testfile52-64.c:2 |
| 83 | foo+0x1 |
| 84 | /home/jistone/src/elfutils/tests/testfile52-64.c:2 |
| 85 | foo+0x2 |
Roland McGrath | 32520bd | 2011-01-12 10:43:32 -0800 | [diff] [blame] | 86 | /home/jistone/src/elfutils/tests/testfile52-64.c:2 |
Josh Stone | ffa0200 | 2011-01-10 21:28:46 -0800 | [diff] [blame] | 87 | EOF |
| 88 | |
| 89 | |
| 90 | # testfile53.c: |
Josh Stone | cf51471 | 2011-01-11 19:16:58 -0800 | [diff] [blame] | 91 | # char foo[0x1000]; |
Josh Stone | ffa0200 | 2011-01-10 21:28:46 -0800 | [diff] [blame] | 92 | # int main() { return 0; } |
| 93 | # |
Josh Stone | cf51471 | 2011-01-11 19:16:58 -0800 | [diff] [blame] | 94 | # gcc -m32 -g testfile53-32.c -o testfile53-32 |
| 95 | # eu-strip -f testfile53-32.debug testfile53-32 |
| 96 | # cp testfile53-32 testfile53-32.prelink |
| 97 | # prelink -N testfile53-32.prelink |
| 98 | testfiles testfile53-32 testfile53-32.debug testfile53-32.prelink |
Josh Stone | ffa0200 | 2011-01-10 21:28:46 -0800 | [diff] [blame] | 99 | |
Mark Wielaard | 86be792 | 2013-04-26 23:44:25 +0200 | [diff] [blame] | 100 | testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile53-32 0x8048394 0x8048395 <<\EOF |
Josh Stone | ffa0200 | 2011-01-10 21:28:46 -0800 | [diff] [blame] | 101 | main |
Josh Stone | cf51471 | 2011-01-11 19:16:58 -0800 | [diff] [blame] | 102 | /home/jistone/src/elfutils/tests/testfile53-32.c:2 |
Josh Stone | ffa0200 | 2011-01-10 21:28:46 -0800 | [diff] [blame] | 103 | main+0x1 |
Josh Stone | cf51471 | 2011-01-11 19:16:58 -0800 | [diff] [blame] | 104 | /home/jistone/src/elfutils/tests/testfile53-32.c:2 |
Josh Stone | ffa0200 | 2011-01-10 21:28:46 -0800 | [diff] [blame] | 105 | EOF |
| 106 | |
| 107 | # prelink shuffled some of the sections, but .text is in the same place. |
Mark Wielaard | 86be792 | 2013-04-26 23:44:25 +0200 | [diff] [blame] | 108 | testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile53-32.prelink 0x8048396 0x8048397 <<\EOF |
Josh Stone | ffa0200 | 2011-01-10 21:28:46 -0800 | [diff] [blame] | 109 | main+0x2 |
Josh Stone | cf51471 | 2011-01-11 19:16:58 -0800 | [diff] [blame] | 110 | /home/jistone/src/elfutils/tests/testfile53-32.c:2 |
Josh Stone | ffa0200 | 2011-01-10 21:28:46 -0800 | [diff] [blame] | 111 | main+0x3 |
Josh Stone | cf51471 | 2011-01-11 19:16:58 -0800 | [diff] [blame] | 112 | /home/jistone/src/elfutils/tests/testfile53-32.c:2 |
| 113 | EOF |
| 114 | |
| 115 | # Repeat testfile53 in 64-bit, except use foo[0x800] to achieve the same |
| 116 | # prelink section shuffling. |
| 117 | testfiles testfile53-64 testfile53-64.debug testfile53-64.prelink |
| 118 | |
Mark Wielaard | 86be792 | 2013-04-26 23:44:25 +0200 | [diff] [blame] | 119 | testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile53-64 0x400474 0x400475 <<\EOF |
Josh Stone | cf51471 | 2011-01-11 19:16:58 -0800 | [diff] [blame] | 120 | main |
| 121 | /home/jistone/src/elfutils/tests/testfile53-64.c:2 |
| 122 | main+0x1 |
| 123 | /home/jistone/src/elfutils/tests/testfile53-64.c:2 |
| 124 | EOF |
| 125 | |
Mark Wielaard | 86be792 | 2013-04-26 23:44:25 +0200 | [diff] [blame] | 126 | testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile53-64.prelink 0x400476 0x400477 <<\EOF |
Josh Stone | cf51471 | 2011-01-11 19:16:58 -0800 | [diff] [blame] | 127 | main+0x2 |
| 128 | /home/jistone/src/elfutils/tests/testfile53-64.c:2 |
| 129 | main+0x3 |
| 130 | /home/jistone/src/elfutils/tests/testfile53-64.c:2 |
Josh Stone | ffa0200 | 2011-01-10 21:28:46 -0800 | [diff] [blame] | 131 | EOF |
Josh Stone | ccbccef | 2011-01-11 19:16:59 -0800 | [diff] [blame] | 132 | |
| 133 | |
| 134 | # testfile54.c: |
| 135 | # extern void * stdin; |
| 136 | # static void * pstdin = &stdin; |
| 137 | # void * const foo = &pstdin; |
| 138 | # |
| 139 | # gcc -m32 -g -shared -nostartfiles testfile54-32.c -o testfile54-32.so |
| 140 | # eu-strip -f testfile54-32.so.debug testfile54-32.so |
| 141 | # cp testfile54-32.so testfile54-32.prelink.so |
| 142 | # prelink -N testfile54-32.prelink.so |
| 143 | # cp testfile54-32.so testfile54-32.noshdrs.so |
| 144 | # prelink -r 0x42000000 testfile54-32.noshdrs.so |
| 145 | # eu-strip --remove-comment --strip-sections testfile54-32.noshdrs.so |
| 146 | testfiles testfile54-32.so testfile54-32.so.debug |
| 147 | testfiles testfile54-32.prelink.so testfile54-32.noshdrs.so |
Roland McGrath | 4f6d4e1 | 2011-01-12 10:49:40 -0800 | [diff] [blame] | 148 | tempfiles testmaps54-32 |
| 149 | |
| 150 | # Note we have no testfile54-32.noshdrs.so.debug link here, so |
| 151 | # this is testing finding the symbols in .dynsym via PT_DYNAMIC. |
Josh Stone | ccbccef | 2011-01-11 19:16:59 -0800 | [diff] [blame] | 152 | |
| 153 | cat > testmaps54-32 <<EOF |
| 154 | 00111000-00112000 r--p 00000000 fd:01 1 `pwd`/testfile54-32.so |
| 155 | 00112000-00113000 rw-p 00000000 fd:01 1 `pwd`/testfile54-32.so |
| 156 | 41000000-41001000 r--p 00000000 fd:01 2 `pwd`/testfile54-32.prelink.so |
| 157 | 41001000-41002000 rw-p 00000000 fd:01 2 `pwd`/testfile54-32.prelink.so |
| 158 | 42000000-42001000 r--p 00000000 fd:01 3 `pwd`/testfile54-32.noshdrs.so |
| 159 | 42001000-42002000 rw-p 00000000 fd:01 3 `pwd`/testfile54-32.noshdrs.so |
| 160 | EOF |
| 161 | |
Mark Wielaard | 86be792 | 2013-04-26 23:44:25 +0200 | [diff] [blame] | 162 | testrun_compare ${abs_top_builddir}/src/addr2line -S -M testmaps54-32 \ |
Josh Stone | ccbccef | 2011-01-11 19:16:59 -0800 | [diff] [blame] | 163 | 0x1111fc 0x1122a4 0x410001fd 0x410012a5 0x420001fe <<\EOF |
| 164 | foo |
| 165 | ??:0 |
| 166 | pstdin |
| 167 | ??:0 |
| 168 | foo+0x1 |
| 169 | ??:0 |
| 170 | pstdin+0x1 |
| 171 | ??:0 |
| 172 | foo+0x2 |
| 173 | ??:0 |
| 174 | EOF |
| 175 | |
| 176 | # Repeat testfile64 in 64-bit |
| 177 | testfiles testfile54-64.so testfile54-64.so.debug |
| 178 | testfiles testfile54-64.prelink.so testfile54-64.noshdrs.so |
Roland McGrath | 4f6d4e1 | 2011-01-12 10:49:40 -0800 | [diff] [blame] | 179 | tempfiles testmaps54-64 |
| 180 | |
| 181 | # Note we have no testfile54-64.noshdrs.so.debug link here, so |
| 182 | # this is testing finding the symbols in .dynsym via PT_DYNAMIC. |
Josh Stone | ccbccef | 2011-01-11 19:16:59 -0800 | [diff] [blame] | 183 | |
| 184 | cat > testmaps54-64 <<EOF |
| 185 | 1000000000-1000001000 r--p 00000000 fd:11 1 `pwd`/testfile54-64.so |
| 186 | 1000001000-1000200000 ---p 00001000 fd:11 1 `pwd`/testfile54-64.so |
| 187 | 1000200000-1000201000 rw-p 00000000 fd:11 1 `pwd`/testfile54-64.so |
| 188 | 3000000000-3000001000 r--p 00000000 fd:11 2 `pwd`/testfile54-64.prelink.so |
| 189 | 3000001000-3000200000 ---p 00001000 fd:11 2 `pwd`/testfile54-64.prelink.so |
| 190 | 3000200000-3000201000 rw-p 00000000 fd:11 2 `pwd`/testfile54-64.prelink.so |
| 191 | 3800000000-3800001000 r--p 00000000 fd:11 3 `pwd`/testfile54-64.noshdrs.so |
| 192 | 3800001000-3800200000 ---p 00001000 fd:11 3 `pwd`/testfile54-64.noshdrs.so |
| 193 | 3800200000-3800201000 rw-p 00000000 fd:11 3 `pwd`/testfile54-64.noshdrs.so |
| 194 | EOF |
| 195 | |
Mark Wielaard | 86be792 | 2013-04-26 23:44:25 +0200 | [diff] [blame] | 196 | testrun_compare ${abs_top_builddir}/src/addr2line -S -M testmaps54-64 \ |
Josh Stone | ccbccef | 2011-01-11 19:16:59 -0800 | [diff] [blame] | 197 | 0x10000002f8 0x1000200448 0x30000002f9 0x3000200449 0x38000002fa <<\EOF |
| 198 | foo |
| 199 | ??:0 |
| 200 | pstdin |
| 201 | ??:0 |
| 202 | foo+0x1 |
| 203 | ??:0 |
| 204 | pstdin+0x1 |
| 205 | ??:0 |
| 206 | foo+0x2 |
| 207 | ??:0 |
| 208 | EOF |
Josh Stone | dc34eda | 2011-02-02 16:30:01 -0800 | [diff] [blame] | 209 | |
| 210 | |
| 211 | # testfile55.c: |
| 212 | # extern void *stdin; |
| 213 | # int main() { return !stdin; } |
| 214 | # |
| 215 | # gcc -m32 -g testfile55-32.c -o testfile55-32 |
| 216 | # eu-strip -f testfile55-32.debug testfile55-32 |
| 217 | # cp testfile55-32 testfile55-32.prelink |
| 218 | # prelink -N testfile55-32.prelink |
| 219 | testfiles testfile55-32 testfile55-32.debug testfile55-32.prelink |
| 220 | |
Mark Wielaard | 86be792 | 2013-04-26 23:44:25 +0200 | [diff] [blame] | 221 | testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile55-32 0x80483b4 0x80483b5 <<\EOF |
Josh Stone | dc34eda | 2011-02-02 16:30:01 -0800 | [diff] [blame] | 222 | main |
| 223 | /home/jistone/src/elfutils/tests/testfile55-32.c:2 |
| 224 | main+0x1 |
| 225 | /home/jistone/src/elfutils/tests/testfile55-32.c:2 |
| 226 | EOF |
| 227 | |
| 228 | # prelink splits .bss into .dynbss+.bss, so the start of .bss changes, but the |
| 229 | # total size remains the same, and .text doesn't move at all. |
Mark Wielaard | 86be792 | 2013-04-26 23:44:25 +0200 | [diff] [blame] | 230 | testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile55-32.prelink 0x80483b6 0x80483b7 <<\EOF |
Josh Stone | dc34eda | 2011-02-02 16:30:01 -0800 | [diff] [blame] | 231 | main+0x2 |
| 232 | /home/jistone/src/elfutils/tests/testfile55-32.c:2 |
| 233 | main+0x3 |
| 234 | /home/jistone/src/elfutils/tests/testfile55-32.c:2 |
| 235 | EOF |
| 236 | |
| 237 | # Repeat testfile55 in 64-bit |
| 238 | testfiles testfile55-64 testfile55-64.debug testfile55-64.prelink |
| 239 | |
Mark Wielaard | 86be792 | 2013-04-26 23:44:25 +0200 | [diff] [blame] | 240 | testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile55-64 0x4004b4 0x4004b5 <<\EOF |
Josh Stone | dc34eda | 2011-02-02 16:30:01 -0800 | [diff] [blame] | 241 | main |
| 242 | /home/jistone/src/elfutils/tests/testfile55-64.c:2 |
| 243 | main+0x1 |
| 244 | /home/jistone/src/elfutils/tests/testfile55-64.c:2 |
| 245 | EOF |
| 246 | |
Mark Wielaard | 86be792 | 2013-04-26 23:44:25 +0200 | [diff] [blame] | 247 | testrun_compare ${abs_top_builddir}/src/addr2line -S -e testfile55-64.prelink 0x4004b6 0x4004b7 <<\EOF |
Josh Stone | dc34eda | 2011-02-02 16:30:01 -0800 | [diff] [blame] | 248 | main+0x2 |
| 249 | /home/jistone/src/elfutils/tests/testfile55-64.c:2 |
| 250 | main+0x3 |
| 251 | /home/jistone/src/elfutils/tests/testfile55-64.c:2 |
| 252 | EOF |