mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-23 20:29:30 +00:00
Remove structure field that can be computed just before use.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238480 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f3344cdffb
commit
c66c8e7730
@ -79,7 +79,6 @@ class ELFObjectWriter : public MCObjectWriter {
|
|||||||
/// Helper struct for containing some precomputed information on symbols.
|
/// Helper struct for containing some precomputed information on symbols.
|
||||||
struct ELFSymbolData {
|
struct ELFSymbolData {
|
||||||
const MCSymbol *Symbol;
|
const MCSymbol *Symbol;
|
||||||
uint64_t StringIndex;
|
|
||||||
uint32_t SectionIndex;
|
uint32_t SectionIndex;
|
||||||
StringRef Name;
|
StringRef Name;
|
||||||
|
|
||||||
@ -171,8 +170,8 @@ class ELFObjectWriter : public MCObjectWriter {
|
|||||||
|
|
||||||
void writeHeader(const MCAssembler &Asm);
|
void writeHeader(const MCAssembler &Asm);
|
||||||
|
|
||||||
void WriteSymbol(SymbolTableWriter &Writer, ELFSymbolData &MSD,
|
void writeSymbol(SymbolTableWriter &Writer, uint32_t StringIndex,
|
||||||
const MCAsmLayout &Layout);
|
ELFSymbolData &MSD, const MCAsmLayout &Layout);
|
||||||
|
|
||||||
// Start and end offset of each section
|
// Start and end offset of each section
|
||||||
typedef std::map<const MCSectionELF *, std::pair<uint64_t, uint64_t>>
|
typedef std::map<const MCSectionELF *, std::pair<uint64_t, uint64_t>>
|
||||||
@ -451,7 +450,8 @@ static uint8_t mergeTypeForSet(uint8_t origType, uint8_t newType) {
|
|||||||
return Type;
|
return Type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ELFObjectWriter::WriteSymbol(SymbolTableWriter &Writer, ELFSymbolData &MSD,
|
void ELFObjectWriter::writeSymbol(SymbolTableWriter &Writer,
|
||||||
|
uint32_t StringIndex, ELFSymbolData &MSD,
|
||||||
const MCAsmLayout &Layout) {
|
const MCAsmLayout &Layout) {
|
||||||
MCSymbolData &OrigData = MSD.Symbol->getData();
|
MCSymbolData &OrigData = MSD.Symbol->getData();
|
||||||
assert((!OrigData.getFragment() ||
|
assert((!OrigData.getFragment() ||
|
||||||
@ -494,8 +494,8 @@ void ELFObjectWriter::WriteSymbol(SymbolTableWriter &Writer, ELFSymbolData &MSD,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write out the symbol table entry
|
// Write out the symbol table entry
|
||||||
Writer.writeSymbol(MSD.StringIndex, Info, Value, Size, Other,
|
Writer.writeSymbol(StringIndex, Info, Value, Size, Other, MSD.SectionIndex,
|
||||||
MSD.SectionIndex, IsReserved);
|
IsReserved);
|
||||||
}
|
}
|
||||||
|
|
||||||
// It is always valid to create a relocation with a symbol. It is preferable
|
// It is always valid to create a relocation with a symbol. It is preferable
|
||||||
@ -948,26 +948,27 @@ void ELFObjectWriter::computeSymbolTable(
|
|||||||
unsigned Index = FileNames.size() + 1;
|
unsigned Index = FileNames.size() + 1;
|
||||||
|
|
||||||
for (ELFSymbolData &MSD : LocalSymbolData) {
|
for (ELFSymbolData &MSD : LocalSymbolData) {
|
||||||
MSD.StringIndex = MCELF::GetType(MSD.Symbol->getData()) == ELF::STT_SECTION
|
unsigned StringIndex =
|
||||||
|
MCELF::GetType(MSD.Symbol->getData()) == ELF::STT_SECTION
|
||||||
? 0
|
? 0
|
||||||
: StrTabBuilder.getOffset(MSD.Name);
|
: StrTabBuilder.getOffset(MSD.Name);
|
||||||
MSD.Symbol->setIndex(Index++);
|
MSD.Symbol->setIndex(Index++);
|
||||||
WriteSymbol(Writer, MSD, Layout);
|
writeSymbol(Writer, StringIndex, MSD, Layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the symbol table entries.
|
// Write the symbol table entries.
|
||||||
LastLocalSymbolIndex = Index;
|
LastLocalSymbolIndex = Index;
|
||||||
|
|
||||||
for (ELFSymbolData &MSD : ExternalSymbolData) {
|
for (ELFSymbolData &MSD : ExternalSymbolData) {
|
||||||
MSD.StringIndex = StrTabBuilder.getOffset(MSD.Name);
|
unsigned StringIndex = StrTabBuilder.getOffset(MSD.Name);
|
||||||
MSD.Symbol->setIndex(Index++);
|
MSD.Symbol->setIndex(Index++);
|
||||||
WriteSymbol(Writer, MSD, Layout);
|
writeSymbol(Writer, StringIndex, MSD, Layout);
|
||||||
assert(MCELF::GetBinding(MSD.Symbol->getData()) != ELF::STB_LOCAL);
|
assert(MCELF::GetBinding(MSD.Symbol->getData()) != ELF::STB_LOCAL);
|
||||||
}
|
}
|
||||||
for (ELFSymbolData &MSD : UndefinedSymbolData) {
|
for (ELFSymbolData &MSD : UndefinedSymbolData) {
|
||||||
MSD.StringIndex = StrTabBuilder.getOffset(MSD.Name);
|
unsigned StringIndex = StrTabBuilder.getOffset(MSD.Name);
|
||||||
MSD.Symbol->setIndex(Index++);
|
MSD.Symbol->setIndex(Index++);
|
||||||
WriteSymbol(Writer, MSD, Layout);
|
writeSymbol(Writer, StringIndex, MSD, Layout);
|
||||||
assert(MCELF::GetBinding(MSD.Symbol->getData()) != ELF::STB_LOCAL);
|
assert(MCELF::GetBinding(MSD.Symbol->getData()) != ELF::STB_LOCAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user