summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/RelocationResolver.cpp
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2019-09-10 12:31:40 +0000
committerMartin Storsjo <martin@martin.st>2019-09-10 12:31:40 +0000
commit5d269590395229743b3c21f1d74dc3912dc680fa (patch)
tree4444e1dff7a51e201d74bf3fdb431fca8f10756e /llvm/lib/Object/RelocationResolver.cpp
parent1eda21e214f2fd5a7d54bec854e4cd83b2800d41 (diff)
downloadbcm5719-llvm-5d269590395229743b3c21f1d74dc3912dc680fa.tar.gz
bcm5719-llvm-5d269590395229743b3c21f1d74dc3912dc680fa.zip
[Object] Implement relocation resolver for COFF ARM/ARM64
Adding testscases for this via llvm-dwarfdump. Also add testcases for the existing resolver support for X86. Differential Revision: https://reviews.llvm.org/D67340 llvm-svn: 371515
Diffstat (limited to 'llvm/lib/Object/RelocationResolver.cpp')
-rw-r--r--llvm/lib/Object/RelocationResolver.cpp55
1 files changed, 53 insertions, 2 deletions
diff --git a/llvm/lib/Object/RelocationResolver.cpp b/llvm/lib/Object/RelocationResolver.cpp
index 7df4f8d2b90..90ae4fa4a54 100644
--- a/llvm/lib/Object/RelocationResolver.cpp
+++ b/llvm/lib/Object/RelocationResolver.cpp
@@ -426,6 +426,47 @@ static uint64_t resolveCOFFX86_64(RelocationRef R, uint64_t S, uint64_t A) {
}
}
+static bool supportsCOFFARM(uint64_t Type) {
+ switch (Type) {
+ case COFF::IMAGE_REL_ARM_SECREL:
+ case COFF::IMAGE_REL_ARM_ADDR32:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static uint64_t resolveCOFFARM(RelocationRef R, uint64_t S, uint64_t A) {
+ switch (R.getType()) {
+ case COFF::IMAGE_REL_ARM_SECREL:
+ case COFF::IMAGE_REL_ARM_ADDR32:
+ return (S + A) & 0xFFFFFFFF;
+ default:
+ llvm_unreachable("Invalid relocation type");
+ }
+}
+
+static bool supportsCOFFARM64(uint64_t Type) {
+ switch (Type) {
+ case COFF::IMAGE_REL_ARM64_SECREL:
+ case COFF::IMAGE_REL_ARM64_ADDR64:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static uint64_t resolveCOFFARM64(RelocationRef R, uint64_t S, uint64_t A) {
+ switch (R.getType()) {
+ case COFF::IMAGE_REL_ARM64_SECREL:
+ return (S + A) & 0xFFFFFFFF;
+ case COFF::IMAGE_REL_ARM64_ADDR64:
+ return S + A;
+ default:
+ llvm_unreachable("Invalid relocation type");
+ }
+}
+
static bool supportsMachOX86_64(uint64_t Type) {
return Type == MachO::X86_64_RELOC_UNSIGNED;
}
@@ -478,9 +519,19 @@ static uint64_t resolveWasm32(RelocationRef R, uint64_t S, uint64_t A) {
std::pair<bool (*)(uint64_t), RelocationResolver>
getRelocationResolver(const ObjectFile &Obj) {
if (Obj.isCOFF()) {
- if (Obj.getBytesInAddress() == 8)
+ switch (Obj.getArch()) {
+ case Triple::x86_64:
return {supportsCOFFX86_64, resolveCOFFX86_64};
- return {supportsCOFFX86, resolveCOFFX86};
+ case Triple::x86:
+ return {supportsCOFFX86, resolveCOFFX86};
+ case Triple::arm:
+ case Triple::thumb:
+ return {supportsCOFFARM, resolveCOFFARM};
+ case Triple::aarch64:
+ return {supportsCOFFARM64, resolveCOFFARM64};
+ default:
+ return {nullptr, nullptr};
+ }
} else if (Obj.isELF()) {
if (Obj.getBytesInAddress() == 8) {
switch (Obj.getArch()) {
OpenPOWER on IntegriCloud