summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorJuergen Ributzka <juergen@apple.com>2014-07-29 19:57:11 +0000
committerJuergen Ributzka <juergen@apple.com>2014-07-29 19:57:11 +0000
commitfbd40c36eb6ac8cd80f1e7841fae5e5da5d0c92d (patch)
treeb420dadce6695b521e42a9fd0dbc229982fdb776 /llvm/lib
parent2056b38faca244fef034c920081d27951f8c364f (diff)
downloadbcm5719-llvm-fbd40c36eb6ac8cd80f1e7841fae5e5da5d0c92d.tar.gz
bcm5719-llvm-fbd40c36eb6ac8cd80f1e7841fae5e5da5d0c92d.zip
[RuntimeDyld][AArch64] Make encode/decodeAddend more typesafe by using the relocation enum type. NFCI.
llvm-svn: 214204
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp2
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h5
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h14
3 files changed, 12 insertions, 9 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
index 009409a1936..920b999fa08 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
@@ -28,7 +28,7 @@ using namespace llvm::object;
namespace llvm {
int64_t RuntimeDyldMachO::decodeAddend(uint8_t *LocalAddress, unsigned NumBytes,
- uint32_t RelType) const {
+ MachO::RelocationInfoType) const {
int64_t Addend = 0;
memcpy(&Addend, LocalAddress, NumBytes);
return Addend;
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h
index abc98944a82..7450f1141e1 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h
@@ -54,7 +54,7 @@ protected:
/// Extract the addend encoded in the instruction.
int64_t decodeAddend(uint8_t *LocalAddress, unsigned NumBytes,
- uint32_t RelType) const;
+ MachO::RelocationInfoType RelType) const;
/// Construct a RelocationValueRef representing the relocation target.
/// For Symbols in known sections, this will return a RelocationValueRef
@@ -138,7 +138,8 @@ protected:
RI->getOffset(Offset);
uint8_t *LocalAddress = Section.Address + Offset;
unsigned NumBytes = 1 << Size;
- uint32_t RelType = Obj.getAnyRelocationType(RelInfo);
+ MachO::RelocationInfoType RelType =
+ static_cast<MachO::RelocationInfoType>(Obj.getAnyRelocationType(RelInfo));
int64_t Addend = impl().decodeAddend(LocalAddress, NumBytes, RelType);
return RelocationEntry(SectionID, Offset, RelType, Addend, IsPCRel, Size);
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h
index 11b6a1392c0..adc3adbba25 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h
@@ -28,7 +28,7 @@ public:
/// Extract the addend encoded in the instruction / memory location.
int64_t decodeAddend(uint8_t *LocalAddress, unsigned NumBytes,
- uint32_t RelType) const {
+ MachO::RelocationInfoType RelType) const {
int64_t Addend = 0;
// Verify that the relocation has the correct size and alignment.
switch (RelType) {
@@ -120,7 +120,7 @@ public:
}
/// Extract the addend encoded in the instruction.
- void encodeAddend(uint8_t *LocalAddress, uint32_t RelType,
+ void encodeAddend(uint8_t *LocalAddress, MachO::RelocationInfoType RelType,
int64_t Addend) const {
// Verify that the relocation has the correct alignment.
switch (RelType) {
@@ -285,8 +285,10 @@ public:
const SectionEntry &Section = Sections[RE.SectionID];
uint8_t *LocalAddress = Section.Address + RE.Offset;
+ MachO::RelocationInfoType RelType =
+ static_cast<MachO::RelocationInfoType>(RE.RelType);
- switch (RE.RelType) {
+ switch (RelType) {
default:
llvm_unreachable("Invalid relocation type!");
case MachO::ARM64_RELOC_UNSIGNED: {
@@ -304,7 +306,7 @@ public:
// Check if branch is in range.
uint64_t FinalAddress = Section.LoadAddress + RE.Offset;
int64_t PCRelVal = Value - FinalAddress + RE.Addend;
- encodeAddend(LocalAddress, RE.RelType, PCRelVal);
+ encodeAddend(LocalAddress, RelType, PCRelVal);
break;
}
case MachO::ARM64_RELOC_GOT_LOAD_PAGE21:
@@ -314,7 +316,7 @@ public:
uint64_t FinalAddress = Section.LoadAddress + RE.Offset;
int64_t PCRelVal =
((Value + RE.Addend) & (-4096)) - (FinalAddress & (-4096));
- encodeAddend(LocalAddress, RE.RelType, PCRelVal);
+ encodeAddend(LocalAddress, RelType, PCRelVal);
break;
}
case MachO::ARM64_RELOC_GOT_LOAD_PAGEOFF12:
@@ -324,7 +326,7 @@ public:
Value += RE.Addend;
// Mask out the page address and only use the lower 12 bits.
Value &= 0xFFF;
- encodeAddend(LocalAddress, RE.RelType, Value);
+ encodeAddend(LocalAddress, RelType, Value);
break;
}
case MachO::ARM64_RELOC_SUBTRACTOR:
OpenPOWER on IntegriCloud