| 1 | // This test checks that referencing build_id through GOT table |
| 2 | // would result in GOT access after disassembly, not directly |
| 3 | // to build_id address. |
| 4 | |
| 5 | // RUN: %clang %cflags -fuse-ld=lld -Wl,-T,%S/Inputs/build_id.ldscript -Wl,-q \ |
| 6 | // RUN: -Wl,--no-relax -Wl,--build-id=sha1 %s -o %t.exe |
| 7 | // RUN: llvm-bolt -print-disasm --print-only=get_build_id %t.exe -o %t.bolt | \ |
| 8 | // RUN: FileCheck %s |
| 9 | |
| 10 | // CHECK: adrp [[REG:x[0-28]+]], __BOLT_got_zero |
| 11 | // CHECK: ldr x{{.*}}, [[[REG]], :lo12:__BOLT_got_zero{{.*}}] |
| 12 | |
| 13 | struct build_id_note { |
| 14 | char pad[16]; |
| 15 | char hash[20]; |
| 16 | }; |
| 17 | |
| 18 | extern const struct build_id_note build_id_note; |
| 19 | |
| 20 | __attribute__((noinline)) char get_build_id() { return build_id_note.hash[0]; } |
| 21 | |
| 22 | int main() { |
| 23 | get_build_id(); |
| 24 | return 0; |
| 25 | } |
| 26 | |