mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-22 10:24:26 +00:00
[MCJIT] Remove the local symbol table from RuntimeDlyd - it's not needed.
All symbols have to be stored in the global symbol to enable cross-rtdyld-instance linking, so the local symbol table content is redundant. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222867 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -155,8 +155,6 @@ RuntimeDyldImpl::loadObjectImpl(const object::ObjectFile &Obj) {
|
|||||||
MemMgr->reserveAllocationSpace(CodeSize, DataSizeRO, DataSizeRW);
|
MemMgr->reserveAllocationSpace(CodeSize, DataSizeRO, DataSizeRW);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Symbols found in this object
|
|
||||||
StringMap<SymbolLoc> LocalSymbols;
|
|
||||||
// Used sections from the object file
|
// Used sections from the object file
|
||||||
ObjSectionToIDMap LocalSections;
|
ObjSectionToIDMap LocalSections;
|
||||||
|
|
||||||
@ -202,7 +200,6 @@ RuntimeDyldImpl::loadObjectImpl(const object::ObjectFile &Obj) {
|
|||||||
bool IsCode = SI->isText();
|
bool IsCode = SI->isText();
|
||||||
unsigned SectionID =
|
unsigned SectionID =
|
||||||
findOrEmitSection(Obj, *SI, IsCode, LocalSections);
|
findOrEmitSection(Obj, *SI, IsCode, LocalSections);
|
||||||
LocalSymbols[Name.data()] = SymbolLoc(SectionID, SectOffset);
|
|
||||||
DEBUG(dbgs() << "\tOffset: " << format("%p", (uintptr_t)SectOffset)
|
DEBUG(dbgs() << "\tOffset: " << format("%p", (uintptr_t)SectOffset)
|
||||||
<< " flags: " << Flags << " SID: " << SectionID);
|
<< " flags: " << Flags << " SID: " << SectionID);
|
||||||
GlobalSymbolTable[Name] = SymbolLoc(SectionID, SectOffset);
|
GlobalSymbolTable[Name] = SymbolLoc(SectionID, SectOffset);
|
||||||
@ -235,8 +232,7 @@ RuntimeDyldImpl::loadObjectImpl(const object::ObjectFile &Obj) {
|
|||||||
DEBUG(dbgs() << "\tSectionID: " << SectionID << "\n");
|
DEBUG(dbgs() << "\tSectionID: " << SectionID << "\n");
|
||||||
|
|
||||||
for (; I != E;)
|
for (; I != E;)
|
||||||
I = processRelocationRef(SectionID, I, Obj, LocalSections, LocalSymbols,
|
I = processRelocationRef(SectionID, I, Obj, LocalSections, Stubs);
|
||||||
Stubs);
|
|
||||||
|
|
||||||
// If there is an attached checker, notify it about the stubs for this
|
// If there is an attached checker, notify it about the stubs for this
|
||||||
// section so that they can be verified.
|
// section so that they can be verified.
|
||||||
|
@ -901,7 +901,7 @@ void RuntimeDyldELF::resolveRelocation(const SectionEntry &Section,
|
|||||||
relocation_iterator RuntimeDyldELF::processRelocationRef(
|
relocation_iterator RuntimeDyldELF::processRelocationRef(
|
||||||
unsigned SectionID, relocation_iterator RelI,
|
unsigned SectionID, relocation_iterator RelI,
|
||||||
const ObjectFile &Obj,
|
const ObjectFile &Obj,
|
||||||
ObjSectionToIDMap &ObjSectionToID, const SymbolTableMap &Symbols,
|
ObjSectionToIDMap &ObjSectionToID,
|
||||||
StubMap &Stubs) {
|
StubMap &Stubs) {
|
||||||
uint64_t RelType;
|
uint64_t RelType;
|
||||||
Check(RelI->getType(RelType));
|
Check(RelI->getType(RelType));
|
||||||
@ -917,21 +917,14 @@ relocation_iterator RuntimeDyldELF::processRelocationRef(
|
|||||||
<< " TargetName: " << TargetName << "\n");
|
<< " TargetName: " << TargetName << "\n");
|
||||||
RelocationValueRef Value;
|
RelocationValueRef Value;
|
||||||
// First search for the symbol in the local symbol table
|
// First search for the symbol in the local symbol table
|
||||||
SymbolTableMap::const_iterator lsi = Symbols.end();
|
|
||||||
SymbolRef::Type SymType = SymbolRef::ST_Unknown;
|
SymbolRef::Type SymType = SymbolRef::ST_Unknown;
|
||||||
if (Symbol != Obj.symbol_end()) {
|
|
||||||
lsi = Symbols.find(TargetName.data());
|
|
||||||
Symbol->getType(SymType);
|
|
||||||
}
|
|
||||||
if (lsi != Symbols.end()) {
|
|
||||||
Value.SectionID = lsi->second.first;
|
|
||||||
Value.Offset = lsi->second.second;
|
|
||||||
Value.Addend = lsi->second.second + Addend;
|
|
||||||
} else {
|
|
||||||
// Search for the symbol in the global symbol table
|
// Search for the symbol in the global symbol table
|
||||||
SymbolTableMap::const_iterator gsi = GlobalSymbolTable.end();
|
SymbolTableMap::const_iterator gsi = GlobalSymbolTable.end();
|
||||||
if (Symbol != Obj.symbol_end())
|
if (Symbol != Obj.symbol_end()) {
|
||||||
gsi = GlobalSymbolTable.find(TargetName.data());
|
gsi = GlobalSymbolTable.find(TargetName.data());
|
||||||
|
Symbol->getType(SymType);
|
||||||
|
}
|
||||||
if (gsi != GlobalSymbolTable.end()) {
|
if (gsi != GlobalSymbolTable.end()) {
|
||||||
Value.SectionID = gsi->second.first;
|
Value.SectionID = gsi->second.first;
|
||||||
Value.Offset = gsi->second.second;
|
Value.Offset = gsi->second.second;
|
||||||
@ -970,7 +963,7 @@ relocation_iterator RuntimeDyldELF::processRelocationRef(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
uint64_t Offset;
|
uint64_t Offset;
|
||||||
Check(RelI->getOffset(Offset));
|
Check(RelI->getOffset(Offset));
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ public:
|
|||||||
processRelocationRef(unsigned SectionID, relocation_iterator RelI,
|
processRelocationRef(unsigned SectionID, relocation_iterator RelI,
|
||||||
const ObjectFile &Obj,
|
const ObjectFile &Obj,
|
||||||
ObjSectionToIDMap &ObjSectionToID,
|
ObjSectionToIDMap &ObjSectionToID,
|
||||||
const SymbolTableMap &Symbols, StubMap &Stubs) override;
|
StubMap &Stubs) override;
|
||||||
bool isCompatibleFile(const object::ObjectFile &Obj) const override;
|
bool isCompatibleFile(const object::ObjectFile &Obj) const override;
|
||||||
void registerEHFrames() override;
|
void registerEHFrames() override;
|
||||||
void deregisterEHFrames() override;
|
void deregisterEHFrames() override;
|
||||||
|
@ -332,7 +332,7 @@ protected:
|
|||||||
virtual relocation_iterator
|
virtual relocation_iterator
|
||||||
processRelocationRef(unsigned SectionID, relocation_iterator RelI,
|
processRelocationRef(unsigned SectionID, relocation_iterator RelI,
|
||||||
const ObjectFile &Obj, ObjSectionToIDMap &ObjSectionToID,
|
const ObjectFile &Obj, ObjSectionToIDMap &ObjSectionToID,
|
||||||
const SymbolTableMap &Symbols, StubMap &Stubs) = 0;
|
StubMap &Stubs) = 0;
|
||||||
|
|
||||||
/// \brief Resolve relocations to external symbols.
|
/// \brief Resolve relocations to external symbols.
|
||||||
void resolveExternalSymbols();
|
void resolveExternalSymbols();
|
||||||
|
@ -52,8 +52,7 @@ int64_t RuntimeDyldMachO::memcpyAddend(const RelocationEntry &RE) const {
|
|||||||
|
|
||||||
RelocationValueRef RuntimeDyldMachO::getRelocationValueRef(
|
RelocationValueRef RuntimeDyldMachO::getRelocationValueRef(
|
||||||
const ObjectFile &BaseTObj, const relocation_iterator &RI,
|
const ObjectFile &BaseTObj, const relocation_iterator &RI,
|
||||||
const RelocationEntry &RE, ObjSectionToIDMap &ObjSectionToID,
|
const RelocationEntry &RE, ObjSectionToIDMap &ObjSectionToID) {
|
||||||
const SymbolTableMap &Symbols) {
|
|
||||||
|
|
||||||
const MachOObjectFile &Obj =
|
const MachOObjectFile &Obj =
|
||||||
static_cast<const MachOObjectFile &>(BaseTObj);
|
static_cast<const MachOObjectFile &>(BaseTObj);
|
||||||
@ -66,12 +65,8 @@ RelocationValueRef RuntimeDyldMachO::getRelocationValueRef(
|
|||||||
symbol_iterator Symbol = RI->getSymbol();
|
symbol_iterator Symbol = RI->getSymbol();
|
||||||
StringRef TargetName;
|
StringRef TargetName;
|
||||||
Symbol->getName(TargetName);
|
Symbol->getName(TargetName);
|
||||||
SymbolTableMap::const_iterator SI = Symbols.find(TargetName.data());
|
SymbolTableMap::const_iterator SI =
|
||||||
if (SI != Symbols.end()) {
|
GlobalSymbolTable.find(TargetName.data());
|
||||||
Value.SectionID = SI->second.first;
|
|
||||||
Value.Offset = SI->second.second + RE.Addend;
|
|
||||||
} else {
|
|
||||||
SI = GlobalSymbolTable.find(TargetName.data());
|
|
||||||
if (SI != GlobalSymbolTable.end()) {
|
if (SI != GlobalSymbolTable.end()) {
|
||||||
Value.SectionID = SI->second.first;
|
Value.SectionID = SI->second.first;
|
||||||
Value.Offset = SI->second.second + RE.Addend;
|
Value.Offset = SI->second.second + RE.Addend;
|
||||||
@ -79,7 +74,6 @@ RelocationValueRef RuntimeDyldMachO::getRelocationValueRef(
|
|||||||
Value.SymbolName = TargetName.data();
|
Value.SymbolName = TargetName.data();
|
||||||
Value.Offset = RE.Addend;
|
Value.Offset = RE.Addend;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
SectionRef Sec = Obj.getRelocationSection(RelInfo);
|
SectionRef Sec = Obj.getRelocationSection(RelInfo);
|
||||||
bool IsCode = Sec.isText();
|
bool IsCode = Sec.isText();
|
||||||
|
@ -90,8 +90,7 @@ protected:
|
|||||||
RelocationValueRef getRelocationValueRef(const ObjectFile &BaseTObj,
|
RelocationValueRef getRelocationValueRef(const ObjectFile &BaseTObj,
|
||||||
const relocation_iterator &RI,
|
const relocation_iterator &RI,
|
||||||
const RelocationEntry &RE,
|
const RelocationEntry &RE,
|
||||||
ObjSectionToIDMap &ObjSectionToID,
|
ObjSectionToIDMap &ObjSectionToID);
|
||||||
const SymbolTableMap &Symbols);
|
|
||||||
|
|
||||||
/// Make the RelocationValueRef addend PC-relative.
|
/// Make the RelocationValueRef addend PC-relative.
|
||||||
void makeValueAddendPCRel(RelocationValueRef &Value,
|
void makeValueAddendPCRel(RelocationValueRef &Value,
|
||||||
|
@ -245,7 +245,7 @@ public:
|
|||||||
processRelocationRef(unsigned SectionID, relocation_iterator RelI,
|
processRelocationRef(unsigned SectionID, relocation_iterator RelI,
|
||||||
const ObjectFile &BaseObjT,
|
const ObjectFile &BaseObjT,
|
||||||
ObjSectionToIDMap &ObjSectionToID,
|
ObjSectionToIDMap &ObjSectionToID,
|
||||||
const SymbolTableMap &Symbols, StubMap &Stubs) override {
|
StubMap &Stubs) override {
|
||||||
const MachOObjectFile &Obj =
|
const MachOObjectFile &Obj =
|
||||||
static_cast<const MachOObjectFile &>(BaseObjT);
|
static_cast<const MachOObjectFile &>(BaseObjT);
|
||||||
MachO::any_relocation_info RelInfo =
|
MachO::any_relocation_info RelInfo =
|
||||||
@ -272,7 +272,7 @@ public:
|
|||||||
RelocationEntry RE(getRelocationEntry(SectionID, Obj, RelI));
|
RelocationEntry RE(getRelocationEntry(SectionID, Obj, RelI));
|
||||||
RE.Addend = decodeAddend(RE);
|
RE.Addend = decodeAddend(RE);
|
||||||
RelocationValueRef Value(
|
RelocationValueRef Value(
|
||||||
getRelocationValueRef(Obj, RelI, RE, ObjSectionToID, Symbols));
|
getRelocationValueRef(Obj, RelI, RE, ObjSectionToID));
|
||||||
|
|
||||||
assert((ExplicitAddend == 0 || RE.Addend == 0) && "Relocation has "\
|
assert((ExplicitAddend == 0 || RE.Addend == 0) && "Relocation has "\
|
||||||
"ARM64_RELOC_ADDEND and embedded addend in the instruction.");
|
"ARM64_RELOC_ADDEND and embedded addend in the instruction.");
|
||||||
|
@ -51,7 +51,7 @@ public:
|
|||||||
processRelocationRef(unsigned SectionID, relocation_iterator RelI,
|
processRelocationRef(unsigned SectionID, relocation_iterator RelI,
|
||||||
const ObjectFile &BaseObjT,
|
const ObjectFile &BaseObjT,
|
||||||
ObjSectionToIDMap &ObjSectionToID,
|
ObjSectionToIDMap &ObjSectionToID,
|
||||||
const SymbolTableMap &Symbols, StubMap &Stubs) override {
|
StubMap &Stubs) override {
|
||||||
const MachOObjectFile &Obj =
|
const MachOObjectFile &Obj =
|
||||||
static_cast<const MachOObjectFile &>(BaseObjT);
|
static_cast<const MachOObjectFile &>(BaseObjT);
|
||||||
MachO::any_relocation_info RelInfo =
|
MachO::any_relocation_info RelInfo =
|
||||||
@ -69,7 +69,7 @@ public:
|
|||||||
RelocationEntry RE(getRelocationEntry(SectionID, Obj, RelI));
|
RelocationEntry RE(getRelocationEntry(SectionID, Obj, RelI));
|
||||||
RE.Addend = decodeAddend(RE);
|
RE.Addend = decodeAddend(RE);
|
||||||
RelocationValueRef Value(
|
RelocationValueRef Value(
|
||||||
getRelocationValueRef(Obj, RelI, RE, ObjSectionToID, Symbols));
|
getRelocationValueRef(Obj, RelI, RE, ObjSectionToID));
|
||||||
|
|
||||||
if (RE.IsPCRel)
|
if (RE.IsPCRel)
|
||||||
makeValueAddendPCRel(Value, Obj, RelI, 8);
|
makeValueAddendPCRel(Value, Obj, RelI, 8);
|
||||||
|
@ -33,7 +33,7 @@ public:
|
|||||||
processRelocationRef(unsigned SectionID, relocation_iterator RelI,
|
processRelocationRef(unsigned SectionID, relocation_iterator RelI,
|
||||||
const ObjectFile &BaseObjT,
|
const ObjectFile &BaseObjT,
|
||||||
ObjSectionToIDMap &ObjSectionToID,
|
ObjSectionToIDMap &ObjSectionToID,
|
||||||
const SymbolTableMap &Symbols, StubMap &Stubs) override {
|
StubMap &Stubs) override {
|
||||||
const MachOObjectFile &Obj =
|
const MachOObjectFile &Obj =
|
||||||
static_cast<const MachOObjectFile &>(BaseObjT);
|
static_cast<const MachOObjectFile &>(BaseObjT);
|
||||||
MachO::any_relocation_info RelInfo =
|
MachO::any_relocation_info RelInfo =
|
||||||
@ -54,7 +54,7 @@ public:
|
|||||||
RelocationEntry RE(getRelocationEntry(SectionID, Obj, RelI));
|
RelocationEntry RE(getRelocationEntry(SectionID, Obj, RelI));
|
||||||
RE.Addend = memcpyAddend(RE);
|
RE.Addend = memcpyAddend(RE);
|
||||||
RelocationValueRef Value(
|
RelocationValueRef Value(
|
||||||
getRelocationValueRef(Obj, RelI, RE, ObjSectionToID, Symbols));
|
getRelocationValueRef(Obj, RelI, RE, ObjSectionToID));
|
||||||
|
|
||||||
// Addends for external, PC-rel relocations on i386 point back to the zero
|
// Addends for external, PC-rel relocations on i386 point back to the zero
|
||||||
// offset. Calculate the final offset from the relocation target instead.
|
// offset. Calculate the final offset from the relocation target instead.
|
||||||
|
@ -33,7 +33,7 @@ public:
|
|||||||
processRelocationRef(unsigned SectionID, relocation_iterator RelI,
|
processRelocationRef(unsigned SectionID, relocation_iterator RelI,
|
||||||
const ObjectFile &BaseObjT,
|
const ObjectFile &BaseObjT,
|
||||||
ObjSectionToIDMap &ObjSectionToID,
|
ObjSectionToIDMap &ObjSectionToID,
|
||||||
const SymbolTableMap &Symbols, StubMap &Stubs) override {
|
StubMap &Stubs) override {
|
||||||
const MachOObjectFile &Obj =
|
const MachOObjectFile &Obj =
|
||||||
static_cast<const MachOObjectFile &>(BaseObjT);
|
static_cast<const MachOObjectFile &>(BaseObjT);
|
||||||
MachO::any_relocation_info RelInfo =
|
MachO::any_relocation_info RelInfo =
|
||||||
@ -45,7 +45,7 @@ public:
|
|||||||
RelocationEntry RE(getRelocationEntry(SectionID, Obj, RelI));
|
RelocationEntry RE(getRelocationEntry(SectionID, Obj, RelI));
|
||||||
RE.Addend = memcpyAddend(RE);
|
RE.Addend = memcpyAddend(RE);
|
||||||
RelocationValueRef Value(
|
RelocationValueRef Value(
|
||||||
getRelocationValueRef(Obj, RelI, RE, ObjSectionToID, Symbols));
|
getRelocationValueRef(Obj, RelI, RE, ObjSectionToID));
|
||||||
|
|
||||||
bool IsExtern = Obj.getPlainRelocationExternal(RelInfo);
|
bool IsExtern = Obj.getPlainRelocationExternal(RelInfo);
|
||||||
if (!IsExtern && RE.IsPCRel)
|
if (!IsExtern && RE.IsPCRel)
|
||||||
|
Reference in New Issue
Block a user