[PATCH] D126467: [JITLink][ELF/AARCH64][NFC] Add testcases for Branch26/Page21/PageOffset21

Sunho Kim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 26 07:17:39 PDT 2022


sunho created this revision.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
sunho requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Add test cases for Branch26/Page21/PageOffset21 using jitlink-check.


https://reviews.llvm.org/D126467

Files:
  llvm/test/ExecutionEngine/JITLink/AArch64/ELF_aarch64_relocations.s


Index: llvm/test/ExecutionEngine/JITLink/AArch64/ELF_aarch64_relocations.s
===================================================================
--- /dev/null
+++ llvm/test/ExecutionEngine/JITLink/AArch64/ELF_aarch64_relocations.s
@@ -0,0 +1,54 @@
+# RUN: rm -rf %t && mkdir -p %t
+# RUN: llvm-mc -triple=aarch64-unknown-linux-gnu -relax-relocations=false -position-independent -filetype=obj -o %t/elf_reloc.o %s
+# RUN: llvm-jitlink -noexec -check %s %t/elf_reloc.o
+
+        .text
+
+        .globl  main
+        .p2align  2
+        .type main, at function
+main:
+        ret
+
+        .size   main, .-main
+
+# Check R_AARCH64_CALL26 relocation of a local function call
+#
+# jitlink-check: decode_operand(local_func_call26, 0)[25:0] = (local_func - local_func_call26)[27:2]
+        .globl  local_func
+        .type	local_func, at function
+local_func:
+        ret
+        .size   local_func, .-local_func
+
+        .globl  local_func_call26
+local_func_call26:
+        bl	local_func
+        .size   local_func_call26, .-local_func_call26
+
+
+# Check R_AARCH64_ADR_PREL_PG_HI21 / R_AARCH64_ADD_ABS_LO12_NC relocation of a local symbol
+#
+# For the ADR_PREL_PG_HI21/ADRP instruction we have the 21-bit delta to the 4k page
+# containing the global.
+#
+# jitlink-check: decode_operand(test_adr_prel, 1) = (named_data - test_adr_prel)[32:12]
+# jitlink-check: decode_operand(test_add_abs_lo12, 2) = (named_data + 0)[11:0]
+        .globl  test_adr_prel
+        .p2align  2
+test_adr_prel:
+        adrp	x0, named_data
+        .size test_adr_prel, .-test_adr_prel
+
+        .globl  test_add_abs_lo12
+test_add_abs_lo12:
+        add	x0, x0, :lo12:named_data
+        .size test_add_abs_lo12, .-test_add_abs_lo12
+
+        .globl  named_data
+        .p2align  4
+        .type   named_data, at object
+named_data:
+        .quad   0x2222222222222222
+        .quad   0x3333333333333333
+        .size   named_data, .-named_data


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126467.432274.patch
Type: text/x-patch
Size: 1935 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220526/718173d0/attachment.bin>


More information about the llvm-commits mailing list