1 // This test checks that the constant island offset
and value is updated if
2 // it has dynamic relocation. The tests checks both
.rela.dyn and relr.dyn
3 // dynamic relocations.
4 // Also check that we don
't duplicate CI if it has dynamic relocations.
6 # RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
8 # RUN: %clang %cflags -fPIC -pie %t.o -o %t.rela.exe -nostdlib \
9 # RUN: -Wl,-q -Wl,-z,notext
10 # RUN: llvm-bolt %t.rela.exe -o %t.rela.bolt --use-old-text=0 --lite=0
11 # RUN: llvm-objdump -j .text -d --show-all-symbols %t.rela.bolt | FileCheck %s
12 # RUN: llvm-readelf -rsW %t.rela.bolt | FileCheck --check-prefix=ELFCHECK %s
14 # RUN: %clang %cflags -fPIC -pie %t.o -o %t.relr.exe -nostdlib \
15 # RUN: -Wl,-q -Wl,-z,notext -Wl,--pack-dyn-relocs=relr
16 # RUN: llvm-objcopy --remove-section .rela.mytext %t.relr.exe
17 # RUN: llvm-bolt %t.relr.exe -o %t.relr.bolt --use-old-text=0 --lite=0
18 # RUN: llvm-objdump -j .text -d --show-all-symbols %t.relr.bolt | FileCheck %s
19 # RUN: llvm-objdump -j .text -d %t.relr.bolt | \
20 # RUN: FileCheck %s --check-prefix=ADDENDCHECK
21 # RUN: llvm-readelf -rsW %t.relr.bolt | FileCheck --check-prefix=ELFCHECK %s
22 # RUN: llvm-readelf -SW %t.relr.bolt | FileCheck --check-prefix=RELRSZCHECK %s
24 // Check that the CI value was updated
25 # CHECK: [[#%x,ADDR:]] <exitLocal>:
27 # CHECK-NEXT: {{.*}} .word 0x{{[0]+}}[[#ADDR]]
28 # CHECK-NEXT: {{.*}} .word 0x00000000
29 # CHECK-NEXT: {{.*}} .word 0x{{[0]+}}[[#ADDR]]
30 # CHECK-NEXT: {{.*}} .word 0x00000000
31 # CHECK-NEXT: {{.*}} .word 0x00000000
32 # CHECK-NEXT: {{.*}} .word 0x00000000
33 # CHECK-NEXT: {{.*}} .word 0x{{[0]+}}[[#ADDR]]
34 # CHECK-NEXT: {{.*}} .word 0x00000000
36 // Check that addend was properly patched in mytextP with stripped relocations
37 # ADDENDCHECK: [[#%x,ADDR:]] <exitLocal>:
38 # ADDENDCHECK: {{.*}} <mytextP>:
39 # ADDENDCHECK-NEXT: {{.*}} .word 0x{{[0]+}}[[#ADDR]]
40 # ADDENDCHECK-NEXT: {{.*}} .word 0x00000000
42 // Check that we've relaxed adr to adrp
+ add to refer external CI
43 # CHECK: <addressDynCi>:
47 // Check that relocation offsets were updated
48 # ELFCHECK: [[#%x,OFF:]] [[#%x,INFO_DYN:]] R_AARCH64_RELATIVE
49 # ELFCHECK-NEXT: [[#OFF + 8]] {{0*}}[[#INFO_DYN]] R_AARCH64_RELATIVE
50 # ELFCHECK-NEXT: [[#OFF + 24]] {{0*}}[[#INFO_DYN]] R_AARCH64_RELATIVE
51 # ELFCHECK-NEXT: {{.*}} R_AARCH64_RELATIVE
52 # ELFCHECK: {{.*}}[[#OFF]] {{.*}} $d
54 // Check that
.relr.dyn size is 2 bytes to ensure that last 3 relocations were
55 // encoded as
a bitmap so the total section size for
3 relocations is
2 bytes.
56 # RELRSZCHECK: .relr.dyn RELR [[#%x,ADDR:]] [[#%x,OFF:]] {{0*}}10
61 .type exitLocal, %function
68 .size exitLocal, .-exitLocal
71 .type _start, %function
85 .size _start, .-_start
88 .type addressDynCi, %function
92 .size addressDynCi, .-addressDynCi
94 .section ".mytext", "ax"
97 .type dummy, %function
106 .size mytextP, .-mytextP