73 lines · plain
1# This test is to verify that BOLT won't take a label pointing to constant2# island as a secondary entry point. This could happen when function doesn't3# have ELF size set if it is from assembly code, or a constant island is4# referenced by another function discovered during relocation processing.5 6# RUN: split-file %s %t7 8# RUN: %clang %cflags -pie %t/tt.asm -o %t.so \9# RUN: -Wl,-q -Wl,--init=_foo -Wl,--fini=_foo10# RUN: llvm-bolt %t.so -o %t.bolt.so --print-cfg 2>&1 | FileCheck %s11# CHECK-NOT: BOLT-WARNING: reference in the middle of instruction detected \12# CHECK-NOT: function _start at offset 0x{{[0-9a-f]+}}13# CHECK: Binary Function "_start" after building cfg14 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_script18# RUN: llvm-bolt %tt.so -o %tt.bolted.so19 20;--- tt.asm21 .text22 23 .global _foo24 .type _foo, %function25_foo:26 ret27 28 .global _start29 .type _start, %function30_start:31 b _foo32 33 .balign 1634_random_consts:35 .long 0x1234567836 .long 0x90abcdef37 38 .global _bar39 .type _bar, %function40_bar:41 ret42 43 # Dummy relocation to force relocation mode44 .reloc 0, R_AARCH64_NONE45 46;--- tt.c47void _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.c62__attribute__((visibility("hidden"))) extern void* _rodatx;63void* bar() { return &_rodatx; }64 65;--- linker_script66{67global:68 _start;69 foo;70 bar;71local: *;72};73