aboutsummaryrefslogtreecommitdiff
path: root/lld/test
diff options
context:
space:
mode:
authorDaniil Kovalev <dkovalev@accesssoftek.com>2024-05-31 14:57:58 +0300
committerGitHub <noreply@github.com>2024-05-31 14:57:58 +0300
commit7acd2c0652250994a4d922bda7275d750f7bf1b7 (patch)
tree2793f8ae9323943275d5d0b185c064d6054dc48c /lld/test
parentf917c396c9855d7e0af0b1b3e6209757c2de0b51 (diff)
downloadllvm-7acd2c0652250994a4d922bda7275d750f7bf1b7.zip
llvm-7acd2c0652250994a4d922bda7275d750f7bf1b7.tar.gz
llvm-7acd2c0652250994a4d922bda7275d750f7bf1b7.tar.bz2
[lld][ELF][AArch64] Support `R_AARCH64_GOT_LD_PREL19` relocation (#89592)
With tiny code model, the GOT slot contents can be loaded via `ldr x0, :got:sym` which corresponds to `R_AARCH64_GOT_LD_PREL19` static GOT-relative relocation. See https://github.com/ARM-software/abi-aa/blob/main/aaelf64/aaelf64.rst#static-aarch64-relocations
Diffstat (limited to 'lld/test')
-rw-r--r--lld/test/ELF/aarch64-fpic-got.s41
1 files changed, 29 insertions, 12 deletions
diff --git a/lld/test/ELF/aarch64-fpic-got.s b/lld/test/ELF/aarch64-fpic-got.s
index 48bd0e2..a77fd8f 100644
--- a/lld/test/ELF/aarch64-fpic-got.s
+++ b/lld/test/ELF/aarch64-fpic-got.s
@@ -1,26 +1,43 @@
# REQUIRES: aarch64
-# RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux %s -o %t.o
-# RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux %p/Inputs/shared.s -o %t-lib.o
-# RUN: ld.lld -shared %t-lib.o -soname t-lib.so -o %t-lib.so
+# RUN: rm -rf %t && split-file %s %t && cd %t
-# RUN: ld.lld %t-lib.so %t.o -o %t.exe
-# RUN: llvm-readobj -r %t.exe | FileCheck --check-prefix=RELOC %s
-# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t.exe | FileCheck --check-prefix=DIS %s
+# RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux %p/Inputs/shared.s -o lib.o
+# RUN: ld.lld -shared lib.o -soname lib.so -o lib.so
## Checks if got access to dynamic objects is done through a got relative
## dynamic relocation and not using plt relative (R_AARCH64_JUMP_SLOT).
# RELOC: .rela.dyn {
-# RELOC-NEXT: 0x220320 R_AARCH64_GLOB_DAT bar 0x0
+# RELOC-NEXT: 0x220318 R_AARCH64_GLOB_DAT bar 0x0
# RELOC-NEXT: }
-## page(0x220320) - page(0x210000) = 65536
-## page(0x220320) & 0xff8 = 800
-# DIS: <_start>:
-# DIS-NEXT: 210258: adrp x0, 0x220000
-# DIS-NEXT: 21025c: ldr x0, [x0, #800]
+#--- small.s
+
+# RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux small.s -o small.o
+# RUN: ld.lld lib.so small.o -o small
+# RUN: llvm-readobj -r small | FileCheck --check-prefix=RELOC %s
+# RUN: llvm-objdump -d --no-show-raw-insn small | FileCheck --check-prefix=DIS-SMALL %s
+
+## page(0x220318) & 0xff8 = 0x318
+# DIS-SMALL: <_start>:
+# DIS-SMALL-NEXT: adrp x0, 0x220000
+# DIS-SMALL-NEXT: ldr x0, [x0, #0x318]
.globl _start
_start:
adrp x0, :got:bar
ldr x0, [x0, :got_lo12:bar]
+
+#--- tiny.s
+
+# RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux tiny.s -o tiny.o
+# RUN: ld.lld lib.so tiny.o -o tiny
+# RUN: llvm-readobj -r tiny | FileCheck --check-prefix=RELOC %s
+# RUN: llvm-objdump -d --no-show-raw-insn tiny | FileCheck --check-prefix=DIS-TINY %s
+
+# DIS-TINY: <_start>:
+# DIS-TINY-NEXT: ldr x0, 0x220318
+
+.globl _start
+_start:
+ ldr x0, :got:bar