Skip to content

Commit 3073a3a

Browse files
committed
[RelocationResolver] Support R_AARCH64_PREL32
Code from D83800 by Yichao Yu
1 parent b922004 commit 3073a3a

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

llvm/lib/Object/RelocationResolver.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ static bool supportsAArch64(uint64_t Type) {
6262
switch (Type) {
6363
case ELF::R_AARCH64_ABS32:
6464
case ELF::R_AARCH64_ABS64:
65+
case ELF::R_AARCH64_PREL32:
66+
case ELF::R_AARCH64_PREL64:
6567
return true;
6668
default:
6769
return false;
@@ -74,6 +76,10 @@ static uint64_t resolveAArch64(RelocationRef R, uint64_t S, uint64_t A) {
7476
return (S + getELFAddend(R)) & 0xFFFFFFFF;
7577
case ELF::R_AARCH64_ABS64:
7678
return S + getELFAddend(R);
79+
case ELF::R_AARCH64_PREL32:
80+
return (S + getELFAddend(R) - R.getOffset()) & 0xFFFFFFFF;
81+
case ELF::R_AARCH64_PREL64:
82+
return S + getELFAddend(R) - R.getOffset();
7783
default:
7884
llvm_unreachable("Invalid relocation type");
7985
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
; RUN: llc -filetype=obj -mtriple=aarch64 %s -o %t.o
2+
; RUN: llvm-readobj -r %t.o | FileCheck %s --check-prefix=REL32
3+
; RUN: llvm-dwarfdump --eh-frame %t.o 2>&1 | FileCheck %s
4+
5+
; REL32: R_AARCH64_PREL32 .text 0x0
6+
; REL32-NEXT: R_AARCH64_PREL32 .text 0x4
7+
8+
; CHECK-NOT: warning:
9+
; CHECK: FDE cie=00000000 pc=00000000...00000004
10+
;; TODO Take relocation into consideration
11+
; CHECK: FDE cie=00000000 pc=00000000...00000004
12+
13+
define void @foo() {
14+
entry:
15+
ret void
16+
}
17+
18+
define void @bar() {
19+
entry:
20+
ret void
21+
}

0 commit comments

Comments
 (0)