summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2018-04-03 23:19:20 +0000
committerLang Hames <lhames@gmail.com>2018-04-03 23:19:20 +0000
commitb92b10f3ec4897c07655aab0999817ba503ebf71 (patch)
tree56a5222437d06724ae964114f26491613d36bf22
parent20b342371539920da0a4fff9e9f7820cb5759fd7 (diff)
downloadbcm5719-llvm-b92b10f3ec4897c07655aab0999817ba503ebf71.tar.gz
bcm5719-llvm-b92b10f3ec4897c07655aab0999817ba503ebf71.zip
[RuntimeDyld][AArch64] Add some error pluming / generation to catch unhandled
relocation types on AArch64. llvm-svn: 329133
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h36
1 files changed, 32 insertions, 4 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h
index 31cedffa15b..6cee7278524 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h
@@ -13,6 +13,8 @@
#include "../RuntimeDyldMachO.h"
#include "llvm/Support/Endian.h"
+#include <sstream>
+
#define DEBUG_TYPE "dyld"
namespace llvm {
@@ -32,7 +34,7 @@ public:
unsigned getStubAlignment() override { return 8; }
/// Extract the addend encoded in the instruction / memory location.
- int64_t decodeAddend(const RelocationEntry &RE) const {
+ Expected<int64_t> decodeAddend(const RelocationEntry &RE) const {
const SectionEntry &Section = Sections[RE.SectionID];
uint8_t *LocalAddress = Section.getAddressWithOffset(RE.Offset);
unsigned NumBytes = 1 << RE.Size;
@@ -40,9 +42,15 @@ public:
// Verify that the relocation has the correct size and alignment.
switch (RE.RelType) {
default:
- llvm_unreachable("Unsupported relocation type!");
+ return make_error<StringError>((std::ostringstream()
+ << "Unsupported relocation type: "
+ << getRelocName(RE.RelType)).str(),
+ inconvertibleErrorCode());
case MachO::ARM64_RELOC_UNSIGNED:
- assert((NumBytes == 4 || NumBytes == 8) && "Invalid relocation size.");
+ if (NumBytes != 4 && NumBytes != 8)
+ return make_error<StringError>("Invalid relocation size for "
+ "ARM64_RELOC_UNSIGNED",
+ inconvertibleErrorCode());
break;
case MachO::ARM64_RELOC_BRANCH26:
case MachO::ARM64_RELOC_PAGE21:
@@ -282,7 +290,10 @@ public:
return processSubtractRelocation(SectionID, RelI, Obj, ObjSectionToID);
RelocationEntry RE(getRelocationEntry(SectionID, Obj, RelI));
- RE.Addend = decodeAddend(RE);
+ if (auto Addend = decodeAddend(RE))
+ RE.Addend = *Addend;
+ else
+ return Addend.takeError();
assert((ExplicitAddend == 0 || RE.Addend == 0) && "Relocation has "\
"ARM64_RELOC_ADDEND and embedded addend in the instruction.");
@@ -463,6 +474,23 @@ private:
return ++RelI;
}
+ static const char *getRelocName(uint32_t RelocType) {
+ switch (RelocType) {
+ case MachO::ARM64_RELOC_UNSIGNED: return "ARM64_RELOC_UNSIGNED";
+ case MachO::ARM64_RELOC_SUBTRACTOR: return "ARM64_RELOC_SUBTRACTOR";
+ case MachO::ARM64_RELOC_BRANCH26: return "ARM64_RELOC_BRANCH26";
+ case MachO::ARM64_RELOC_PAGE21: return "ARM64_RELOC_PAGE21";
+ case MachO::ARM64_RELOC_PAGEOFF12: return "ARM64_RELOC_PAGEOFF12";
+ case MachO::ARM64_RELOC_GOT_LOAD_PAGE21: return "ARM64_RELOC_GOT_LOAD_PAGE21";
+ case MachO::ARM64_RELOC_GOT_LOAD_PAGEOFF12: return "ARM64_RELOC_GOT_LOAD_PAGEOFF12";
+ case MachO::ARM64_RELOC_POINTER_TO_GOT: return "ARM64_RELOC_POINTER_TO_GOT";
+ case MachO::ARM64_RELOC_TLVP_LOAD_PAGE21: return "ARM64_RELOC_TLVP_LOAD_PAGE21";
+ case MachO::ARM64_RELOC_TLVP_LOAD_PAGEOFF12: return "ARM64_RELOC_TLVP_LOAD_PAGEOFF12";
+ case MachO::ARM64_RELOC_ADDEND: return "ARM64_RELOC_ADDEND";
+ }
+ return "Unrecognized arm64 addend";
+ }
+
};
}
OpenPOWER on IntegriCloud