mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +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:
parent
21f9d78c25
commit
973e54ac96
@ -155,8 +155,6 @@ RuntimeDyldImpl::loadObjectImpl(const object::ObjectFile &Obj) {
|
||||
MemMgr->reserveAllocationSpace(CodeSize, DataSizeRO, DataSizeRW);
|
||||
}
|
||||
|
||||
// Symbols found in this object
|
||||
StringMap<SymbolLoc> LocalSymbols;
|
||||
// Used sections from the object file
|
||||
ObjSectionToIDMap LocalSections;
|
||||
|
||||
@ -202,7 +200,6 @@ RuntimeDyldImpl::loadObjectImpl(const object::ObjectFile &Obj) {
|
||||
bool IsCode = SI->isText();
|
||||
unsigned SectionID =
|
||||
findOrEmitSection(Obj, *SI, IsCode, LocalSections);
|
||||
LocalSymbols[Name.data()] = SymbolLoc(SectionID, SectOffset);
|
||||
DEBUG(dbgs() << "\tOffset: " << format("%p", (uintptr_t)SectOffset)
|
||||
<< " flags: " << Flags << " SID: " << SectionID);
|
||||
GlobalSymbolTable[Name] = SymbolLoc(SectionID, SectOffset);
|
||||
@ -235,8 +232,7 @@ RuntimeDyldImpl::loadObjectImpl(const object::ObjectFile &Obj) {
|
||||
DEBUG(dbgs() << "\tSectionID: " << SectionID << "\n");
|
||||
|
||||
for (; I != E;)
|
||||
I = processRelocationRef(SectionID, I, Obj, LocalSections, LocalSymbols,
|
||||
Stubs);
|
||||
I = processRelocationRef(SectionID, I, Obj, LocalSections, Stubs);
|
||||
|
||||
// If there is an attached checker, notify it about the stubs for this
|
||||
// section so that they can be verified.
|
||||
|
@ -901,7 +901,7 @@ void RuntimeDyldELF::resolveRelocation(const SectionEntry &Section,
|
||||
relocation_iterator RuntimeDyldELF::processRelocationRef(
|
||||
unsigned SectionID, relocation_iterator RelI,
|
||||
const ObjectFile &Obj,
|
||||
ObjSectionToIDMap &ObjSectionToID, const SymbolTableMap &Symbols,
|
||||
ObjSectionToIDMap &ObjSectionToID,
|
||||
StubMap &Stubs) {
|
||||
uint64_t RelType;
|
||||
Check(RelI->getType(RelType));
|
||||
@ -917,60 +917,53 @@ relocation_iterator RuntimeDyldELF::processRelocationRef(
|
||||
<< " TargetName: " << TargetName << "\n");
|
||||
RelocationValueRef Value;
|
||||
// First search for the symbol in the local symbol table
|
||||
SymbolTableMap::const_iterator lsi = Symbols.end();
|
||||
SymbolRef::Type SymType = SymbolRef::ST_Unknown;
|
||||
|
||||
// Search for the symbol in the global symbol table
|
||||
SymbolTableMap::const_iterator gsi = GlobalSymbolTable.end();
|
||||
if (Symbol != Obj.symbol_end()) {
|
||||
lsi = Symbols.find(TargetName.data());
|
||||
gsi = GlobalSymbolTable.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;
|
||||
if (gsi != GlobalSymbolTable.end()) {
|
||||
Value.SectionID = gsi->second.first;
|
||||
Value.Offset = gsi->second.second;
|
||||
Value.Addend = gsi->second.second + Addend;
|
||||
} else {
|
||||
// Search for the symbol in the global symbol table
|
||||
SymbolTableMap::const_iterator gsi = GlobalSymbolTable.end();
|
||||
if (Symbol != Obj.symbol_end())
|
||||
gsi = GlobalSymbolTable.find(TargetName.data());
|
||||
if (gsi != GlobalSymbolTable.end()) {
|
||||
Value.SectionID = gsi->second.first;
|
||||
Value.Offset = gsi->second.second;
|
||||
Value.Addend = gsi->second.second + Addend;
|
||||
} else {
|
||||
switch (SymType) {
|
||||
case SymbolRef::ST_Debug: {
|
||||
// TODO: Now ELF SymbolRef::ST_Debug = STT_SECTION, it's not obviously
|
||||
// and can be changed by another developers. Maybe best way is add
|
||||
// a new symbol type ST_Section to SymbolRef and use it.
|
||||
section_iterator si(Obj.section_end());
|
||||
Symbol->getSection(si);
|
||||
if (si == Obj.section_end())
|
||||
llvm_unreachable("Symbol section not found, bad object file format!");
|
||||
DEBUG(dbgs() << "\t\tThis is section symbol\n");
|
||||
bool isCode = si->isText();
|
||||
Value.SectionID = findOrEmitSection(Obj, (*si), isCode, ObjSectionToID);
|
||||
Value.Addend = Addend;
|
||||
break;
|
||||
}
|
||||
case SymbolRef::ST_Data:
|
||||
case SymbolRef::ST_Unknown: {
|
||||
Value.SymbolName = TargetName.data();
|
||||
Value.Addend = Addend;
|
||||
switch (SymType) {
|
||||
case SymbolRef::ST_Debug: {
|
||||
// TODO: Now ELF SymbolRef::ST_Debug = STT_SECTION, it's not obviously
|
||||
// and can be changed by another developers. Maybe best way is add
|
||||
// a new symbol type ST_Section to SymbolRef and use it.
|
||||
section_iterator si(Obj.section_end());
|
||||
Symbol->getSection(si);
|
||||
if (si == Obj.section_end())
|
||||
llvm_unreachable("Symbol section not found, bad object file format!");
|
||||
DEBUG(dbgs() << "\t\tThis is section symbol\n");
|
||||
bool isCode = si->isText();
|
||||
Value.SectionID = findOrEmitSection(Obj, (*si), isCode, ObjSectionToID);
|
||||
Value.Addend = Addend;
|
||||
break;
|
||||
}
|
||||
case SymbolRef::ST_Data:
|
||||
case SymbolRef::ST_Unknown: {
|
||||
Value.SymbolName = TargetName.data();
|
||||
Value.Addend = Addend;
|
||||
|
||||
// Absolute relocations will have a zero symbol ID (STN_UNDEF), which
|
||||
// will manifest here as a NULL symbol name.
|
||||
// We can set this as a valid (but empty) symbol name, and rely
|
||||
// on addRelocationForSymbol to handle this.
|
||||
if (!Value.SymbolName)
|
||||
Value.SymbolName = "";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
llvm_unreachable("Unresolved symbol type!");
|
||||
break;
|
||||
}
|
||||
// Absolute relocations will have a zero symbol ID (STN_UNDEF), which
|
||||
// will manifest here as a NULL symbol name.
|
||||
// We can set this as a valid (but empty) symbol name, and rely
|
||||
// on addRelocationForSymbol to handle this.
|
||||
if (!Value.SymbolName)
|
||||
Value.SymbolName = "";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
llvm_unreachable("Unresolved symbol type!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t Offset;
|
||||
Check(RelI->getOffset(Offset));
|
||||
|
||||
|
@ -119,7 +119,7 @@ public:
|
||||
processRelocationRef(unsigned SectionID, relocation_iterator RelI,
|
||||
const ObjectFile &Obj,
|
||||
ObjSectionToIDMap &ObjSectionToID,
|
||||
const SymbolTableMap &Symbols, StubMap &Stubs) override;
|
||||
StubMap &Stubs) override;
|
||||
bool isCompatibleFile(const object::ObjectFile &Obj) const override;
|
||||
void registerEHFrames() override;
|
||||
void deregisterEHFrames() override;
|
||||
|
@ -332,7 +332,7 @@ protected:
|
||||
virtual relocation_iterator
|
||||
processRelocationRef(unsigned SectionID, relocation_iterator RelI,
|
||||
const ObjectFile &Obj, ObjSectionToIDMap &ObjSectionToID,
|
||||
const SymbolTableMap &Symbols, StubMap &Stubs) = 0;
|
||||
StubMap &Stubs) = 0;
|
||||
|
||||
/// \brief Resolve relocations to external symbols.
|
||||
void resolveExternalSymbols();
|
||||
|
@ -52,8 +52,7 @@ int64_t RuntimeDyldMachO::memcpyAddend(const RelocationEntry &RE) const {
|
||||
|
||||
RelocationValueRef RuntimeDyldMachO::getRelocationValueRef(
|
||||
const ObjectFile &BaseTObj, const relocation_iterator &RI,
|
||||
const RelocationEntry &RE, ObjSectionToIDMap &ObjSectionToID,
|
||||
const SymbolTableMap &Symbols) {
|
||||
const RelocationEntry &RE, ObjSectionToIDMap &ObjSectionToID) {
|
||||
|
||||
const MachOObjectFile &Obj =
|
||||
static_cast<const MachOObjectFile &>(BaseTObj);
|
||||
@ -66,19 +65,14 @@ RelocationValueRef RuntimeDyldMachO::getRelocationValueRef(
|
||||
symbol_iterator Symbol = RI->getSymbol();
|
||||
StringRef TargetName;
|
||||
Symbol->getName(TargetName);
|
||||
SymbolTableMap::const_iterator SI = Symbols.find(TargetName.data());
|
||||
if (SI != Symbols.end()) {
|
||||
SymbolTableMap::const_iterator SI =
|
||||
GlobalSymbolTable.find(TargetName.data());
|
||||
if (SI != GlobalSymbolTable.end()) {
|
||||
Value.SectionID = SI->second.first;
|
||||
Value.Offset = SI->second.second + RE.Addend;
|
||||
} else {
|
||||
SI = GlobalSymbolTable.find(TargetName.data());
|
||||
if (SI != GlobalSymbolTable.end()) {
|
||||
Value.SectionID = SI->second.first;
|
||||
Value.Offset = SI->second.second + RE.Addend;
|
||||
} else {
|
||||
Value.SymbolName = TargetName.data();
|
||||
Value.Offset = RE.Addend;
|
||||
}
|
||||
Value.SymbolName = TargetName.data();
|
||||
Value.Offset = RE.Addend;
|
||||
}
|
||||
} else {
|
||||
SectionRef Sec = Obj.getRelocationSection(RelInfo);
|
||||
|
@ -90,8 +90,7 @@ protected:
|
||||
RelocationValueRef getRelocationValueRef(const ObjectFile &BaseTObj,
|
||||
const relocation_iterator &RI,
|
||||
const RelocationEntry &RE,
|
||||
ObjSectionToIDMap &ObjSectionToID,
|
||||
const SymbolTableMap &Symbols);
|
||||
ObjSectionToIDMap &ObjSectionToID);
|
||||
|
||||
/// Make the RelocationValueRef addend PC-relative.
|
||||
void makeValueAddendPCRel(RelocationValueRef &Value,
|
||||
|
@ -245,7 +245,7 @@ public:
|
||||
processRelocationRef(unsigned SectionID, relocation_iterator RelI,
|
||||
const ObjectFile &BaseObjT,
|
||||
ObjSectionToIDMap &ObjSectionToID,
|
||||
const SymbolTableMap &Symbols, StubMap &Stubs) override {
|
||||
StubMap &Stubs) override {
|
||||
const MachOObjectFile &Obj =
|
||||
static_cast<const MachOObjectFile &>(BaseObjT);
|
||||
MachO::any_relocation_info RelInfo =
|
||||
@ -272,7 +272,7 @@ public:
|
||||
RelocationEntry RE(getRelocationEntry(SectionID, Obj, RelI));
|
||||
RE.Addend = decodeAddend(RE);
|
||||
RelocationValueRef Value(
|
||||
getRelocationValueRef(Obj, RelI, RE, ObjSectionToID, Symbols));
|
||||
getRelocationValueRef(Obj, RelI, RE, ObjSectionToID));
|
||||
|
||||
assert((ExplicitAddend == 0 || RE.Addend == 0) && "Relocation has "\
|
||||
"ARM64_RELOC_ADDEND and embedded addend in the instruction.");
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
processRelocationRef(unsigned SectionID, relocation_iterator RelI,
|
||||
const ObjectFile &BaseObjT,
|
||||
ObjSectionToIDMap &ObjSectionToID,
|
||||
const SymbolTableMap &Symbols, StubMap &Stubs) override {
|
||||
StubMap &Stubs) override {
|
||||
const MachOObjectFile &Obj =
|
||||
static_cast<const MachOObjectFile &>(BaseObjT);
|
||||
MachO::any_relocation_info RelInfo =
|
||||
@ -69,7 +69,7 @@ public:
|
||||
RelocationEntry RE(getRelocationEntry(SectionID, Obj, RelI));
|
||||
RE.Addend = decodeAddend(RE);
|
||||
RelocationValueRef Value(
|
||||
getRelocationValueRef(Obj, RelI, RE, ObjSectionToID, Symbols));
|
||||
getRelocationValueRef(Obj, RelI, RE, ObjSectionToID));
|
||||
|
||||
if (RE.IsPCRel)
|
||||
makeValueAddendPCRel(Value, Obj, RelI, 8);
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
processRelocationRef(unsigned SectionID, relocation_iterator RelI,
|
||||
const ObjectFile &BaseObjT,
|
||||
ObjSectionToIDMap &ObjSectionToID,
|
||||
const SymbolTableMap &Symbols, StubMap &Stubs) override {
|
||||
StubMap &Stubs) override {
|
||||
const MachOObjectFile &Obj =
|
||||
static_cast<const MachOObjectFile &>(BaseObjT);
|
||||
MachO::any_relocation_info RelInfo =
|
||||
@ -54,7 +54,7 @@ public:
|
||||
RelocationEntry RE(getRelocationEntry(SectionID, Obj, RelI));
|
||||
RE.Addend = memcpyAddend(RE);
|
||||
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
|
||||
// offset. Calculate the final offset from the relocation target instead.
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
processRelocationRef(unsigned SectionID, relocation_iterator RelI,
|
||||
const ObjectFile &BaseObjT,
|
||||
ObjSectionToIDMap &ObjSectionToID,
|
||||
const SymbolTableMap &Symbols, StubMap &Stubs) override {
|
||||
StubMap &Stubs) override {
|
||||
const MachOObjectFile &Obj =
|
||||
static_cast<const MachOObjectFile &>(BaseObjT);
|
||||
MachO::any_relocation_info RelInfo =
|
||||
@ -45,7 +45,7 @@ public:
|
||||
RelocationEntry RE(getRelocationEntry(SectionID, Obj, RelI));
|
||||
RE.Addend = memcpyAddend(RE);
|
||||
RelocationValueRef Value(
|
||||
getRelocationValueRef(Obj, RelI, RE, ObjSectionToID, Symbols));
|
||||
getRelocationValueRef(Obj, RelI, RE, ObjSectionToID));
|
||||
|
||||
bool IsExtern = Obj.getPlainRelocationExternal(RelInfo);
|
||||
if (!IsExtern && RE.IsPCRel)
|
||||
|
Loading…
Reference in New Issue
Block a user