mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
Spread some const around for non-mutating uses of MCSymbolData.
I discovered this const-hole while attempting to coalesnce the Symbol and SymbolMap data structures. There's some pending issues with that, but I figured this change was easy to flush early. llvm-svn: 207124
This commit is contained in:
parent
e7b7e6a483
commit
52ea9cc073
@ -1207,7 +1207,13 @@ public:
|
|||||||
return SymbolMap.lookup(&Symbol) != nullptr;
|
return SymbolMap.lookup(&Symbol) != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
MCSymbolData &getSymbolData(const MCSymbol &Symbol) const {
|
MCSymbolData &getSymbolData(const MCSymbol &Symbol) {
|
||||||
|
MCSymbolData *Entry = SymbolMap.lookup(&Symbol);
|
||||||
|
assert(Entry && "Missing symbol data!");
|
||||||
|
return *Entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
const MCSymbolData &getSymbolData(const MCSymbol &Symbol) const {
|
||||||
MCSymbolData *Entry = SymbolMap.lookup(&Symbol);
|
MCSymbolData *Entry = SymbolMap.lookup(&Symbol);
|
||||||
assert(Entry && "Missing symbol data!");
|
assert(Entry && "Missing symbol data!");
|
||||||
return *Entry;
|
return *Entry;
|
||||||
|
@ -925,7 +925,7 @@ void ELFObjectWriter::RecordRelocation(const MCAssembler &Asm,
|
|||||||
uint64_t
|
uint64_t
|
||||||
ELFObjectWriter::getSymbolIndexInSymbolTable(const MCAssembler &Asm,
|
ELFObjectWriter::getSymbolIndexInSymbolTable(const MCAssembler &Asm,
|
||||||
const MCSymbol *S) {
|
const MCSymbol *S) {
|
||||||
MCSymbolData &SD = Asm.getSymbolData(*S);
|
const MCSymbolData &SD = Asm.getSymbolData(*S);
|
||||||
return SD.getIndex();
|
return SD.getIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,8 +506,8 @@ static void AttemptToFoldSymbolOffsetDifference(const MCAssembler *Asm,
|
|||||||
if (!Asm->getWriter().IsSymbolRefDifferenceFullyResolved(*Asm, A, B, InSet))
|
if (!Asm->getWriter().IsSymbolRefDifferenceFullyResolved(*Asm, A, B, InSet))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MCSymbolData &AD = Asm->getSymbolData(SA);
|
const MCSymbolData &AD = Asm->getSymbolData(SA);
|
||||||
MCSymbolData &BD = Asm->getSymbolData(SB);
|
const MCSymbolData &BD = Asm->getSymbolData(SB);
|
||||||
|
|
||||||
if (AD.getFragment() == BD.getFragment()) {
|
if (AD.getFragment() == BD.getFragment()) {
|
||||||
Addend += (AD.getOffset() - BD.getOffset());
|
Addend += (AD.getOffset() - BD.getOffset());
|
||||||
|
@ -686,7 +686,7 @@ void WinCOFFObjectWriter::RecordRelocation(const MCAssembler &Asm,
|
|||||||
Fixup.getLoc(),
|
Fixup.getLoc(),
|
||||||
Twine("symbol '") + A.getName() + "' can not be undefined");
|
Twine("symbol '") + A.getName() + "' can not be undefined");
|
||||||
|
|
||||||
MCSymbolData &A_SD = Asm.getSymbolData(A);
|
const MCSymbolData &A_SD = Asm.getSymbolData(A);
|
||||||
|
|
||||||
MCSectionData const *SectionData = Fragment->getParent();
|
MCSectionData const *SectionData = Fragment->getParent();
|
||||||
|
|
||||||
@ -703,7 +703,7 @@ void WinCOFFObjectWriter::RecordRelocation(const MCAssembler &Asm,
|
|||||||
|
|
||||||
if (SymB) {
|
if (SymB) {
|
||||||
const MCSymbol *B = &SymB->getSymbol();
|
const MCSymbol *B = &SymB->getSymbol();
|
||||||
MCSymbolData &B_SD = Asm.getSymbolData(*B);
|
const MCSymbolData &B_SD = Asm.getSymbolData(*B);
|
||||||
if (!B_SD.getFragment())
|
if (!B_SD.getFragment())
|
||||||
Asm.getContext().FatalError(
|
Asm.getContext().FatalError(
|
||||||
Fixup.getLoc(),
|
Fixup.getLoc(),
|
||||||
|
@ -603,7 +603,7 @@ void ARMAsmBackend::processFixupValue(const MCAssembler &Asm,
|
|||||||
// the offset when the destination has the same MCFragment.
|
// the offset when the destination has the same MCFragment.
|
||||||
if (A && (unsigned)Fixup.getKind() == ARM::fixup_arm_thumb_bl) {
|
if (A && (unsigned)Fixup.getKind() == ARM::fixup_arm_thumb_bl) {
|
||||||
const MCSymbol &Sym = A->getSymbol().AliasedSymbol();
|
const MCSymbol &Sym = A->getSymbol().AliasedSymbol();
|
||||||
MCSymbolData &SymData = Asm.getSymbolData(Sym);
|
const MCSymbolData &SymData = Asm.getSymbolData(Sym);
|
||||||
IsResolved = (SymData.getFragment() == DF);
|
IsResolved = (SymData.getFragment() == DF);
|
||||||
}
|
}
|
||||||
// We must always generate a relocation for BL/BLX instructions if we have
|
// We must always generate a relocation for BL/BLX instructions if we have
|
||||||
|
@ -156,7 +156,7 @@ RecordARMScatteredHalfRelocation(MachObjectWriter *Writer,
|
|||||||
|
|
||||||
// See <reloc.h>.
|
// See <reloc.h>.
|
||||||
const MCSymbol *A = &Target.getSymA()->getSymbol();
|
const MCSymbol *A = &Target.getSymA()->getSymbol();
|
||||||
MCSymbolData *A_SD = &Asm.getSymbolData(*A);
|
const MCSymbolData *A_SD = &Asm.getSymbolData(*A);
|
||||||
|
|
||||||
if (!A_SD->getFragment())
|
if (!A_SD->getFragment())
|
||||||
Asm.getContext().FatalError(Fixup.getLoc(),
|
Asm.getContext().FatalError(Fixup.getLoc(),
|
||||||
@ -170,7 +170,7 @@ RecordARMScatteredHalfRelocation(MachObjectWriter *Writer,
|
|||||||
FixedValue += SecAddr;
|
FixedValue += SecAddr;
|
||||||
|
|
||||||
if (const MCSymbolRefExpr *B = Target.getSymB()) {
|
if (const MCSymbolRefExpr *B = Target.getSymB()) {
|
||||||
MCSymbolData *B_SD = &Asm.getSymbolData(B->getSymbol());
|
const MCSymbolData *B_SD = &Asm.getSymbolData(B->getSymbol());
|
||||||
|
|
||||||
if (!B_SD->getFragment())
|
if (!B_SD->getFragment())
|
||||||
Asm.getContext().FatalError(Fixup.getLoc(),
|
Asm.getContext().FatalError(Fixup.getLoc(),
|
||||||
@ -259,7 +259,7 @@ void ARMMachObjectWriter::RecordARMScatteredRelocation(MachObjectWriter *Writer,
|
|||||||
|
|
||||||
// See <reloc.h>.
|
// See <reloc.h>.
|
||||||
const MCSymbol *A = &Target.getSymA()->getSymbol();
|
const MCSymbol *A = &Target.getSymA()->getSymbol();
|
||||||
MCSymbolData *A_SD = &Asm.getSymbolData(*A);
|
const MCSymbolData *A_SD = &Asm.getSymbolData(*A);
|
||||||
|
|
||||||
if (!A_SD->getFragment())
|
if (!A_SD->getFragment())
|
||||||
Asm.getContext().FatalError(Fixup.getLoc(),
|
Asm.getContext().FatalError(Fixup.getLoc(),
|
||||||
@ -272,7 +272,7 @@ void ARMMachObjectWriter::RecordARMScatteredRelocation(MachObjectWriter *Writer,
|
|||||||
uint32_t Value2 = 0;
|
uint32_t Value2 = 0;
|
||||||
|
|
||||||
if (const MCSymbolRefExpr *B = Target.getSymB()) {
|
if (const MCSymbolRefExpr *B = Target.getSymB()) {
|
||||||
MCSymbolData *B_SD = &Asm.getSymbolData(B->getSymbol());
|
const MCSymbolData *B_SD = &Asm.getSymbolData(B->getSymbol());
|
||||||
|
|
||||||
if (!B_SD->getFragment())
|
if (!B_SD->getFragment())
|
||||||
Asm.getContext().FatalError(Fixup.getLoc(),
|
Asm.getContext().FatalError(Fixup.getLoc(),
|
||||||
@ -378,7 +378,7 @@ void ARMMachObjectWriter::RecordRelocation(MachObjectWriter *Writer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the symbol data, if any.
|
// Get the symbol data, if any.
|
||||||
MCSymbolData *SD = 0;
|
const MCSymbolData *SD = 0;
|
||||||
if (Target.getSymA())
|
if (Target.getSymA())
|
||||||
SD = &Asm.getSymbolData(Target.getSymA()->getSymbol());
|
SD = &Asm.getSymbolData(Target.getSymA()->getSymbol());
|
||||||
|
|
||||||
|
@ -183,11 +183,11 @@ void ARM64MachObjectWriter::RecordRelocation(
|
|||||||
}
|
}
|
||||||
} else if (Target.getSymB()) { // A - B + constant
|
} else if (Target.getSymB()) { // A - B + constant
|
||||||
const MCSymbol *A = &Target.getSymA()->getSymbol();
|
const MCSymbol *A = &Target.getSymA()->getSymbol();
|
||||||
MCSymbolData &A_SD = Asm.getSymbolData(*A);
|
const MCSymbolData &A_SD = Asm.getSymbolData(*A);
|
||||||
const MCSymbolData *A_Base = Asm.getAtom(&A_SD);
|
const MCSymbolData *A_Base = Asm.getAtom(&A_SD);
|
||||||
|
|
||||||
const MCSymbol *B = &Target.getSymB()->getSymbol();
|
const MCSymbol *B = &Target.getSymB()->getSymbol();
|
||||||
MCSymbolData &B_SD = Asm.getSymbolData(*B);
|
const MCSymbolData &B_SD = Asm.getSymbolData(*B);
|
||||||
const MCSymbolData *B_Base = Asm.getAtom(&B_SD);
|
const MCSymbolData *B_Base = Asm.getAtom(&B_SD);
|
||||||
|
|
||||||
// Check for "_foo@got - .", which comes through here as:
|
// Check for "_foo@got - .", which comes through here as:
|
||||||
@ -267,7 +267,7 @@ void ARM64MachObjectWriter::RecordRelocation(
|
|||||||
Type = MachO::ARM64_RELOC_SUBTRACTOR;
|
Type = MachO::ARM64_RELOC_SUBTRACTOR;
|
||||||
} else { // A + constant
|
} else { // A + constant
|
||||||
const MCSymbol *Symbol = &Target.getSymA()->getSymbol();
|
const MCSymbol *Symbol = &Target.getSymA()->getSymbol();
|
||||||
MCSymbolData &SD = Asm.getSymbolData(*Symbol);
|
const MCSymbolData &SD = Asm.getSymbolData(*Symbol);
|
||||||
const MCSymbolData *Base = Asm.getAtom(&SD);
|
const MCSymbolData *Base = Asm.getAtom(&SD);
|
||||||
const MCSectionMachO &Section = static_cast<const MCSectionMachO &>(
|
const MCSectionMachO &Section = static_cast<const MCSectionMachO &>(
|
||||||
Fragment->getParent()->getSection());
|
Fragment->getParent()->getSection());
|
||||||
|
@ -206,7 +206,7 @@ bool PPCMachObjectWriter::RecordScatteredRelocation(
|
|||||||
|
|
||||||
// See <reloc.h>.
|
// See <reloc.h>.
|
||||||
const MCSymbol *A = &Target.getSymA()->getSymbol();
|
const MCSymbol *A = &Target.getSymA()->getSymbol();
|
||||||
MCSymbolData *A_SD = &Asm.getSymbolData(*A);
|
const MCSymbolData *A_SD = &Asm.getSymbolData(*A);
|
||||||
|
|
||||||
if (!A_SD->getFragment())
|
if (!A_SD->getFragment())
|
||||||
report_fatal_error("symbol '" + A->getName() +
|
report_fatal_error("symbol '" + A->getName() +
|
||||||
@ -219,7 +219,7 @@ bool PPCMachObjectWriter::RecordScatteredRelocation(
|
|||||||
uint32_t Value2 = 0;
|
uint32_t Value2 = 0;
|
||||||
|
|
||||||
if (const MCSymbolRefExpr *B = Target.getSymB()) {
|
if (const MCSymbolRefExpr *B = Target.getSymB()) {
|
||||||
MCSymbolData *B_SD = &Asm.getSymbolData(B->getSymbol());
|
const MCSymbolData *B_SD = &Asm.getSymbolData(B->getSymbol());
|
||||||
|
|
||||||
if (!B_SD->getFragment())
|
if (!B_SD->getFragment())
|
||||||
report_fatal_error("symbol '" + B->getSymbol().getName() +
|
report_fatal_error("symbol '" + B->getSymbol().getName() +
|
||||||
@ -324,7 +324,7 @@ void PPCMachObjectWriter::RecordPPCRelocation(
|
|||||||
|
|
||||||
// this doesn't seem right for RIT_PPC_BR24
|
// this doesn't seem right for RIT_PPC_BR24
|
||||||
// Get the symbol data, if any.
|
// Get the symbol data, if any.
|
||||||
MCSymbolData *SD = 0;
|
const MCSymbolData *SD = 0;
|
||||||
if (Target.getSymA())
|
if (Target.getSymA())
|
||||||
SD = &Asm.getSymbolData(Target.getSymA()->getSymbol());
|
SD = &Asm.getSymbolData(Target.getSymA()->getSymbol());
|
||||||
|
|
||||||
|
@ -146,13 +146,13 @@ void X86MachObjectWriter::RecordX86_64Relocation(MachObjectWriter *Writer,
|
|||||||
const MCSymbol *A = &Target.getSymA()->getSymbol();
|
const MCSymbol *A = &Target.getSymA()->getSymbol();
|
||||||
if (A->isTemporary())
|
if (A->isTemporary())
|
||||||
A = &A->AliasedSymbol();
|
A = &A->AliasedSymbol();
|
||||||
MCSymbolData &A_SD = Asm.getSymbolData(*A);
|
const MCSymbolData &A_SD = Asm.getSymbolData(*A);
|
||||||
const MCSymbolData *A_Base = Asm.getAtom(&A_SD);
|
const MCSymbolData *A_Base = Asm.getAtom(&A_SD);
|
||||||
|
|
||||||
const MCSymbol *B = &Target.getSymB()->getSymbol();
|
const MCSymbol *B = &Target.getSymB()->getSymbol();
|
||||||
if (B->isTemporary())
|
if (B->isTemporary())
|
||||||
B = &B->AliasedSymbol();
|
B = &B->AliasedSymbol();
|
||||||
MCSymbolData &B_SD = Asm.getSymbolData(*B);
|
const MCSymbolData &B_SD = Asm.getSymbolData(*B);
|
||||||
const MCSymbolData *B_Base = Asm.getAtom(&B_SD);
|
const MCSymbolData *B_Base = Asm.getAtom(&B_SD);
|
||||||
|
|
||||||
// Neither symbol can be modified.
|
// Neither symbol can be modified.
|
||||||
@ -220,7 +220,7 @@ void X86MachObjectWriter::RecordX86_64Relocation(MachObjectWriter *Writer,
|
|||||||
Type = MachO::X86_64_RELOC_SUBTRACTOR;
|
Type = MachO::X86_64_RELOC_SUBTRACTOR;
|
||||||
} else {
|
} else {
|
||||||
const MCSymbol *Symbol = &Target.getSymA()->getSymbol();
|
const MCSymbol *Symbol = &Target.getSymA()->getSymbol();
|
||||||
MCSymbolData &SD = Asm.getSymbolData(*Symbol);
|
const MCSymbolData &SD = Asm.getSymbolData(*Symbol);
|
||||||
const MCSymbolData *Base = Asm.getAtom(&SD);
|
const MCSymbolData *Base = Asm.getAtom(&SD);
|
||||||
|
|
||||||
// Relocations inside debug sections always use local relocations when
|
// Relocations inside debug sections always use local relocations when
|
||||||
@ -369,7 +369,7 @@ bool X86MachObjectWriter::RecordScatteredRelocation(MachObjectWriter *Writer,
|
|||||||
|
|
||||||
// See <reloc.h>.
|
// See <reloc.h>.
|
||||||
const MCSymbol *A = &Target.getSymA()->getSymbol();
|
const MCSymbol *A = &Target.getSymA()->getSymbol();
|
||||||
MCSymbolData *A_SD = &Asm.getSymbolData(*A);
|
const MCSymbolData *A_SD = &Asm.getSymbolData(*A);
|
||||||
|
|
||||||
if (!A_SD->getFragment())
|
if (!A_SD->getFragment())
|
||||||
report_fatal_error("symbol '" + A->getName() +
|
report_fatal_error("symbol '" + A->getName() +
|
||||||
@ -382,7 +382,7 @@ bool X86MachObjectWriter::RecordScatteredRelocation(MachObjectWriter *Writer,
|
|||||||
uint32_t Value2 = 0;
|
uint32_t Value2 = 0;
|
||||||
|
|
||||||
if (const MCSymbolRefExpr *B = Target.getSymB()) {
|
if (const MCSymbolRefExpr *B = Target.getSymB()) {
|
||||||
MCSymbolData *B_SD = &Asm.getSymbolData(B->getSymbol());
|
const MCSymbolData *B_SD = &Asm.getSymbolData(B->getSymbol());
|
||||||
|
|
||||||
if (!B_SD->getFragment())
|
if (!B_SD->getFragment())
|
||||||
report_fatal_error("symbol '" + B->getSymbol().getName() +
|
report_fatal_error("symbol '" + B->getSymbol().getName() +
|
||||||
@ -465,7 +465,7 @@ void X86MachObjectWriter::RecordTLVPRelocation(MachObjectWriter *Writer,
|
|||||||
unsigned IsPCRel = 0;
|
unsigned IsPCRel = 0;
|
||||||
|
|
||||||
// Get the symbol data.
|
// Get the symbol data.
|
||||||
MCSymbolData *SD_A = &Asm.getSymbolData(Target.getSymA()->getSymbol());
|
const MCSymbolData *SD_A = &Asm.getSymbolData(Target.getSymA()->getSymbol());
|
||||||
unsigned Index = SD_A->getIndex();
|
unsigned Index = SD_A->getIndex();
|
||||||
|
|
||||||
// We're only going to have a second symbol in pic mode and it'll be a
|
// We're only going to have a second symbol in pic mode and it'll be a
|
||||||
@ -476,7 +476,8 @@ void X86MachObjectWriter::RecordTLVPRelocation(MachObjectWriter *Writer,
|
|||||||
// If this is a subtraction then we're pcrel.
|
// If this is a subtraction then we're pcrel.
|
||||||
uint32_t FixupAddress =
|
uint32_t FixupAddress =
|
||||||
Writer->getFragmentAddress(Fragment, Layout) + Fixup.getOffset();
|
Writer->getFragmentAddress(Fragment, Layout) + Fixup.getOffset();
|
||||||
MCSymbolData *SD_B = &Asm.getSymbolData(Target.getSymB()->getSymbol());
|
const MCSymbolData *SD_B =
|
||||||
|
&Asm.getSymbolData(Target.getSymB()->getSymbol());
|
||||||
IsPCRel = 1;
|
IsPCRel = 1;
|
||||||
FixedValue = (FixupAddress - Writer->getSymbolAddress(SD_B, Layout) +
|
FixedValue = (FixupAddress - Writer->getSymbolAddress(SD_B, Layout) +
|
||||||
Target.getConstant());
|
Target.getConstant());
|
||||||
@ -524,7 +525,7 @@ void X86MachObjectWriter::RecordX86Relocation(MachObjectWriter *Writer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the symbol data, if any.
|
// Get the symbol data, if any.
|
||||||
MCSymbolData *SD = 0;
|
const MCSymbolData *SD = 0;
|
||||||
if (Target.getSymA())
|
if (Target.getSymA())
|
||||||
SD = &Asm.getSymbolData(Target.getSymA()->getSymbol());
|
SD = &Asm.getSymbolData(Target.getSymA()->getSymbol());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user