Skip to content

Commit 61d5425

Browse files
yavtukyota9
authored andcommitted
[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
1 parent b8d4fe0 commit 61d5425

File tree

2 files changed

+60
-37
lines changed

2 files changed

+60
-37
lines changed

bolt/test/AArch64/r_aarch64_prelxx.s

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// This test checks processing of R_AARCH64_PREL64/32/16 relocations
2+
// S + A - P = Value
3+
// S = P - A + Value
4+
5+
// mul(D1,0x100) == << 8
6+
// mul(D2,0x10000) == << 16
7+
// mul(D3,0x1000000) == << 24
8+
9+
// REQUIRES: system-linux
10+
11+
// RUN: %clang %cflags -nostartfiles -nostdlib %s -o %t.exe -mlittle-endian \
12+
// RUN: -Wl,-q -Wl,-z,max-page-size=4
13+
// RUN: llvm-readelf -Wa %t.exe | FileCheck %s -check-prefix=CHECKPREL
14+
15+
// CHECKPREL: R_AARCH64_PREL16 {{.*}} .dummy + 0
16+
// CHECKPREL-NEXT: R_AARCH64_PREL32 {{.*}} _start + 4
17+
// CHECKPREL-NEXT: R_AARCH64_PREL64 {{.*}} _start + 8
18+
19+
// RUN: llvm-bolt %t.exe -o %t.bolt
20+
// RUN: llvm-objdump -D %t.bolt | FileCheck %s --check-prefix=CHECKPREL32
21+
22+
// CHECKPREL32: [[#%x,DATATABLEADDR:]] <datatable>:
23+
// CHECKPREL32-NEXT: 00:
24+
// CHECKPREL32-NEXT: 04: [[#%x,D0:]] [[#%x,D1:]] [[#%x,D2:]] [[#%x,D3:]]
25+
26+
// 4 is offset in datatable
27+
// 8 is addend
28+
// CHECKPREL32: [[#DATATABLEADDR + 4 - 8 + D0 + mul(D1,0x100) + mul(D2,0x10000) + mul(D3,0x1000000)]] <_start>:
29+
30+
// RUN: llvm-objdump -D %t.bolt | FileCheck %s --check-prefix=CHECKPREL64
31+
// CHECKPREL64: [[#%x,DATATABLEADDR:]] <datatable>:
32+
// CHECKPREL64-NEXT: 00:
33+
// CHECKPREL64-NEXT: 04:
34+
// CHECKPREL64-NEXT: 08: [[#%x,D0:]] [[#%x,D1:]] [[#%x,D2:]] [[#%x,D3:]]
35+
// CHECKPREL64-NEXT: 0c: 00 00 00 00
36+
37+
// 8 is offset in datatable
38+
// 12 is addend
39+
// CHECKPREL64: [[#DATATABLEADDR + 8 - 12 + D0 + mul(D1,0x100) + mul(D2,0x10000) + mul(D3,0x1000000)]] <_start>:
40+
41+
.section .text
42+
.align 4
43+
.globl _start
44+
.type _start, %function
45+
_start:
46+
adr x0, datatable
47+
mov x0, #0
48+
ret
49+
50+
.section .dummy, "da"
51+
dummy:
52+
.word 0
53+
54+
.data
55+
.align 8
56+
datatable:
57+
.hword dummy - datatable
58+
.align 2
59+
.word _start - datatable
60+
.xword _start - datatable

bolt/test/runtime/AArch64/r_aarch64_prelxx.s

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)