68 lines · plain
1// This test checks that BOLT creates entry points for addresses2// referenced by dynamic relocations.3// The test also checks that BOLT can map addresses inside functions.4 5// Checks for error and entry points.6# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o7# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q8# RUN: llvm-bolt %t.exe -o %t.bolt 2>&1 | FileCheck %s9# RUN: llvm-bolt %t.exe -o %t.bolt --print-cfg | FileCheck --check-prefix=CHECK-ENTRIES %s10 11// Checks for dynamic relocations.12# RUN: llvm-readelf -dr %t.bolt > %t.out.txt13# RUN: llvm-objdump -j .rela.dyn -d %t.bolt >> %t.out.txt14# RUN: FileCheck --check-prefix=CHECK-RELOCS %s --input-file=%t.out.txt15 16// Before bolt could handle mapping addresses within moved functions, it17// would bail out with an error of the form:18// BOLT-ERROR: unable to get new address corresponding to input address 0x10390 in function main. Consider adding this function to --skip-funcs=...19// These addresses arise if computed GOTO is in use.20// Check that bolt does not emit any error.21# CHECK-NOT: BOLT-ERROR22 23// Check that there are dynamic relocations.24# CHECK-RELOCS: Dynamic section at offset {{.*}} contains {{.*}} entries:25# CHECK-RELOCS: Relocation section '.rela.dyn' at offset {{.*}} contains {{.*}} entries26 27// Check that dynamic relocations were updated28# CHECK-RELOCS: [[#%x,OFF:]] [[#%x,INFO_DYN:]] R_AARCH64_RELATIVE [[#%x,ADDR:]]29# CHECK-RELOCS-NEXT: [[#OFF + 8]] {{0*}}[[#INFO_DYN]] R_AARCH64_RELATIVE [[#ADDR + 8]]30# CHECK-RELOCS: [[#ADDR]] <unknown>31# CHECK-RELOCS: [[#ADDR + 8]] <unknown>32 33// Check that BOLT registers extra entry points for dynamic relocations.34# CHECK-ENTRIES: Binary Function "main" after building cfg {35# CHECK-ENTRIES: IsMultiEntry: 136# CHECK-ENTRIES: .Ltmp0 {{.*}}37# CHECK-ENTRIES-NEXT: Secondary Entry Point: {{.*}}38# CHECK-ENTRIES: .Ltmp1 {{.*}}39# CHECK-ENTRIES-NEXT: Secondary Entry Point: {{.*}}40 41.globl main42.p2align 243.type main,@function44main:45.cfi_startproc46 adrp x8, .L__const.main.ptrs+847 add x8, x8, :lo12:.L__const.main.ptrs+848 ldr x9, [x8], #849 br x950 51.Label0: // Block address taken52 ldr x9, [x8], #853 br x954 55.Label1: // Block address taken56 mov w0, #4257 ret58 59.Lfunc_end0:60.size main, .Lfunc_end0-main61.cfi_endproc62 .type .L__const.main.ptrs,@object63 .section .data.rel.ro,"aw",@progbits64 .p2align 3, 0x065.L__const.main.ptrs:66 .xword .Label067 .xword .Label168