|
1 | 1 | # This test is to verify that BOLT won't take a label pointing to constant |
2 | | -# island as a secondary entry point (function `_start` doesn't have ELF size |
3 | | -# set originally) and the function won't otherwise be mistaken as non-simple. |
| 2 | +# island as a secondary entry point. This could happen when function doesn't |
| 3 | +# have ELF size set if it is from assembly code, or a constant island is |
| 4 | +# referenced by another function discovered during relocation processing. |
4 | 5 |
|
5 | | -# RUN: %clang %cflags -pie %s -o %t.so -Wl,-q -Wl,--init=_foo -Wl,--fini=_foo |
| 6 | +# RUN: split-file %s %t |
| 7 | + |
| 8 | +# RUN: %clang %cflags -pie %t/tt.asm -o %t.so \ |
| 9 | +# RUN: -Wl,-q -Wl,--init=_foo -Wl,--fini=_foo |
6 | 10 | # RUN: llvm-bolt %t.so -o %t.bolt.so --print-cfg 2>&1 | FileCheck %s |
7 | 11 | # CHECK-NOT: BOLT-WARNING: reference in the middle of instruction detected \ |
8 | 12 | # CHECK-NOT: function _start at offset 0x{{[0-9a-f]+}} |
9 | 13 | # CHECK: Binary Function "_start" after building cfg |
10 | 14 |
|
| 15 | +# RUN: %clang %cflags -ffunction-sections -shared %t/tt.c %t/ss.c -o %tt.so \ |
| 16 | +# RUN: -Wl,-q -Wl,--init=_start -Wl,--fini=_start \ |
| 17 | +# RUN: -Wl,--version-script=%t/linker_script |
| 18 | +# RUN: llvm-bolt %tt.so -o %tt.bolted.so |
| 19 | + |
| 20 | +;--- tt.asm |
11 | 21 | .text |
12 | 22 |
|
13 | 23 | .global _foo |
|
32 | 42 |
|
33 | 43 | # Dummy relocation to force relocation mode |
34 | 44 | .reloc 0, R_AARCH64_NONE |
| 45 | + |
| 46 | +;--- tt.c |
| 47 | +void _start() {} |
| 48 | + |
| 49 | +__attribute__((naked)) void foo() { |
| 50 | + asm("ldr x16, .L_fnptr\n" |
| 51 | + "blr x16\n" |
| 52 | + "ret\n" |
| 53 | + |
| 54 | + "_rodatx:" |
| 55 | + ".global _rodatx;" |
| 56 | + ".quad 0;" |
| 57 | + ".L_fnptr:" |
| 58 | + ".quad 0;"); |
| 59 | +} |
| 60 | + |
| 61 | +;--- ss.c |
| 62 | +__attribute__((visibility("hidden"))) extern void* _rodatx; |
| 63 | +void* bar() { return &_rodatx; } |
| 64 | + |
| 65 | +;--- linker_script |
| 66 | +{ |
| 67 | +global: |
| 68 | + _start; |
| 69 | + foo; |
| 70 | + bar; |
| 71 | +local: *; |
| 72 | +}; |
0 commit comments