1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[MCJIT] Rewrite RuntimeDyldMachO and its derived classes to use the 'Offset'

field of RelocationValueRef, rather than the 'Addend' field.

This is consistent with RuntimeDyldELF's use of RelocationValueRef, and more
consistent with the semantics of the data being stored (the offset from the
start of a section or symbol).

llvm-svn: 217328
This commit is contained in:
Lang Hames 2014-09-07 04:03:32 +00:00
parent a31589cae0
commit 31f4910c56
7 changed files with 18 additions and 18 deletions

View File

@ -883,7 +883,7 @@ void RuntimeDyldCheckerImpl::registerStubMap(
for (auto &GSTEntry : getRTDyld().GlobalSymbolTable) { for (auto &GSTEntry : getRTDyld().GlobalSymbolTable) {
if (GSTEntry.second.first == StubMapEntry.first.SectionID && if (GSTEntry.second.first == StubMapEntry.first.SectionID &&
GSTEntry.second.second == GSTEntry.second.second ==
static_cast<uint64_t>(StubMapEntry.first.Addend)) { static_cast<uint64_t>(StubMapEntry.first.Offset)) {
SymbolName = GSTEntry.first(); SymbolName = GSTEntry.first();
break; break;
} }

View File

@ -1034,11 +1034,11 @@ relocation_iterator RuntimeDyldELF::processRelocationRef(
createStubFunction(Section.Address + Section.StubOffset); createStubFunction(Section.Address + Section.StubOffset);
RelocationEntry REmovz_g3(SectionID, StubTargetAddr - Section.Address, RelocationEntry REmovz_g3(SectionID, StubTargetAddr - Section.Address,
ELF::R_AARCH64_MOVW_UABS_G3, Value.Addend); ELF::R_AARCH64_MOVW_UABS_G3, Value.Offset + Addend);
RelocationEntry REmovk_g2(SectionID, StubTargetAddr - Section.Address + 4, RelocationEntry REmovk_g2(SectionID, StubTargetAddr - Section.Address + 4,
ELF::R_AARCH64_MOVW_UABS_G2_NC, Value.Addend); ELF::R_AARCH64_MOVW_UABS_G2_NC, Value.Offset + Addend);
RelocationEntry REmovk_g1(SectionID, StubTargetAddr - Section.Address + 8, RelocationEntry REmovk_g1(SectionID, StubTargetAddr - Section.Address + 8,
ELF::R_AARCH64_MOVW_UABS_G1_NC, Value.Addend); ELF::R_AARCH64_MOVW_UABS_G1_NC, Value.Offset + Addend);
RelocationEntry REmovk_g0(SectionID, RelocationEntry REmovk_g0(SectionID,
StubTargetAddr - Section.Address + 12, StubTargetAddr - Section.Address + 12,
ELF::R_AARCH64_MOVW_UABS_G0_NC, Value.Addend); ELF::R_AARCH64_MOVW_UABS_G0_NC, Value.Addend);

View File

@ -53,15 +53,15 @@ RelocationValueRef RuntimeDyldMachO::getRelocationValueRef(
SymbolTableMap::const_iterator SI = Symbols.find(TargetName.data()); SymbolTableMap::const_iterator SI = Symbols.find(TargetName.data());
if (SI != Symbols.end()) { if (SI != Symbols.end()) {
Value.SectionID = SI->second.first; Value.SectionID = SI->second.first;
Value.Addend = SI->second.second + RE.Addend; Value.Offset = SI->second.second + RE.Addend;
} else { } else {
SI = GlobalSymbolTable.find(TargetName.data()); SI = GlobalSymbolTable.find(TargetName.data());
if (SI != GlobalSymbolTable.end()) { if (SI != GlobalSymbolTable.end()) {
Value.SectionID = SI->second.first; Value.SectionID = SI->second.first;
Value.Addend = SI->second.second + RE.Addend; Value.Offset = SI->second.second + RE.Addend;
} else { } else {
Value.SymbolName = TargetName.data(); Value.SymbolName = TargetName.data();
Value.Addend = RE.Addend; Value.Offset = RE.Addend;
} }
} }
} else { } else {
@ -71,7 +71,7 @@ RelocationValueRef RuntimeDyldMachO::getRelocationValueRef(
Value.SectionID = findOrEmitSection(ObjImg, Sec, IsCode, ObjSectionToID); Value.SectionID = findOrEmitSection(ObjImg, Sec, IsCode, ObjSectionToID);
uint64_t Addr; uint64_t Addr;
Sec.getAddress(Addr); Sec.getAddress(Addr);
Value.Addend = RE.Addend - Addr; Value.Offset = RE.Addend - Addr;
} }
return Value; return Value;
@ -90,7 +90,7 @@ void RuntimeDyldMachO::makeValueAddendPCRel(RelocationValueRef &Value,
if (IsPCRel) { if (IsPCRel) {
uint64_t RelocAddr = 0; uint64_t RelocAddr = 0;
RI->getAddress(RelocAddr); RI->getAddress(RelocAddr);
Value.Addend += RelocAddr + OffsetToNextPC; Value.Offset += RelocAddr + OffsetToNextPC;
} }
} }

View File

@ -277,14 +277,14 @@ public:
"ARM64_RELOC_ADDEND and embedded addend in the instruction."); "ARM64_RELOC_ADDEND and embedded addend in the instruction.");
if (ExplicitAddend) { if (ExplicitAddend) {
RE.Addend = ExplicitAddend; RE.Addend = ExplicitAddend;
Value.Addend = ExplicitAddend; Value.Offset = ExplicitAddend;
} }
bool IsExtern = Obj.getPlainRelocationExternal(RelInfo); bool IsExtern = Obj.getPlainRelocationExternal(RelInfo);
if (!IsExtern && RE.IsPCRel) if (!IsExtern && RE.IsPCRel)
makeValueAddendPCRel(Value, ObjImg, RelI, 1 << RE.Size); makeValueAddendPCRel(Value, ObjImg, RelI, 1 << RE.Size);
RE.Addend = Value.Addend; RE.Addend = Value.Offset;
if (RE.RelType == MachO::ARM64_RELOC_GOT_LOAD_PAGE21 || if (RE.RelType == MachO::ARM64_RELOC_GOT_LOAD_PAGE21 ||
RE.RelType == MachO::ARM64_RELOC_GOT_LOAD_PAGEOFF12) RE.RelType == MachO::ARM64_RELOC_GOT_LOAD_PAGEOFF12)
@ -384,7 +384,7 @@ private:
assert(((StubAddress % getStubAlignment()) == 0) && assert(((StubAddress % getStubAlignment()) == 0) &&
"GOT entry not aligned"); "GOT entry not aligned");
RelocationEntry GOTRE(RE.SectionID, StubOffset, RelocationEntry GOTRE(RE.SectionID, StubOffset,
MachO::ARM64_RELOC_UNSIGNED, Value.Addend, MachO::ARM64_RELOC_UNSIGNED, Value.Offset,
/*IsPCRel=*/false, /*Size=*/3); /*IsPCRel=*/false, /*Size=*/3);
if (Value.SymbolName) if (Value.SymbolName)
addRelocationForSymbol(GOTRE, Value.SymbolName); addRelocationForSymbol(GOTRE, Value.SymbolName);

View File

@ -71,7 +71,7 @@ public:
if ((RE.RelType & 0xf) == MachO::ARM_RELOC_BR24) if ((RE.RelType & 0xf) == MachO::ARM_RELOC_BR24)
processBranchRelocation(RE, Value, Stubs); processBranchRelocation(RE, Value, Stubs);
else { else {
RE.Addend = Value.Addend; RE.Addend = Value.Offset;
if (Value.SymbolName) if (Value.SymbolName)
addRelocationForSymbol(RE, Value.SymbolName); addRelocationForSymbol(RE, Value.SymbolName);
else else
@ -152,7 +152,7 @@ private:
uint8_t *StubTargetAddr = uint8_t *StubTargetAddr =
createStubFunction(Section.Address + Section.StubOffset); createStubFunction(Section.Address + Section.StubOffset);
RelocationEntry StubRE(RE.SectionID, StubTargetAddr - Section.Address, RelocationEntry StubRE(RE.SectionID, StubTargetAddr - Section.Address,
MachO::GENERIC_RELOC_VANILLA, Value.Addend, false, MachO::GENERIC_RELOC_VANILLA, Value.Offset, false,
2); 2);
if (Value.SymbolName) if (Value.SymbolName)
addRelocationForSymbol(StubRE, Value.SymbolName); addRelocationForSymbol(StubRE, Value.SymbolName);

View File

@ -68,7 +68,7 @@ public:
if (RE.IsPCRel) if (RE.IsPCRel)
makeValueAddendPCRel(Value, ObjImg, RelI, 1 << RE.Size); makeValueAddendPCRel(Value, ObjImg, RelI, 1 << RE.Size);
RE.Addend = Value.Addend; RE.Addend = Value.Offset;
if (Value.SymbolName) if (Value.SymbolName)
addRelocationForSymbol(RE, Value.SymbolName); addRelocationForSymbol(RE, Value.SymbolName);

View File

@ -54,7 +54,7 @@ public:
RE.RelType == MachO::X86_64_RELOC_GOT_LOAD) RE.RelType == MachO::X86_64_RELOC_GOT_LOAD)
processGOTRelocation(RE, Value, Stubs); processGOTRelocation(RE, Value, Stubs);
else { else {
RE.Addend = Value.Addend; RE.Addend = Value.Offset;
if (Value.SymbolName) if (Value.SymbolName)
addRelocationForSymbol(RE, Value.SymbolName); addRelocationForSymbol(RE, Value.SymbolName);
else else
@ -106,7 +106,7 @@ private:
SectionEntry &Section = Sections[RE.SectionID]; SectionEntry &Section = Sections[RE.SectionID];
assert(RE.IsPCRel); assert(RE.IsPCRel);
assert(RE.Size == 2); assert(RE.Size == 2);
Value.Addend -= RE.Addend; Value.Offset -= RE.Addend;
RuntimeDyldMachO::StubMap::const_iterator i = Stubs.find(Value); RuntimeDyldMachO::StubMap::const_iterator i = Stubs.find(Value);
uint8_t *Addr; uint8_t *Addr;
if (i != Stubs.end()) { if (i != Stubs.end()) {
@ -115,7 +115,7 @@ private:
Stubs[Value] = Section.StubOffset; Stubs[Value] = Section.StubOffset;
uint8_t *GOTEntry = Section.Address + Section.StubOffset; uint8_t *GOTEntry = Section.Address + Section.StubOffset;
RelocationEntry GOTRE(RE.SectionID, Section.StubOffset, RelocationEntry GOTRE(RE.SectionID, Section.StubOffset,
MachO::X86_64_RELOC_UNSIGNED, Value.Addend, false, MachO::X86_64_RELOC_UNSIGNED, Value.Offset, false,
3); 3);
if (Value.SymbolName) if (Value.SymbolName)
addRelocationForSymbol(GOTRE, Value.SymbolName); addRelocationForSymbol(GOTRE, Value.SymbolName);