[llvm] r213687 - [RuntimeDyld][MachO][AArch64] Add assertion to check for duplicate addend definition.
Juergen Ributzka
juergen at apple.com
Tue Jul 22 14:42:49 PDT 2014
Author: ributzka
Date: Tue Jul 22 16:42:49 2014
New Revision: 213687
URL: http://llvm.org/viewvc/llvm-project?rev=213687&view=rev
Log:
[RuntimeDyld][MachO][AArch64] Add assertion to check for duplicate addend definition.
In MachO for AArch64 it is possible to have an explicit addend defined by
the ARM64_RELOC_ADDEND relocation or having an addend encoded within the
instruction. Only one of them are allowed per relocation.
Modified:
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h?rev=213687&r1=213686&r2=213687&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h Tue Jul 22 16:42:49 2014
@@ -41,16 +41,14 @@ public:
// addend for the following relocation. If found: (1) store the associated
// addend, (2) consume the next relocation, and (3) use the stored addend to
// override the addend.
- bool HasExplicitAddend = false;
int64_t ExplicitAddend = 0;
if (Obj.getAnyRelocationType(RelInfo) == MachO::ARM64_RELOC_ADDEND) {
assert(!Obj.getPlainRelocationExternal(RelInfo));
assert(!Obj.getAnyRelocationPCRel(RelInfo));
assert(Obj.getAnyRelocationLength(RelInfo) == 2);
- HasExplicitAddend = true;
int64_t RawAddend = Obj.getPlainRelocationSymbolNum(RelInfo);
// Sign-extend the 24-bit to 64-bit.
- ExplicitAddend = (RawAddend << 40) >> 40;
+ ExplicitAddend = SignExtend64(RawAddend, 24);
++RelI;
RelInfo = Obj.getRelocation(RelI->getRawDataRefImpl());
}
@@ -59,7 +57,9 @@ public:
RelocationValueRef Value(
getRelocationValueRef(ObjImg, RelI, RE, ObjSectionToID, Symbols));
- if (HasExplicitAddend) {
+ assert((ExplicitAddend == 0 || RE.Addend == 0) && "Relocation has "\
+ "ARM64_RELOC_ADDEND and embedded addend in the instruction.");
+ if (ExplicitAddend) {
RE.Addend = ExplicitAddend;
Value.Addend = ExplicitAddend;
}
More information about the llvm-commits
mailing list