1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

[RelocationResolver] Support R_AARCH64_PREL32

Code from D83800 by Yichao Yu
This commit is contained in:
Fangrui Song 2020-07-17 23:49:15 -07:00
parent 07079947f8
commit 6d196aebc6
2 changed files with 27 additions and 0 deletions

View File

@ -62,6 +62,8 @@ static bool supportsAArch64(uint64_t Type) {
switch (Type) {
case ELF::R_AARCH64_ABS32:
case ELF::R_AARCH64_ABS64:
case ELF::R_AARCH64_PREL32:
case ELF::R_AARCH64_PREL64:
return true;
default:
return false;
@ -74,6 +76,10 @@ static uint64_t resolveAArch64(RelocationRef R, uint64_t S, uint64_t A) {
return (S + getELFAddend(R)) & 0xFFFFFFFF;
case ELF::R_AARCH64_ABS64:
return S + getELFAddend(R);
case ELF::R_AARCH64_PREL32:
return (S + getELFAddend(R) - R.getOffset()) & 0xFFFFFFFF;
case ELF::R_AARCH64_PREL64:
return S + getELFAddend(R) - R.getOffset();
default:
llvm_unreachable("Invalid relocation type");
}

View File

@ -0,0 +1,21 @@
; RUN: llc -filetype=obj -mtriple=aarch64 %s -o %t.o
; RUN: llvm-readobj -r %t.o | FileCheck %s --check-prefix=REL32
; RUN: llvm-dwarfdump --eh-frame %t.o 2>&1 | FileCheck %s
; REL32: R_AARCH64_PREL32 .text 0x0
; REL32-NEXT: R_AARCH64_PREL32 .text 0x4
; CHECK-NOT: warning:
; CHECK: FDE cie=00000000 pc=00000000...00000004
;; TODO Take relocation into consideration
; CHECK: FDE cie=00000000 pc=00000000...00000004
define void @foo() {
entry:
ret void
}
define void @bar() {
entry:
ret void
}