[libc] Switch to using the generic `<gpuintrin.h>` implementations (#121810)
[llvm-project.git] / bolt / test / AArch64 / constant_island_pie_update.s
blob889f6b6acd9f2a78405a5b9436520ffb560e5fcf
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
7 // .rela.dyn
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 -z --show-all-symbols %t.rela.bolt | FileCheck %s
12 # RUN: llvm-readelf -rsW %t.rela.bolt | FileCheck --check-prefix=ELFCHECK %s
13 // .relr.dyn
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 -z --show-all-symbols %t.relr.bolt | FileCheck %s
19 # RUN: llvm-objdump -j .text -d -z %t.relr.bolt | \
20 # RUN: FileCheck %s --check-prefix=ADDENDCHECK
21 # RUN: llvm-readelf -rsW %t.relr.bolt | FileCheck --check-prefix=RELRELFCHECK %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>:
26 # CHECK: {{.*}} <$d>:
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>:
44 # CHECK-NEXT: adrp
45 # CHECK-NEXT: add
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 # RELRELFCHECK: $d{{$}}
55 # RELRELFCHECK-NEXT: $d + 0x8{{$}}
56 # RELRELFCHECK-NEXT: $d + 0x18{{$}}
57 # RELRELFCHECK-NEXT: mytextP
58 # RELRELFCHECK-EMPTY:
60 // Check that .relr.dyn size is 2 bytes to ensure that last 3 relocations were
61 // encoded as a bitmap so the total section size for 3 relocations is 2 bytes.
62 # RELRSZCHECK: .relr.dyn RELR [[#%x,ADDR:]] [[#%x,OFF:]] {{0*}}10
64 .text
65 .align 4
66 .local exitLocal
67 .type exitLocal, %function
68 exitLocal:
69 add x1, x1, #1
70 add x1, x1, #1
71 nop
72 nop
73 ret
74 .size exitLocal, .-exitLocal
76 .global _start
77 .type _start, %function
78 _start:
79 mov x0, #0
80 adr x1, .Lci
81 ldr x1, [x1]
82 blr x1
83 mov x0, #1
84 bl exitLocal
85 nop
86 .Lci:
87 .xword exitLocal
88 .xword exitLocal
89 .xword 0
90 .xword exitLocal
91 .size _start, .-_start
93 .global addressDynCi
94 .type addressDynCi, %function
95 addressDynCi:
96 adr x1, .Lci
97 bl _start
98 .size addressDynCi, .-addressDynCi
100 .section ".mytext", "ax"
101 .balign 8
102 .global dummy
103 .type dummy, %function
104 dummy:
106 .word 0
107 .size dummy, .-dummy
109 .global mytextP
110 mytextP:
111 .xword exitLocal
112 .size mytextP, .-mytextP