mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-24 12:29:33 +00:00
MC: Change MCFragment::Atom to an MCSymbol, NFC
Change `MCFragment::Atom` from an `MCSymbolData` to an `MCSymbol`, moving in the direction of removing the back-pointer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237497 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a5bb842d95
commit
5f7c1f8415
@ -70,7 +70,7 @@ private:
|
||||
|
||||
/// Atom - The atom this fragment is in, as represented by it's defining
|
||||
/// symbol.
|
||||
MCSymbolData *Atom;
|
||||
const MCSymbol *Atom;
|
||||
|
||||
/// \name Assembler Backend Data
|
||||
/// @{
|
||||
@ -99,8 +99,8 @@ public:
|
||||
MCSectionData *getParent() const { return Parent; }
|
||||
void setParent(MCSectionData *Value) { Parent = Value; }
|
||||
|
||||
MCSymbolData *getAtom() const { return Atom; }
|
||||
void setAtom(MCSymbolData *Value) { Atom = Value; }
|
||||
const MCSymbol *getAtom() const { return Atom; }
|
||||
void setAtom(const MCSymbol *Value) { Atom = Value; }
|
||||
|
||||
unsigned getLayoutOrder() const { return LayoutOrder; }
|
||||
void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
|
||||
@ -834,7 +834,7 @@ public:
|
||||
|
||||
/// Find the symbol which defines the atom containing the given symbol, or
|
||||
/// null if there is no such symbol.
|
||||
const MCSymbolData *getAtom(const MCSymbolData *Symbol) const;
|
||||
const MCSymbol *getAtom(const MCSymbolData *Symbol) const;
|
||||
|
||||
/// Check whether a particular symbol is visible to the linker and is required
|
||||
/// in the symbol table, or whether it can be discarded by the assembler. This
|
||||
|
@ -460,10 +460,10 @@ bool MCAssembler::isSymbolLinkerVisible(const MCSymbol &Symbol) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
const MCSymbolData *MCAssembler::getAtom(const MCSymbolData *SD) const {
|
||||
const MCSymbol *MCAssembler::getAtom(const MCSymbolData *SD) const {
|
||||
// Linker visible symbols define atoms.
|
||||
if (isSymbolLinkerVisible(SD->getSymbol()))
|
||||
return SD;
|
||||
return &SD->getSymbol();
|
||||
|
||||
// Absolute and undefined symbols have no defining atom.
|
||||
if (!SD->getFragment())
|
||||
|
@ -478,11 +478,11 @@ void MCMachOStreamer::FinishImpl() {
|
||||
// symbol.
|
||||
for (MCAssembler::iterator it = getAssembler().begin(),
|
||||
ie = getAssembler().end(); it != ie; ++it) {
|
||||
MCSymbolData *CurrentAtom = nullptr;
|
||||
const MCSymbol *CurrentAtom = nullptr;
|
||||
for (MCSectionData::iterator it2 = it->begin(),
|
||||
ie2 = it->end(); it2 != ie2; ++it2) {
|
||||
if (MCSymbolData *SD = DefiningSymbolMap.lookup(it2))
|
||||
CurrentAtom = SD;
|
||||
CurrentAtom = &SD->getSymbol();
|
||||
it2->setAtom(CurrentAtom);
|
||||
}
|
||||
}
|
||||
|
@ -679,8 +679,6 @@ bool MachObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(
|
||||
// - addr(atom(B)) - offset(B)
|
||||
// and the offsets are not relocatable, so the fixup is fully resolved when
|
||||
// addr(atom(A)) - addr(atom(B)) == 0.
|
||||
const MCSymbolData *A_Base = nullptr, *B_Base = nullptr;
|
||||
|
||||
const MCSymbol &SA = findAliasedSymbol(DataA.getSymbol());
|
||||
const MCSection &SecA = SA.getSection();
|
||||
const MCSection &SecB = FB.getParent()->getSection();
|
||||
@ -733,11 +731,8 @@ bool MachObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(
|
||||
if (!FA)
|
||||
return false;
|
||||
|
||||
A_Base = FA->getAtom();
|
||||
B_Base = FB.getAtom();
|
||||
|
||||
// If the atoms are the same, they are guaranteed to have the same address.
|
||||
if (A_Base == B_Base)
|
||||
if (FA->getAtom() == FB.getAtom())
|
||||
return true;
|
||||
|
||||
// Otherwise, we can't prove this is fully resolved.
|
||||
|
@ -154,7 +154,7 @@ void AArch64MachObjectWriter::RecordRelocation(
|
||||
unsigned Index = 0;
|
||||
unsigned Type = 0;
|
||||
unsigned Kind = Fixup.getKind();
|
||||
const MCSymbolData *RelSymbol = nullptr;
|
||||
const MCSymbol *RelSymbol = nullptr;
|
||||
|
||||
FixupOffset += Fixup.getOffset();
|
||||
|
||||
@ -211,11 +211,11 @@ void AArch64MachObjectWriter::RecordRelocation(
|
||||
} else if (Target.getSymB()) { // A - B + constant
|
||||
const MCSymbol *A = &Target.getSymA()->getSymbol();
|
||||
const MCSymbolData &A_SD = Asm.getSymbolData(*A);
|
||||
const MCSymbolData *A_Base = Asm.getAtom(&A_SD);
|
||||
const MCSymbol *A_Base = Asm.getAtom(&A_SD);
|
||||
|
||||
const MCSymbol *B = &Target.getSymB()->getSymbol();
|
||||
const MCSymbolData &B_SD = Asm.getSymbolData(*B);
|
||||
const MCSymbolData *B_Base = Asm.getAtom(&B_SD);
|
||||
const MCSymbol *B_Base = Asm.getAtom(&B_SD);
|
||||
|
||||
// Check for "_foo@got - .", which comes through here as:
|
||||
// Ltmp0:
|
||||
@ -230,7 +230,8 @@ void AArch64MachObjectWriter::RecordRelocation(
|
||||
MachO::any_relocation_info MRE;
|
||||
MRE.r_word0 = FixupOffset;
|
||||
MRE.r_word1 = (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
|
||||
Writer->addRelocation(A_Base, Fragment->getParent(), MRE);
|
||||
Writer->addRelocation(A_Base ? &A_Base->getData() : nullptr,
|
||||
Fragment->getParent(), MRE);
|
||||
return;
|
||||
} else if (Target.getSymA()->getKind() != MCSymbolRefExpr::VK_None ||
|
||||
Target.getSymB()->getKind() != MCSymbolRefExpr::VK_None)
|
||||
@ -265,23 +266,24 @@ void AArch64MachObjectWriter::RecordRelocation(
|
||||
Asm.getContext().FatalError(Fixup.getLoc(),
|
||||
"unsupported relocation with identical base");
|
||||
|
||||
Value += (!A_SD.getFragment() ? 0
|
||||
: Writer->getSymbolAddress(&A_SD, Layout)) -
|
||||
(!A_Base || !A_Base->getFragment()
|
||||
? 0
|
||||
: Writer->getSymbolAddress(A_Base, Layout));
|
||||
Value -= (!B_SD.getFragment() ? 0
|
||||
: Writer->getSymbolAddress(&B_SD, Layout)) -
|
||||
(!B_Base || !B_Base->getFragment()
|
||||
? 0
|
||||
: Writer->getSymbolAddress(B_Base, Layout));
|
||||
Value +=
|
||||
(!A_SD.getFragment() ? 0 : Writer->getSymbolAddress(&A_SD, Layout)) -
|
||||
(!A_Base || !A_Base->getData().getFragment()
|
||||
? 0
|
||||
: Writer->getSymbolAddress(&A_Base->getData(), Layout));
|
||||
Value -=
|
||||
(!B_SD.getFragment() ? 0 : Writer->getSymbolAddress(&B_SD, Layout)) -
|
||||
(!B_Base || !B_Base->getData().getFragment()
|
||||
? 0
|
||||
: Writer->getSymbolAddress(&B_Base->getData(), Layout));
|
||||
|
||||
Type = MachO::ARM64_RELOC_UNSIGNED;
|
||||
|
||||
MachO::any_relocation_info MRE;
|
||||
MRE.r_word0 = FixupOffset;
|
||||
MRE.r_word1 = (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
|
||||
Writer->addRelocation(A_Base, Fragment->getParent(), MRE);
|
||||
Writer->addRelocation(A_Base ? &A_Base->getData() : nullptr,
|
||||
Fragment->getParent(), MRE);
|
||||
|
||||
RelSymbol = B_Base;
|
||||
Type = MachO::ARM64_RELOC_SUBTRACTOR;
|
||||
@ -299,7 +301,7 @@ void AArch64MachObjectWriter::RecordRelocation(
|
||||
}
|
||||
|
||||
const MCSymbolData &SD = Asm.getSymbolData(*Symbol);
|
||||
const MCSymbolData *Base = Asm.getAtom(&SD);
|
||||
const MCSymbol *Base = Asm.getAtom(&SD);
|
||||
|
||||
// If the symbol is a variable and we weren't able to get a Base for it
|
||||
// (i.e., it's not in the symbol table associated with a section) resolve
|
||||
@ -342,8 +344,9 @@ void AArch64MachObjectWriter::RecordRelocation(
|
||||
RelSymbol = Base;
|
||||
|
||||
// Add the local offset, if needed.
|
||||
if (Base != &SD)
|
||||
Value += Layout.getSymbolOffset(&SD) - Layout.getSymbolOffset(Base);
|
||||
if (&Base->getData() != &SD)
|
||||
Value += Layout.getSymbolOffset(&SD) -
|
||||
Layout.getSymbolOffset(&Base->getData());
|
||||
} else if (Symbol->isInSection()) {
|
||||
if (!CanUseLocalRelocation)
|
||||
Asm.getContext().FatalError(
|
||||
@ -389,7 +392,8 @@ void AArch64MachObjectWriter::RecordRelocation(
|
||||
MRE.r_word0 = FixupOffset;
|
||||
MRE.r_word1 =
|
||||
(Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
|
||||
Writer->addRelocation(RelSymbol, Fragment->getParent(), MRE);
|
||||
Writer->addRelocation(RelSymbol ? &RelSymbol->getData() : nullptr,
|
||||
Fragment->getParent(), MRE);
|
||||
|
||||
// Now set up the Addend relocation.
|
||||
Type = MachO::ARM64_RELOC_ADDEND;
|
||||
@ -410,7 +414,8 @@ void AArch64MachObjectWriter::RecordRelocation(
|
||||
MRE.r_word0 = FixupOffset;
|
||||
MRE.r_word1 =
|
||||
(Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
|
||||
Writer->addRelocation(RelSymbol, Fragment->getParent(), MRE);
|
||||
Writer->addRelocation(RelSymbol ? &RelSymbol->getData() : nullptr,
|
||||
Fragment->getParent(), MRE);
|
||||
}
|
||||
|
||||
MCObjectWriter *llvm::createAArch64MachObjectWriter(raw_pwrite_stream &OS,
|
||||
|
@ -113,7 +113,7 @@ void X86MachObjectWriter::RecordX86_64Relocation(
|
||||
unsigned Index = 0;
|
||||
unsigned IsExtern = 0;
|
||||
unsigned Type = 0;
|
||||
const MCSymbolData *RelSymbol = nullptr;
|
||||
const MCSymbol *RelSymbol = nullptr;
|
||||
|
||||
Value = Target.getConstant();
|
||||
|
||||
@ -143,13 +143,13 @@ void X86MachObjectWriter::RecordX86_64Relocation(
|
||||
if (A->isTemporary())
|
||||
A = &Writer->findAliasedSymbol(*A);
|
||||
const MCSymbolData &A_SD = Asm.getSymbolData(*A);
|
||||
const MCSymbolData *A_Base = Asm.getAtom(&A_SD);
|
||||
const MCSymbol *A_Base = Asm.getAtom(&A_SD);
|
||||
|
||||
const MCSymbol *B = &Target.getSymB()->getSymbol();
|
||||
if (B->isTemporary())
|
||||
B = &Writer->findAliasedSymbol(*B);
|
||||
const MCSymbolData &B_SD = Asm.getSymbolData(*B);
|
||||
const MCSymbolData *B_Base = Asm.getAtom(&B_SD);
|
||||
const MCSymbol *B_Base = Asm.getAtom(&B_SD);
|
||||
|
||||
// Neither symbol can be modified.
|
||||
if (Target.getSymA()->getKind() != MCSymbolRefExpr::VK_None ||
|
||||
@ -184,10 +184,12 @@ void X86MachObjectWriter::RecordX86_64Relocation(
|
||||
Name + "' can not be undefined in a subtraction expression");
|
||||
}
|
||||
|
||||
Value += Writer->getSymbolAddress(&A_SD, Layout) -
|
||||
(!A_Base ? 0 : Writer->getSymbolAddress(A_Base, Layout));
|
||||
Value -= Writer->getSymbolAddress(&B_SD, Layout) -
|
||||
(!B_Base ? 0 : Writer->getSymbolAddress(B_Base, Layout));
|
||||
Value +=
|
||||
Writer->getSymbolAddress(&A_SD, Layout) -
|
||||
(!A_Base ? 0 : Writer->getSymbolAddress(&A_Base->getData(), Layout));
|
||||
Value -=
|
||||
Writer->getSymbolAddress(&B_SD, Layout) -
|
||||
(!B_Base ? 0 : Writer->getSymbolAddress(&B_Base->getData(), Layout));
|
||||
|
||||
if (!A_Base)
|
||||
Index = A_SD.getFragment()->getParent()->getOrdinal() + 1;
|
||||
@ -197,7 +199,8 @@ void X86MachObjectWriter::RecordX86_64Relocation(
|
||||
MRE.r_word0 = FixupOffset;
|
||||
MRE.r_word1 =
|
||||
(Index << 0) | (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
|
||||
Writer->addRelocation(A_Base, Fragment->getParent(), MRE);
|
||||
Writer->addRelocation(A_Base ? &A_Base->getData() : nullptr,
|
||||
Fragment->getParent(), MRE);
|
||||
|
||||
if (B_Base)
|
||||
RelSymbol = B_Base;
|
||||
@ -230,9 +233,9 @@ void X86MachObjectWriter::RecordX86_64Relocation(
|
||||
// non-local symbol).
|
||||
if (RelSymbol) {
|
||||
// Add the local offset, if needed.
|
||||
if (RelSymbol != &SD)
|
||||
Value +=
|
||||
Layout.getSymbolOffset(&SD) - Layout.getSymbolOffset(RelSymbol);
|
||||
if (&RelSymbol->getData() != &SD)
|
||||
Value += Layout.getSymbolOffset(&SD) -
|
||||
Layout.getSymbolOffset(&RelSymbol->getData());
|
||||
} else if (Symbol->isInSection() && !Symbol->isVariable()) {
|
||||
// The index is the section ordinal (1-based).
|
||||
Index = SD.getFragment()->getParent()->getOrdinal() + 1;
|
||||
@ -336,7 +339,8 @@ void X86MachObjectWriter::RecordX86_64Relocation(
|
||||
MRE.r_word0 = FixupOffset;
|
||||
MRE.r_word1 = (Index << 0) | (IsPCRel << 24) | (Log2Size << 25) |
|
||||
(IsExtern << 27) | (Type << 28);
|
||||
Writer->addRelocation(RelSymbol, Fragment->getParent(), MRE);
|
||||
Writer->addRelocation(RelSymbol ? &RelSymbol->getData() : nullptr,
|
||||
Fragment->getParent(), MRE);
|
||||
}
|
||||
|
||||
bool X86MachObjectWriter::RecordScatteredRelocation(MachObjectWriter *Writer,
|
||||
|
Loading…
x
Reference in New Issue
Block a user