diff options
author | Fangrui Song <i@maskray.me> | 2020-07-17 23:49:15 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2020-07-18 15:22:02 -0700 |
commit | a1f2fd11bde3efe2dd145163be1a7df15d0800d1 (patch) | |
tree | 78a699718309874260ab6f8db2665decfb9cb491 | |
parent | 094d6386ec0478076218303a756edda8a63d7c55 (diff) | |
download | llvm-a1f2fd11bde3efe2dd145163be1a7df15d0800d1.zip llvm-a1f2fd11bde3efe2dd145163be1a7df15d0800d1.tar.gz llvm-a1f2fd11bde3efe2dd145163be1a7df15d0800d1.tar.bz2 |
[RelocationResolver] Support R_AARCH64_PREL32
Code from D83800 by Yichao Yu
(cherry picked from commit 3073a3aa1ef1ce8c9cac9b97a8e5905dd8779e16)
-rw-r--r-- | llvm/lib/Object/RelocationResolver.cpp | 6 | ||||
-rw-r--r-- | llvm/test/DebugInfo/AArch64/eh-frame.ll | 21 |
2 files changed, 27 insertions, 0 deletions
diff --git a/llvm/lib/Object/RelocationResolver.cpp b/llvm/lib/Object/RelocationResolver.cpp index 0058d12..ad7a50d1 100644 --- a/llvm/lib/Object/RelocationResolver.cpp +++ b/llvm/lib/Object/RelocationResolver.cpp @@ -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"); } diff --git a/llvm/test/DebugInfo/AArch64/eh-frame.ll b/llvm/test/DebugInfo/AArch64/eh-frame.ll new file mode 100644 index 0000000..9651159 --- /dev/null +++ b/llvm/test/DebugInfo/AArch64/eh-frame.ll @@ -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 +} |