|
8 | 8 | ## (4) early calls to a dylib stub use a thunk, and later calls the stub |
9 | 9 | ## directly |
10 | 10 | ## (5) Thunks are created for all sections in the text segment with branches. |
| 11 | +## (6) Thunks are in the linker map file. |
11 | 12 | ## Notes: |
12 | 13 | ## 0x4000000 = 64 Mi = half the magnitude of the forward-branch range |
13 | 14 |
|
14 | 15 | # RUN: rm -rf %t; mkdir %t |
15 | 16 | # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %s -o %t/input.o |
16 | | -# RUN: %lld -arch arm64 -dead_strip -lSystem -U _extern_sym -o %t/thunk %t/input.o |
| 17 | +# RUN: %lld -arch arm64 -dead_strip -lSystem -U _extern_sym -map %t/thunk.map -o %t/thunk %t/input.o |
17 | 18 | # RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t/thunk | FileCheck %s |
18 | 19 |
|
| 20 | +## Check that the thunks appear in the map file and that everything is sorted by address |
| 21 | +# Because of the `.space` instructions, there will end up being a lot of dead symbols in the |
| 22 | +# linker map (linker map will be ~2.7GB). So to avoid the test trying to (slowly) match regex |
| 23 | +# across all the ~2.7GB of the linker map - generate a version of the linker map without dead symbols. |
| 24 | +# RUN: awk '/# Dead Stripped Symbols:/ {exit} {print}' %t/thunk.map > %t/thunk_no_dead_syms.map |
| 25 | + |
| 26 | +# RUN: FileCheck %s --input-file %t/thunk_no_dead_syms.map --check-prefix=MAP |
| 27 | + |
| 28 | +# MAP: 0x{{[[:xdigit:]]+}} {{.*}} _b |
| 29 | +# MAP-NEXT: 0x{{[[:xdigit:]]+}} {{.*}} _c |
| 30 | +# MAP-NEXT: 0x{{[[:xdigit:]]+}} {{.*}} _d.thunk.0 |
| 31 | +# MAP-NEXT: 0x{{[[:xdigit:]]+}} {{.*}} _e.thunk.0 |
| 32 | +# MAP-NEXT: 0x{{[[:xdigit:]]+}} {{.*}} _f.thunk.0 |
| 33 | +# MAP-NEXT: 0x{{[[:xdigit:]]+}} {{.*}} _g.thunk.0 |
| 34 | +# MAP-NEXT: 0x{{[[:xdigit:]]+}} {{.*}} _h.thunk.0 |
| 35 | +# MAP-NEXT: 0x{{[[:xdigit:]]+}} {{.*}} ___nan.thunk.0 |
| 36 | +# MAP-NEXT: 0x{{[[:xdigit:]]+}} {{.*}} _d |
| 37 | +# MAP-NEXT: 0x{{[[:xdigit:]]+}} {{.*}} _e |
| 38 | +# MAP-NEXT: 0x{{[[:xdigit:]]+}} {{.*}} _f |
| 39 | +# MAP-NEXT: 0x{{[[:xdigit:]]+}} {{.*}} _g |
| 40 | +# MAP-NEXT: 0x{{[[:xdigit:]]+}} {{.*}} _a.thunk.0 |
| 41 | +# MAP-NEXT: 0x{{[[:xdigit:]]+}} {{.*}} _b.thunk.0 |
| 42 | +# MAP-NEXT: 0x{{[[:xdigit:]]+}} {{.*}} _h |
| 43 | +# MAP-NEXT: 0x{{[[:xdigit:]]+}} {{.*}} _main |
| 44 | +# MAP-NEXT: 0x{{[[:xdigit:]]+}} {{.*}} _c.thunk.0 |
| 45 | +# MAP-NEXT: 0x{{[[:xdigit:]]+}} {{.*}} _d.thunk.1 |
| 46 | +# MAP-NEXT: 0x{{[[:xdigit:]]+}} {{.*}} _e.thunk.1 |
| 47 | +# MAP-NEXT: 0x{{[[:xdigit:]]+}} {{.*}} _f.thunk.1 |
| 48 | +# MAP-NEXT: 0x{{[[:xdigit:]]+}} {{.*}} _z |
| 49 | + |
| 50 | + |
19 | 51 | # CHECK: Disassembly of section __TEXT,__text: |
20 | 52 |
|
21 | 53 | # CHECK: [[#%.13x, A_PAGE:]][[#%.3x, A_OFFSET:]] <_a>: |
|
0 commit comments