mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-28 03:25:23 +00:00
MC: Use MCSymbol in MachObjectWriter, NFC
Replace uses of `MCSymbolData` with `MCSymbol` where both are needed, so we can remove the backpointer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237799 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -39,15 +39,14 @@ void MachObjectWriter::reset() {
|
||||
MCObjectWriter::reset();
|
||||
}
|
||||
|
||||
bool MachObjectWriter::
|
||||
doesSymbolRequireExternRelocation(const MCSymbolData *SD) {
|
||||
bool MachObjectWriter::doesSymbolRequireExternRelocation(const MCSymbol &S) {
|
||||
// Undefined symbols are always extern.
|
||||
if (SD->getSymbol().isUndefined())
|
||||
if (S.isUndefined())
|
||||
return true;
|
||||
|
||||
// References to weak definitions require external relocation entries; the
|
||||
// definition may not always be the one in the same object file.
|
||||
if (SD->getFlags() & SF_WeakDefinition)
|
||||
if (S.getData().getFlags() & SF_WeakDefinition)
|
||||
return true;
|
||||
|
||||
// Otherwise, we can use an internal relocation.
|
||||
@@ -56,8 +55,7 @@ doesSymbolRequireExternRelocation(const MCSymbolData *SD) {
|
||||
|
||||
bool MachObjectWriter::
|
||||
MachSymbolData::operator<(const MachSymbolData &RHS) const {
|
||||
return SymbolData->getSymbol().getName() <
|
||||
RHS.SymbolData->getSymbol().getName();
|
||||
return Symbol->getName() < RHS.Symbol->getName();
|
||||
}
|
||||
|
||||
bool MachObjectWriter::isFixupKindPCRel(const MCAssembler &Asm, unsigned Kind) {
|
||||
@@ -303,15 +301,15 @@ void MachObjectWriter::WriteDysymtabLoadCommand(uint32_t FirstLocalSymbol,
|
||||
MachObjectWriter::MachSymbolData *
|
||||
MachObjectWriter::findSymbolData(const MCSymbol &Sym) {
|
||||
for (auto &Entry : LocalSymbolData)
|
||||
if (&Entry.SymbolData->getSymbol() == &Sym)
|
||||
if (Entry.Symbol == &Sym)
|
||||
return &Entry;
|
||||
|
||||
for (auto &Entry : ExternalSymbolData)
|
||||
if (&Entry.SymbolData->getSymbol() == &Sym)
|
||||
if (Entry.Symbol == &Sym)
|
||||
return &Entry;
|
||||
|
||||
for (auto &Entry : UndefinedSymbolData)
|
||||
if (&Entry.SymbolData->getSymbol() == &Sym)
|
||||
if (Entry.Symbol == &Sym)
|
||||
return &Entry;
|
||||
|
||||
return nullptr;
|
||||
@@ -331,8 +329,8 @@ const MCSymbol &MachObjectWriter::findAliasedSymbol(const MCSymbol &Sym) const {
|
||||
|
||||
void MachObjectWriter::WriteNlist(MachSymbolData &MSD,
|
||||
const MCAsmLayout &Layout) {
|
||||
MCSymbolData &Data = *MSD.SymbolData;
|
||||
const MCSymbol *Symbol = &Data.getSymbol();
|
||||
const MCSymbol *Symbol = MSD.Symbol;
|
||||
MCSymbolData &Data = Symbol->getData();
|
||||
const MCSymbol *AliasedSymbol = &findAliasedSymbol(*Symbol);
|
||||
uint8_t SectionIndex = MSD.SectionIndex;
|
||||
uint8_t Type = 0;
|
||||
@@ -570,7 +568,7 @@ void MachObjectWriter::ComputeSymbolTable(
|
||||
continue;
|
||||
|
||||
MachSymbolData MSD;
|
||||
MSD.SymbolData = &SD;
|
||||
MSD.Symbol = &Symbol;
|
||||
MSD.StringIndex = StringTable.getOffset(Symbol.getName());
|
||||
|
||||
if (Symbol.isUndefined()) {
|
||||
@@ -598,7 +596,7 @@ void MachObjectWriter::ComputeSymbolTable(
|
||||
continue;
|
||||
|
||||
MachSymbolData MSD;
|
||||
MSD.SymbolData = &SD;
|
||||
MSD.Symbol = &Symbol;
|
||||
MSD.StringIndex = StringTable.getOffset(Symbol.getName());
|
||||
|
||||
if (Symbol.isAbsolute()) {
|
||||
@@ -618,11 +616,11 @@ void MachObjectWriter::ComputeSymbolTable(
|
||||
// Set the symbol indices.
|
||||
Index = 0;
|
||||
for (unsigned i = 0, e = LocalSymbolData.size(); i != e; ++i)
|
||||
LocalSymbolData[i].SymbolData->setIndex(Index++);
|
||||
LocalSymbolData[i].Symbol->getData().setIndex(Index++);
|
||||
for (unsigned i = 0, e = ExternalSymbolData.size(); i != e; ++i)
|
||||
ExternalSymbolData[i].SymbolData->setIndex(Index++);
|
||||
ExternalSymbolData[i].Symbol->getData().setIndex(Index++);
|
||||
for (unsigned i = 0, e = UndefinedSymbolData.size(); i != e; ++i)
|
||||
UndefinedSymbolData[i].SymbolData->setIndex(Index++);
|
||||
UndefinedSymbolData[i].Symbol->getData().setIndex(Index++);
|
||||
|
||||
for (const MCSectionData &SD : Asm) {
|
||||
std::vector<RelAndSymbol> &Relocs = Relocations[&SD];
|
||||
|
Reference in New Issue
Block a user