/// Atom - The atom this fragment is in, as represented by it's defining
/// symbol.
- MCSymbolData *Atom;
+ const MCSymbol *Atom;
/// \name Assembler Backend Data
/// @{
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; }
/// 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
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())
// 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);
}
}
// - 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();
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.
unsigned Index = 0;
unsigned Type = 0;
unsigned Kind = Fixup.getKind();
- const MCSymbolData *RelSymbol = nullptr;
+ const MCSymbol *RelSymbol = nullptr;
FixupOffset += Fixup.getOffset();
} 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:
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)
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;
}
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
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(
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;
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,
unsigned Index = 0;
unsigned IsExtern = 0;
unsigned Type = 0;
- const MCSymbolData *RelSymbol = nullptr;
+ const MCSymbol *RelSymbol = nullptr;
Value = Target.getConstant();
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 ||
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;
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;
// 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;
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,