#include "llvm/Support/ELF.h"
-// Because all the symbol flags need to be stored in the MCSymbolData
+// Because all the symbol flags need to be stored in the MCSymbol
// 'flags' variable we need to provide shift constants per flag type.
namespace llvm {
void dump() const;
};
-typedef MCSymbol MCSymbolData;
-
inline raw_ostream &operator<<(raw_ostream &OS, const MCSymbol &Sym) {
Sym.print(OS);
return OS;
uint64_t ELFObjectWriter::SymbolValue(const MCSymbol &Sym,
const MCAsmLayout &Layout) {
- MCSymbolData &Data = Sym.getData();
+ MCSymbol &Data = Sym.getData();
if (Sym.isCommon() && Data.isExternal())
return Sym.getCommonAlignment();
// versions declared with @@@ to be renamed.
for (const MCSymbol &Alias : Asm.symbols()) {
- MCSymbolData &OriginalData = Alias.getData();
+ MCSymbol &OriginalData = Alias.getData();
// Not an alias.
if (!Alias.isVariable())
if (!Ref)
continue;
const MCSymbol &Symbol = Ref->getSymbol();
- MCSymbolData &SD = Symbol.getData();
+ MCSymbol &SD = Symbol.getData();
StringRef AliasName = Alias.getName();
size_t Pos = AliasName.find('@');
uint32_t StringIndex, ELFSymbolData &MSD,
const MCAsmLayout &Layout) {
#ifndef NDEBUG
- MCSymbolData &OrigData = MSD.Symbol->getData();
+ MCSymbol &OrigData = MSD.Symbol->getData();
assert((!OrigData.getFragment() ||
(OrigData.getFragment()->getParent() == &MSD.Symbol->getSection())) &&
"The symbol's section doesn't match the fragment's symbol");
// Binding and Type share the same byte as upper and lower nibbles
uint8_t Binding = MCELF::GetBinding(*MSD.Symbol);
uint8_t Type = MCELF::GetType(*MSD.Symbol);
- MCSymbolData *BaseSD = nullptr;
+ MCSymbol *BaseSD = nullptr;
if (Base) {
BaseSD = &Base->getData();
Type = mergeTypeForSet(Type, MCELF::GetType(*Base));
bool ELFObjectWriter::isLocal(const MCSymbol &Symbol, bool IsUsedInReloc,
bool IsSignature) {
- const MCSymbolData &Data = Symbol.getData();
+ const MCSymbol &Data = Symbol.getData();
if (Data.isExternal())
return false;
// Simple getSymbolOffset helper for the non-varibale case.
static bool getLabelOffset(const MCAsmLayout &Layout, const MCSymbol &S,
bool ReportError, uint64_t &Val) {
- const MCSymbolData &SD = S.getData();
+ const MCSymbol &SD = S.getData();
if (!SD.getFragment()) {
if (ReportError)
report_fatal_error("unable to evaluate offset to undefined symbol '" +
// important side effect of calling registerSymbol here is to register
// the symbol with the assembler.
getAssembler().registerSymbol(*Symbol);
- MCSymbolData &SD = Symbol->getData();
+ MCSymbol &SD = Symbol->getData();
// The implementation of symbol attributes is designed to match 'as', but it
// leaves much to desired. It doesn't really make sense to arbitrarily add and
void MCELFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
unsigned ByteAlignment) {
getAssembler().registerSymbol(*Symbol);
- MCSymbolData &SD = Symbol->getData();
+ MCSymbol &SD = Symbol->getData();
if (!BindingExplicitlySet.count(Symbol)) {
MCELF::SetBinding(*Symbol, ELF::STB_GLOBAL);
unsigned ByteAlignment) {
// FIXME: Should this be caught and done earlier?
getAssembler().registerSymbol(*Symbol);
- MCSymbolData &SD = Symbol->getData();
+ MCSymbol &SD = Symbol->getData();
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
SD.setExternal(false);
BindingExplicitlySet.insert(Symbol);
if (!Asm->getWriter().IsSymbolRefDifferenceFullyResolved(*Asm, A, B, InSet))
return;
- const MCSymbolData &AD = SA.getData();
- const MCSymbolData &BD = SB.getData();
+ const MCSymbol &AD = SA.getData();
+ const MCSymbol &BD = SB.getData();
if (AD.getFragment() == BD.getFragment()) {
Addend += (SA.getOffset() - SB.getOffset());
void MCMachOStreamer::EmitEHSymAttributes(const MCSymbol *Symbol,
MCSymbol *EHSymbol) {
getAssembler().registerSymbol(*Symbol);
- MCSymbolData &SD = Symbol->getData();
+ MCSymbol &SD = Symbol->getData();
if (SD.isExternal())
EmitSymbolAttribute(EHSymbol, MCSA_Global);
if (Symbol->getFlags() & SF_WeakDefinition)
// important side effect of calling registerSymbol here is to register
// the symbol with the assembler.
getAssembler().registerSymbol(*Symbol);
- MCSymbolData &SD = Symbol->getData();
+ MCSymbol &SD = Symbol->getData();
// The implementation of symbol attributes is designed to match 'as', but it
// leaves much to desired. It doesn't really make sense to arbitrarily add and
AssignSection(Symbol, nullptr);
getAssembler().registerSymbol(*Symbol);
- MCSymbolData &SD = Symbol->getData();
+ MCSymbol &SD = Symbol->getData();
SD.setExternal(true);
Symbol->setCommon(Size, ByteAlignment);
}
assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
getAssembler().registerSymbol(*Symbol);
- MCSymbolData &SD = Symbol->getData();
+ MCSymbol &SD = Symbol->getData();
// Emit an align fragment if necessary.
if (ByteAlignment != 1)
// defining symbols.
DenseMap<const MCFragment *, const MCSymbol *> DefiningSymbolMap;
for (const MCSymbol &Symbol : getAssembler().symbols()) {
- MCSymbolData &SD = Symbol.getData();
+ MCSymbol &SD = Symbol.getData();
if (getAssembler().isSymbolLinkerVisible(Symbol) && SD.getFragment()) {
// An atom defining symbol should never be internal to a fragment.
assert(Symbol.getOffset() == 0 &&
F->setParent(CurSection);
}
for (MCSymbol *Sym : PendingLabels) {
- MCSymbolData *SD = &Sym->getData();
+ MCSymbol *SD = &Sym->getData();
SD->setFragment(F);
Sym->setOffset(FOffset);
}
MCStreamer::EmitLabel(Symbol);
getAssembler().registerSymbol(*Symbol);
- MCSymbolData &SD = Symbol->getData();
+ MCSymbol &SD = Symbol->getData();
assert(!SD.getFragment() && "Unexpected fragment on symbol data!");
// If there is a current fragment, mark the symbol as pointing into it.
if (SA.isUndefined() || SB.isUndefined())
return false;
- const MCSymbolData &DataA = SA.getData();
- const MCSymbolData &DataB = SB.getData();
+ const MCSymbol &DataA = SA.getData();
+ const MCSymbol &DataB = SB.getData();
if(!DataA.getFragment() || !DataB.getFragment())
return false;
void MachObjectWriter::WriteNlist(MachSymbolData &MSD,
const MCAsmLayout &Layout) {
const MCSymbol *Symbol = MSD.Symbol;
- MCSymbolData &Data = Symbol->getData();
+ MCSymbol &Data = Symbol->getData();
const MCSymbol *AliasedSymbol = &findAliasedSymbol(*Symbol);
uint8_t SectionIndex = MSD.SectionIndex;
uint8_t Type = 0;
// match 'as'. Even though it doesn't matter for correctness, this is
// important for letting us diff .o files.
for (const MCSymbol &Symbol : Asm.symbols()) {
- MCSymbolData &SD = Symbol.getData();
+ MCSymbol &SD = Symbol.getData();
// Ignore non-linker visible symbols.
if (!Asm.isSymbolLinkerVisible(Symbol))
// Now add the data for local symbols.
for (const MCSymbol &Symbol : Asm.symbols()) {
- MCSymbolData &SD = Symbol.getData();
+ MCSymbol &SD = Symbol.getData();
// Ignore non-linker visible symbols.
if (!Asm.isSymbolLinkerVisible(Symbol))
static uint64_t getSymbolValue(const MCSymbol &Symbol,
const MCAsmLayout &Layout) {
- const MCSymbolData &Data = Symbol.getData();
+ const MCSymbol &Data = Symbol.getData();
if (Symbol.isCommon() && Data.isExternal())
return Symbol.getCommonSize();
coff_symbol->MC = &Symbol;
} else {
- const MCSymbolData &ResSymData = Symbol.getData();
+ const MCSymbol &ResSymData = Symbol.getData();
const MCSymbol *Base = Layout.getBaseSymbol(Symbol);
coff_symbol->Data.Value = getSymbolValue(Symbol, Layout);
if (!Base) {
coff_symbol->Data.SectionNumber = COFF::IMAGE_SYM_ABSOLUTE;
} else {
- const MCSymbolData &BaseData = Base->getData();
+ const MCSymbol &BaseData = Base->getData();
if (BaseData.getFragment()) {
COFFSection *Sec = SectionMap[BaseData.getFragment()->getParent()];
}
bool WinCOFFObjectWriter::isWeak(const MCSymbol &Sym) const {
- const MCSymbolData &SD = Sym.getData();
+ const MCSymbol &SD = Sym.getData();
if (!SD.isExternal())
return false;
Twine("symbol '") + A.getName() +
"' can not be undefined");
- const MCSymbolData &A_SD = A.getData();
+ const MCSymbol &A_SD = A.getData();
MCSection *Section = Fragment->getParent();
if (SymB) {
const MCSymbol *B = &SymB->getSymbol();
- const MCSymbolData &B_SD = B->getData();
+ const MCSymbol &B_SD = B->getData();
if (!B_SD.getFragment())
Asm.getContext().reportFatalError(
Fixup.getLoc(),
"Got non-COFF section in the COFF backend!");
getAssembler().registerSymbol(*Symbol);
- MCSymbolData &SD = Symbol->getData();
+ MCSymbol &SD = Symbol->getData();
switch (Attribute) {
default: return false;
AssignSection(Symbol, nullptr);
getAssembler().registerSymbol(*Symbol);
- MCSymbolData &SD = Symbol->getData();
+ MCSymbol &SD = Symbol->getData();
SD.setExternal(true);
Symbol->setCommon(Size, ByteAlignment);
Section->setAlignment(ByteAlignment);
getAssembler().registerSymbol(*Symbol);
- MCSymbolData &SD = Symbol->getData();
+ MCSymbol &SD = Symbol->getData();
SD.setExternal(false);
AssignSection(Symbol, Section);
Name + "." + Twine(MappingSymbolCounter++));
getAssembler().registerSymbol(*Symbol);
- MCSymbolData &SD = Symbol->getData();
+ MCSymbol &SD = Symbol->getData();
MCELF::SetType(*Symbol, ELF::STT_NOTYPE);
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
SD.setExternal(false);
}
} else if (Target.getSymB()) { // A - B + constant
const MCSymbol *A = &Target.getSymA()->getSymbol();
- const MCSymbolData &A_SD = A->getData();
+ const MCSymbol &A_SD = A->getData();
const MCSymbol *A_Base = Asm.getAtom(*A);
const MCSymbol *B = &Target.getSymB()->getSymbol();
- const MCSymbolData &B_SD = B->getData();
+ const MCSymbol &B_SD = B->getData();
const MCSymbol *B_Base = Asm.getAtom(*B);
// Check for "_foo@got - .", which comes through here as:
// the offset when the destination has the same MCFragment.
if (A && (unsigned)Fixup.getKind() == ARM::fixup_arm_thumb_bl) {
const MCSymbol &Sym = A->getSymbol();
- const MCSymbolData &SymData = Sym.getData();
+ const MCSymbol &SymData = Sym.getData();
IsResolved = (SymData.getFragment() == DF);
}
// We must always generate a relocation for BL/BLX instructions if we have
Twine(MappingSymbolCounter++));
getAssembler().registerSymbol(*Symbol);
- MCSymbolData &SD = Symbol->getData();
+ MCSymbol &SD = Symbol->getData();
MCELF::SetType(*Symbol, ELF::STT_NOTYPE);
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
SD.setExternal(false);
// See <reloc.h>.
const MCSymbol *A = &Target.getSymA()->getSymbol();
- const MCSymbolData *A_SD = &A->getData();
+ const MCSymbol *A_SD = &A->getData();
if (!A_SD->getFragment())
Asm.getContext().reportFatalError(Fixup.getLoc(),
FixedValue += SecAddr;
if (const MCSymbolRefExpr *B = Target.getSymB()) {
- const MCSymbolData *B_SD = &B->getSymbol().getData();
+ const MCSymbol *B_SD = &B->getSymbol().getData();
if (!B_SD->getFragment())
Asm.getContext().reportFatalError(Fixup.getLoc(),
// See <reloc.h>.
const MCSymbol *A = &Target.getSymA()->getSymbol();
- const MCSymbolData *A_SD = &A->getData();
+ const MCSymbol *A_SD = &A->getData();
if (!A_SD->getFragment())
Asm.getContext().reportFatalError(Fixup.getLoc(),
if (const MCSymbolRefExpr *B = Target.getSymB()) {
assert(Type == MachO::ARM_RELOC_VANILLA && "invalid reloc for 2 symbols");
- const MCSymbolData *B_SD = &B->getSymbol().getData();
+ const MCSymbol *B_SD = &B->getSymbol().getData();
if (!B_SD->getFragment())
Asm.getContext().reportFatalError(Fixup.getLoc(),
// See <reloc.h>.
const MCSymbol *A = &Target.getSymA()->getSymbol();
- const MCSymbolData *A_SD = &A->getData();
+ const MCSymbol *A_SD = &A->getData();
if (!A_SD->getFragment())
report_fatal_error("symbol '" + A->getName() +
uint32_t Value2 = 0;
if (const MCSymbolRefExpr *B = Target.getSymB()) {
- const MCSymbolData *B_SD = &B->getSymbol().getData();
+ const MCSymbol *B_SD = &B->getSymbol().getData();
if (!B_SD->getFragment())
report_fatal_error("symbol '" + B->getSymbol().getName() +
const MCSymbol *A = &Target.getSymA()->getSymbol();
if (A->isTemporary())
A = &Writer->findAliasedSymbol(*A);
- const MCSymbolData &A_SD = A->getData();
+ const MCSymbol &A_SD = A->getData();
const MCSymbol *A_Base = Asm.getAtom(*A);
const MCSymbol *B = &Target.getSymB()->getSymbol();
if (B->isTemporary())
B = &Writer->findAliasedSymbol(*B);
- const MCSymbolData &B_SD = B->getData();
+ const MCSymbol &B_SD = B->getData();
const MCSymbol *B_Base = Asm.getAtom(*B);
// Neither symbol can be modified.
if (!Asm.getContext().getAsmInfo()->isSectionAtomizableBySymbols(Sec))
Asm.addLocalUsedInReloc(*Symbol);
}
- const MCSymbolData &SD = Symbol->getData();
+ const MCSymbol &SD = Symbol->getData();
RelSymbol = Asm.getAtom(*Symbol);
// Relocations inside debug sections always use local relocations when
// See <reloc.h>.
const MCSymbol *A = &Target.getSymA()->getSymbol();
- const MCSymbolData *A_SD = &A->getData();
+ const MCSymbol *A_SD = &A->getData();
if (!A_SD->getFragment())
report_fatal_error("symbol '" + A->getName() +
uint32_t Value2 = 0;
if (const MCSymbolRefExpr *B = Target.getSymB()) {
- const MCSymbolData *B_SD = &B->getSymbol().getData();
+ const MCSymbol *B_SD = &B->getSymbol().getData();
if (!B_SD->getFragment())
report_fatal_error("symbol '" + B->getSymbol().getName() +