Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/bolt
diff options
context:
space:
mode:
authorAlexey Moksyakov <alexey.moksyakov@huawei.com>2022-04-28 23:34:03 +0300
committerVladislav Khmelevsky <och95@yandex.ru>2022-04-28 23:52:24 +0300
commit61d54259ed2bb7e67c19f658153362d117f7079e (patch)
tree085920eaab38ef14854ac0e6a352cd42a5984ea0 /bolt
parentb8d4fe0f0aeac4d2f61161b7212f1b028b56a2ad (diff)
[BOLT] Fix r_aarch64_prelxx test
The relocation value is calculated using the formula S + A - P, the verification of the value is performed by inversely calculating the location address Reviewed By: Amir Differential Revision: https://reviews.llvm.org/D124270
Diffstat (limited to 'bolt')
-rw-r--r--bolt/test/AArch64/r_aarch64_prelxx.s60
-rw-r--r--bolt/test/runtime/AArch64/r_aarch64_prelxx.s37
2 files changed, 60 insertions, 37 deletions
diff --git a/bolt/test/AArch64/r_aarch64_prelxx.s b/bolt/test/AArch64/r_aarch64_prelxx.s
new file mode 100644
index 000000000000..fd99141a6ddd
--- /dev/null
+++ b/bolt/test/AArch64/r_aarch64_prelxx.s
@@ -0,0 +1,60 @@
+// This test checks processing of R_AARCH64_PREL64/32/16 relocations
+// S + A - P = Value
+// S = P - A + Value
+
+// mul(D1,0x100) == << 8
+// mul(D2,0x10000) == << 16
+// mul(D3,0x1000000) == << 24
+
+// REQUIRES: system-linux
+
+// RUN: %clang %cflags -nostartfiles -nostdlib %s -o %t.exe -mlittle-endian \
+// RUN: -Wl,-q -Wl,-z,max-page-size=4
+// RUN: llvm-readelf -Wa %t.exe | FileCheck %s -check-prefix=CHECKPREL
+
+// CHECKPREL: R_AARCH64_PREL16 {{.*}} .dummy + 0
+// CHECKPREL-NEXT: R_AARCH64_PREL32 {{.*}} _start + 4
+// CHECKPREL-NEXT: R_AARCH64_PREL64 {{.*}} _start + 8
+
+// RUN: llvm-bolt %t.exe -o %t.bolt
+// RUN: llvm-objdump -D %t.bolt | FileCheck %s --check-prefix=CHECKPREL32
+
+// CHECKPREL32: [[#%x,DATATABLEADDR:]] <datatable>:
+// CHECKPREL32-NEXT: 00:
+// CHECKPREL32-NEXT: 04: [[#%x,D0:]] [[#%x,D1:]] [[#%x,D2:]] [[#%x,D3:]]
+
+// 4 is offset in datatable
+// 8 is addend
+// CHECKPREL32: [[#DATATABLEADDR + 4 - 8 + D0 + mul(D1,0x100) + mul(D2,0x10000) + mul(D3,0x1000000)]] <_start>:
+
+// RUN: llvm-objdump -D %t.bolt | FileCheck %s --check-prefix=CHECKPREL64
+// CHECKPREL64: [[#%x,DATATABLEADDR:]] <datatable>:
+// CHECKPREL64-NEXT: 00:
+// CHECKPREL64-NEXT: 04:
+// CHECKPREL64-NEXT: 08: [[#%x,D0:]] [[#%x,D1:]] [[#%x,D2:]] [[#%x,D3:]]
+// CHECKPREL64-NEXT: 0c: 00 00 00 00
+
+// 8 is offset in datatable
+// 12 is addend
+// CHECKPREL64: [[#DATATABLEADDR + 8 - 12 + D0 + mul(D1,0x100) + mul(D2,0x10000) + mul(D3,0x1000000)]] <_start>:
+
+ .section .text
+ .align 4
+ .globl _start
+ .type _start, %function
+_start:
+ adr x0, datatable
+ mov x0, #0
+ ret
+
+.section .dummy, "da"
+dummy:
+ .word 0
+
+ .data
+ .align 8
+datatable:
+ .hword dummy - datatable
+ .align 2
+ .word _start - datatable
+ .xword _start - datatable
diff --git a/bolt/test/runtime/AArch64/r_aarch64_prelxx.s b/bolt/test/runtime/AArch64/r_aarch64_prelxx.s
deleted file mode 100644
index 89bc6ccf667f..000000000000
--- a/bolt/test/runtime/AArch64/r_aarch64_prelxx.s
+++ /dev/null
@@ -1,37 +0,0 @@
-// This test checks processing of R_AARCH64_PREL64/32/16 relocations
-
-// RUN: %clang %cflags -nostartfiles -nostdlib %s -o %t.exe -Wl,-q \
-// RUN: -Wl,-z,max-page-size=4
-// RUN: llvm-readelf -Wa %t.exe | FileCheck %s -check-prefix=CHECKPREL
-
-// CHECKPREL: R_AARCH64_PREL16 {{.*}} .dummy + 0
-// CHECKPREL-NEXT: R_AARCH64_PREL32 {{.*}} _start + 4
-// CHECKPREL-NEXT: R_AARCH64_PREL64 {{.*}} _start + 8
-
-// RUN: llvm-bolt %t.exe -o %t.bolt
-// RUN: llvm-readobj -S --section-data %t.bolt | FileCheck %s
-
-// CHECK: Name: .data
-// CHECK: SectionData (
-// CHECK: 0000: FCFF0000 44FF3F00 44FF3F00 00000000
-// CHECK: )
-
- .text
- .align 4
- .globl _start
- .type _start, %function
-_start:
- adr x0, datatable
- mov x0, #0
- ret
-
-.section .dummy, "da"
-dummy:
- .word 0
-
-.section .data
-datatable:
- .hword dummy - datatable
- .align 2
- .word _start - datatable
- .xword _start - datatable