bool hasData() const { return HasData; }
- MCSymbol &getData() const { return *const_cast<MCSymbol *>(this); }
-
/// Initialize symbol data.
///
/// Nothing really to do here, but this is enables an assertion that \a
uint64_t ELFObjectWriter::SymbolValue(const MCSymbol &Sym,
const MCAsmLayout &Layout) {
- MCSymbol &Data = Sym.getData();
- if (Sym.isCommon() && Data.isExternal())
+ if (Sym.isCommon() && Sym.isExternal())
return Sym.getCommonAlignment();
uint64_t Res;
// versions declared with @@@ to be renamed.
for (const MCSymbol &Alias : Asm.symbols()) {
- MCSymbol &OriginalData = Alias.getData();
-
// Not an alias.
if (!Alias.isVariable())
continue;
if (!Ref)
continue;
const MCSymbol &Symbol = Ref->getSymbol();
- MCSymbol &SD = Symbol.getData();
StringRef AliasName = Alias.getName();
size_t Pos = AliasName.find('@');
// Aliases defined with .symvar copy the binding from the symbol they alias.
// This is the first place we are able to copy this information.
- OriginalData.setExternal(SD.isExternal());
+ Alias.setExternal(Symbol.isExternal());
MCELF::SetBinding(Alias, MCELF::GetBinding(Symbol));
StringRef Rest = AliasName.substr(Pos);
void ELFObjectWriter::writeSymbol(SymbolTableWriter &Writer,
uint32_t StringIndex, ELFSymbolData &MSD,
const MCAsmLayout &Layout) {
-#ifndef NDEBUG
- MCSymbol &OrigData = MSD.Symbol->getData();
- assert((!OrigData.getFragment() ||
- (OrigData.getFragment()->getParent() == &MSD.Symbol->getSection())) &&
+ const MCSymbol &Symbol = *MSD.Symbol;
+ assert((!Symbol.getFragment() ||
+ (Symbol.getFragment()->getParent() == &Symbol.getSection())) &&
"The symbol's section doesn't match the fragment's symbol");
-#endif
- const MCSymbol *Base = Layout.getBaseSymbol(*MSD.Symbol);
+ const MCSymbol *Base = Layout.getBaseSymbol(Symbol);
// This has to be in sync with when computeSymbolTable uses SHN_ABS or
// SHN_COMMON.
- bool IsReserved = !Base || MSD.Symbol->isCommon();
+ bool IsReserved = !Base || Symbol.isCommon();
// 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);
- MCSymbol *BaseSD = nullptr;
+ uint8_t Binding = MCELF::GetBinding(Symbol);
+ uint8_t Type = MCELF::GetType(Symbol);
if (Base) {
- BaseSD = &Base->getData();
Type = mergeTypeForSet(Type, MCELF::GetType(*Base));
}
uint8_t Info = (Binding << ELF_STB_Shift) | (Type << ELF_STT_Shift);
// Other and Visibility share the same byte with Visibility using the lower
// 2 bits
- uint8_t Visibility = MCELF::GetVisibility(*MSD.Symbol);
- uint8_t Other = MCELF::getOther(*MSD.Symbol)
- << (ELF_STO_Shift - ELF_STV_Shift);
+ uint8_t Visibility = MCELF::GetVisibility(Symbol);
+ uint8_t Other = MCELF::getOther(Symbol) << (ELF_STO_Shift - ELF_STV_Shift);
Other |= Visibility;
uint64_t Value = SymbolValue(*MSD.Symbol, Layout);
bool ELFObjectWriter::isLocal(const MCSymbol &Symbol, bool IsUsedInReloc,
bool IsSignature) {
- const MCSymbol &Data = Symbol.getData();
- if (Data.isExternal())
+ if (Symbol.isExternal())
return false;
if (Symbol.isDefined())
// Simple getSymbolOffset helper for the non-varibale case.
static bool getLabelOffset(const MCAsmLayout &Layout, const MCSymbol &S,
bool ReportError, uint64_t &Val) {
- const MCSymbol &SD = S.getData();
- if (!SD.getFragment()) {
+ if (!S.getFragment()) {
if (ReportError)
report_fatal_error("unable to evaluate offset to undefined symbol '" +
S.getName() + "'");
return false;
}
- Val = Layout.getFragmentOffset(SD.getFragment()) + S.getOffset();
+ Val = Layout.getFragmentOffset(S.getFragment()) + S.getOffset();
return true;
}
return &S;
// Absolute and undefined symbols have no defining atom.
- if (!S.getData().getFragment())
+ if (!S.getFragment())
return nullptr;
// Non-linker visible symbols in sections which can't be atomized have no
// defining atom.
if (!getContext().getAsmInfo()->isSectionAtomizableBySymbols(
- *S.getData().getFragment()->getParent()))
+ *S.getFragment()->getParent()))
return nullptr;
// Otherwise, return the atom for the containing fragment.
- return S.getData().getFragment()->getAtom();
+ return S.getFragment()->getAtom();
}
bool MCAssembler::evaluateFixup(const MCAsmLayout &Layout,
OS << "(";
it->dump();
OS << ", Index:" << it->getIndex() << ", ";
- it->getData().dump();
OS << ")";
}
OS << "]>\n";
// important side effect of calling registerSymbol here is to register
// the symbol with the assembler.
getAssembler().registerSymbol(*Symbol);
- 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
MCELF::SetType(
*Symbol, CombineSymbolTypes(MCELF::GetType(*Symbol), ELF::STT_OBJECT));
MCELF::SetBinding(*Symbol, ELF::STB_GNU_UNIQUE);
- SD.setExternal(true);
+ Symbol->setExternal(true);
BindingExplicitlySet.insert(Symbol);
break;
case MCSA_Global:
MCELF::SetBinding(*Symbol, ELF::STB_GLOBAL);
- SD.setExternal(true);
+ Symbol->setExternal(true);
BindingExplicitlySet.insert(Symbol);
break;
case MCSA_WeakReference:
case MCSA_Weak:
MCELF::SetBinding(*Symbol, ELF::STB_WEAK);
- SD.setExternal(true);
+ Symbol->setExternal(true);
BindingExplicitlySet.insert(Symbol);
break;
case MCSA_Local:
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
- SD.setExternal(false);
+ Symbol->setExternal(false);
BindingExplicitlySet.insert(Symbol);
break;
void MCELFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
unsigned ByteAlignment) {
getAssembler().registerSymbol(*Symbol);
- MCSymbol &SD = Symbol->getData();
if (!BindingExplicitlySet.count(Symbol)) {
MCELF::SetBinding(*Symbol, ELF::STB_GLOBAL);
- SD.setExternal(true);
+ Symbol->setExternal(true);
}
MCELF::SetType(*Symbol, ELF::STT_OBJECT);
unsigned ByteAlignment) {
// FIXME: Should this be caught and done earlier?
getAssembler().registerSymbol(*Symbol);
- MCSymbol &SD = Symbol->getData();
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
- SD.setExternal(false);
+ Symbol->setExternal(false);
BindingExplicitlySet.insert(Symbol);
EmitCommonSymbol(Symbol, Size, ByteAlignment);
}
new MCAlignFragment(ByteAlignment, 0, 1, ByteAlignment, &Section);
MCFragment *F = new MCFillFragment(0, 0, Size, &Section);
- Symbol.getData().setFragment(F);
+ Symbol.setFragment(F);
// Update the maximum alignment of the section if necessary.
if (ByteAlignment > Section.getAlignment())
if (!Asm->getWriter().IsSymbolRefDifferenceFullyResolved(*Asm, A, B, InSet))
return;
- const MCSymbol &AD = SA.getData();
- const MCSymbol &BD = SB.getData();
-
- if (AD.getFragment() == BD.getFragment()) {
+ if (SA.getFragment() == SB.getFragment()) {
Addend += (SA.getOffset() - SB.getOffset());
// Pointers to Thumb symbols need to have their low-bit set to allow
if (!Layout)
return;
- const MCSection &SecA = *AD.getFragment()->getParent();
- const MCSection &SecB = *BD.getFragment()->getParent();
+ const MCSection &SecA = *SA.getFragment()->getParent();
+ const MCSection &SecB = *SB.getFragment()->getParent();
if ((&SecA != &SecB) && !Addrs)
return;
void MCMachOStreamer::EmitEHSymAttributes(const MCSymbol *Symbol,
MCSymbol *EHSymbol) {
getAssembler().registerSymbol(*Symbol);
- MCSymbol &SD = Symbol->getData();
- if (SD.isExternal())
+ if (Symbol->isExternal())
EmitSymbolAttribute(EHSymbol, MCSA_Global);
if (Symbol->getFlags() & SF_WeakDefinition)
EmitSymbolAttribute(EHSymbol, MCSA_WeakDefinition);
- if (SD.isPrivateExtern())
+ if (Symbol->isPrivateExtern())
EmitSymbolAttribute(EHSymbol, MCSA_PrivateExtern);
}
// important side effect of calling registerSymbol here is to register
// the symbol with the assembler.
getAssembler().registerSymbol(*Symbol);
- 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
return false;
case MCSA_Global:
- SD.setExternal(true);
+ Symbol->setExternal(true);
// This effectively clears the undefined lazy bit, in Darwin 'as', although
// it isn't very consistent because it implements this as part of symbol
// lookup.
break;
case MCSA_PrivateExtern:
- SD.setExternal(true);
- SD.setPrivateExtern(true);
+ Symbol->setExternal(true);
+ Symbol->setPrivateExtern(true);
break;
case MCSA_WeakReference:
AssignSection(Symbol, nullptr);
getAssembler().registerSymbol(*Symbol);
- MCSymbol &SD = Symbol->getData();
- SD.setExternal(true);
+ Symbol->setExternal(true);
Symbol->setCommon(Size, ByteAlignment);
}
assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
getAssembler().registerSymbol(*Symbol);
- MCSymbol &SD = Symbol->getData();
// Emit an align fragment if necessary.
if (ByteAlignment != 1)
new MCAlignFragment(ByteAlignment, 0, 0, ByteAlignment, Section);
MCFragment *F = new MCFillFragment(0, 0, Size, Section);
- SD.setFragment(F);
+ Symbol->setFragment(F);
AssignSection(Symbol, Section);
// defining symbols.
DenseMap<const MCFragment *, const MCSymbol *> DefiningSymbolMap;
for (const MCSymbol &Symbol : getAssembler().symbols()) {
- MCSymbol &SD = Symbol.getData();
- if (getAssembler().isSymbolLinkerVisible(Symbol) && SD.getFragment()) {
+ if (getAssembler().isSymbolLinkerVisible(Symbol) && Symbol.getFragment()) {
// An atom defining symbol should never be internal to a fragment.
assert(Symbol.getOffset() == 0 &&
"Invalid offset in atom defining symbol!");
- DefiningSymbolMap[SD.getFragment()] = &Symbol;
+ DefiningSymbolMap[Symbol.getFragment()] = &Symbol;
}
}
F->setParent(CurSection);
}
for (MCSymbol *Sym : PendingLabels) {
- MCSymbol *SD = &Sym->getData();
- SD->setFragment(F);
+ Sym->setFragment(F);
Sym->setOffset(FOffset);
}
PendingLabels.clear();
// Must have symbol data.
if (!Assembler->hasSymbolData(*Hi) || !Assembler->hasSymbolData(*Lo))
return false;
- auto &HiD = Hi->getData();
- auto &LoD = Lo->getData();
// Must both be assigned to the same (valid) fragment.
- if (!HiD.getFragment() || HiD.getFragment() != LoD.getFragment())
+ if (!Hi->getFragment() || Hi->getFragment() != Lo->getFragment())
return false;
// Must be a data fragment.
- if (!isa<MCDataFragment>(HiD.getFragment()))
+ if (!isa<MCDataFragment>(Hi->getFragment()))
return false;
assert(Hi->getOffset() >= Lo->getOffset() &&
MCStreamer::EmitLabel(Symbol);
getAssembler().registerSymbol(*Symbol);
- MCSymbol &SD = Symbol->getData();
- assert(!SD.getFragment() && "Unexpected fragment on symbol data!");
+ assert(!Symbol->getFragment() && "Unexpected fragment on symbol data!");
// If there is a current fragment, mark the symbol as pointing into it.
// Otherwise queue the label and set its fragment pointer when we emit the
auto *F = dyn_cast_or_null<MCDataFragment>(getCurrentFragment());
if (F && !(getAssembler().isBundlingEnabled() &&
getAssembler().getRelaxAll())) {
- SD.setFragment(F);
+ Symbol->setFragment(F);
Symbol->setOffset(F->getContents().size());
} else {
PendingLabels.push_back(Symbol);
if (SA.isUndefined() || SB.isUndefined())
return false;
- const MCSymbol &DataA = SA.getData();
- const MCSymbol &DataB = SB.getData();
- if(!DataA.getFragment() || !DataB.getFragment())
+ if (!SA.getFragment() || !SB.getFragment())
return false;
- return IsSymbolRefDifferenceFullyResolvedImpl(Asm, SA, *DataB.getFragment(),
+ return IsSymbolRefDifferenceFullyResolvedImpl(Asm, SA, *SB.getFragment(),
InSet, false);
}
return Address;
}
- return getSectionAddress(S.getData().getFragment()->getParent()) +
+ return getSectionAddress(S.getFragment()->getParent()) +
Layout.getSymbolOffset(S);
}
void MachObjectWriter::WriteNlist(MachSymbolData &MSD,
const MCAsmLayout &Layout) {
const MCSymbol *Symbol = MSD.Symbol;
- MCSymbol &Data = Symbol->getData();
+ const MCSymbol &Data = *Symbol;
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()) {
- MCSymbol &SD = Symbol.getData();
-
// Ignore non-linker visible symbols.
if (!Asm.isSymbolLinkerVisible(Symbol))
continue;
- if (!SD.isExternal() && !Symbol.isUndefined())
+ if (!Symbol.isExternal() && !Symbol.isUndefined())
continue;
MachSymbolData MSD;
// Now add the data for local symbols.
for (const MCSymbol &Symbol : Asm.symbols()) {
- MCSymbol &SD = Symbol.getData();
-
// Ignore non-linker visible symbols.
if (!Asm.isSymbolLinkerVisible(Symbol))
continue;
- if (SD.isExternal() || Symbol.isUndefined())
+ if (Symbol.isExternal() || Symbol.isUndefined())
continue;
MachSymbolData MSD;
bool hasReliableSymbolDifference = isX86_64();
if (!hasReliableSymbolDifference) {
if (!SA.isInSection() || &SecA != &SecB ||
- (!SA.isTemporary() &&
- FB.getAtom() != SA.getData().getFragment()->getAtom() &&
+ (!SA.isTemporary() && FB.getAtom() != SA.getFragment()->getAtom() &&
Asm.getSubsectionsViaSymbols()))
return false;
return true;
if (&SecA != &SecB)
return false;
- const MCFragment *FA = SA.getData().getFragment();
+ const MCFragment *FA = SA.getFragment();
// Bail if the symbol has no fragment.
if (!FA)
static_cast<const MCSectionMachO &>(*it->Section);
if (Section.getType() == MachO::S_NON_LAZY_SYMBOL_POINTERS) {
// If this symbol is defined and internal, mark it as such.
- if (it->Symbol->isDefined() && !it->Symbol->getData().isExternal()) {
+ if (it->Symbol->isDefined() && !it->Symbol->isExternal()) {
uint32_t Flags = MachO::INDIRECT_SYMBOL_LOCAL;
if (it->Symbol->isAbsolute())
Flags |= MachO::INDIRECT_SYMBOL_ABS;
static uint64_t getSymbolValue(const MCSymbol &Symbol,
const MCAsmLayout &Layout) {
- const MCSymbol &Data = Symbol.getData();
- if (Symbol.isCommon() && Data.isExternal())
+ if (Symbol.isCommon() && Symbol.isExternal())
return Symbol.getCommonSize();
uint64_t Res;
coff_symbol->MC = &Symbol;
} else {
- const MCSymbol &ResSymData = Symbol.getData();
const MCSymbol *Base = Layout.getBaseSymbol(Symbol);
coff_symbol->Data.Value = getSymbolValue(Symbol, Layout);
// If no storage class was specified in the streamer, define it here.
if (coff_symbol->Data.StorageClass == 0) {
- bool IsExternal = ResSymData.isExternal() ||
- (!ResSymData.getFragment() && !Symbol.isVariable());
+ bool IsExternal = Symbol.isExternal() ||
+ (!Symbol.getFragment() && !Symbol.isVariable());
coff_symbol->Data.StorageClass = IsExternal
? COFF::IMAGE_SYM_CLASS_EXTERNAL
if (!Base) {
coff_symbol->Data.SectionNumber = COFF::IMAGE_SYM_ABSOLUTE;
} else {
- const MCSymbol &BaseData = Base->getData();
- if (BaseData.getFragment()) {
- COFFSection *Sec = SectionMap[BaseData.getFragment()->getParent()];
+ if (Base->getFragment()) {
+ COFFSection *Sec = SectionMap[Base->getFragment()->getParent()];
if (coff_symbol->Section && coff_symbol->Section != Sec)
report_fatal_error("conflicting sections for symbol");
}
bool WinCOFFObjectWriter::isWeak(const MCSymbol &Sym) const {
- const MCSymbol &SD = Sym.getData();
- if (!SD.isExternal())
+ if (!Sym.isExternal())
return false;
if (!Sym.isInSection())
Twine("symbol '") + A.getName() +
"' can not be undefined");
- const MCSymbol &A_SD = A.getData();
-
MCSection *Section = Fragment->getParent();
// Mark this symbol as requiring an entry in the symbol table.
if (SymB) {
const MCSymbol *B = &SymB->getSymbol();
- const MCSymbol &B_SD = B->getData();
- if (!B_SD.getFragment())
+ if (!B->getFragment())
Asm.getContext().reportFatalError(
Fixup.getLoc(),
Twine("symbol '") + B->getName() +
"' can not be undefined in a subtraction expression");
- if (!A_SD.getFragment())
+ if (!A.getFragment())
Asm.getContext().reportFatalError(
Fixup.getLoc(),
Twine("symbol '") + Symbol.getName() +
// Turn relocations for temporary symbols into section relocations.
if (coff_symbol->MC->isTemporary() || CrossSection) {
Reloc.Symb = coff_symbol->Section->Symbol;
- FixedValue +=
- Layout.getFragmentOffset(coff_symbol->MC->getData().getFragment()) +
- coff_symbol->MC->getOffset();
+ FixedValue += Layout.getFragmentOffset(coff_symbol->MC->getFragment()) +
+ coff_symbol->MC->getOffset();
} else
Reloc.Symb = coff_symbol;
"Got non-COFF section in the COFF backend!");
getAssembler().registerSymbol(*Symbol);
- MCSymbol &SD = Symbol->getData();
switch (Attribute) {
default: return false;
case MCSA_WeakReference:
case MCSA_Weak:
Symbol->modifyFlags(COFF::SF_WeakExternal, COFF::SF_WeakExternal);
- SD.setExternal(true);
+ Symbol->setExternal(true);
break;
case MCSA_Global:
- SD.setExternal(true);
+ Symbol->setExternal(true);
break;
}
AssignSection(Symbol, nullptr);
getAssembler().registerSymbol(*Symbol);
- MCSymbol &SD = Symbol->getData();
- SD.setExternal(true);
+ Symbol->setExternal(true);
Symbol->setCommon(Size, ByteAlignment);
if (!T.isKnownWindowsMSVCEnvironment() && ByteAlignment > 1) {
Section->setAlignment(ByteAlignment);
getAssembler().registerSymbol(*Symbol);
- MCSymbol &SD = Symbol->getData();
- SD.setExternal(false);
+ Symbol->setExternal(false);
AssignSection(Symbol, Section);
MCFillFragment *Fragment = new MCFillFragment(
/*Value=*/0, /*ValueSize=*/0, Size, Section);
- SD.setFragment(Fragment);
+ Symbol->setFragment(Fragment);
}
void MCWinCOFFStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol,
Name + "." + Twine(MappingSymbolCounter++));
getAssembler().registerSymbol(*Symbol);
- MCSymbol &SD = Symbol->getData();
MCELF::SetType(*Symbol, ELF::STT_NOTYPE);
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
- SD.setExternal(false);
+ Symbol->setExternal(false);
auto Sec = getCurrentSection().first;
assert(Sec && "need a section");
Symbol->setSection(*Sec);
}
} else if (Target.getSymB()) { // A - B + constant
const MCSymbol *A = &Target.getSymA()->getSymbol();
- const MCSymbol &A_SD = A->getData();
const MCSymbol *A_Base = Asm.getAtom(*A);
const MCSymbol *B = &Target.getSymB()->getSymbol();
- const MCSymbol &B_SD = B->getData();
const MCSymbol *B_Base = Asm.getAtom(*B);
// Check for "_foo@got - .", which comes through here as:
Asm.getContext().reportFatalError(Fixup.getLoc(),
"unsupported relocation with identical base");
- Value += (!A_SD.getFragment() ? 0 : Writer->getSymbolAddress(*A, Layout)) -
- (!A_Base || !A_Base->getData().getFragment()
- ? 0
- : Writer->getSymbolAddress(*A_Base, Layout));
- Value -= (!B_SD.getFragment() ? 0 : Writer->getSymbolAddress(*B, Layout)) -
- (!B_Base || !B_Base->getData().getFragment()
- ? 0
- : Writer->getSymbolAddress(*B_Base, Layout));
+ Value += (!A->getFragment() ? 0 : Writer->getSymbolAddress(*A, Layout)) -
+ (!A_Base || !A_Base->getFragment() ? 0 : Writer->getSymbolAddress(
+ *A_Base, Layout));
+ Value -= (!B->getFragment() ? 0 : Writer->getSymbolAddress(*B, Layout)) -
+ (!B_Base || !B_Base->getFragment() ? 0 : Writer->getSymbolAddress(
+ *B_Base, Layout));
Type = MachO::ARM64_RELOC_UNSIGNED;
// 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 MCSymbol &SymData = Sym.getData();
- IsResolved = (SymData.getFragment() == DF);
+ IsResolved = (Sym.getFragment() == DF);
}
// We must always generate a relocation for BL/BLX instructions if we have
// a symbol to reference, as the linker relies on knowing the destination
Twine(MappingSymbolCounter++));
getAssembler().registerSymbol(*Symbol);
- MCSymbol &SD = Symbol->getData();
MCELF::SetType(*Symbol, ELF::STT_NOTYPE);
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
- SD.setExternal(false);
+ Symbol->setExternal(false);
AssignSection(Symbol, getCurrentSection().first);
const MCExpr *Value = MCSymbolRefExpr::Create(Start, getContext());
// See <reloc.h>.
const MCSymbol *A = &Target.getSymA()->getSymbol();
- const MCSymbol *A_SD = &A->getData();
- if (!A_SD->getFragment())
+ if (!A->getFragment())
Asm.getContext().reportFatalError(Fixup.getLoc(),
"symbol '" + A->getName() +
"' can not be undefined in a subtraction expression");
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
uint32_t Value2 = 0;
- uint64_t SecAddr =
- Writer->getSectionAddress(A_SD->getFragment()->getParent());
+ uint64_t SecAddr = Writer->getSectionAddress(A->getFragment()->getParent());
FixedValue += SecAddr;
if (const MCSymbolRefExpr *B = Target.getSymB()) {
- const MCSymbol *B_SD = &B->getSymbol().getData();
+ const MCSymbol *SB = &B->getSymbol();
- if (!B_SD->getFragment())
+ if (!SB->getFragment())
Asm.getContext().reportFatalError(Fixup.getLoc(),
"symbol '" + B->getSymbol().getName() +
"' can not be undefined in a subtraction expression");
// Select the appropriate difference relocation type.
Type = MachO::ARM_RELOC_HALF_SECTDIFF;
Value2 = Writer->getSymbolAddress(B->getSymbol(), Layout);
- FixedValue -= Writer->getSectionAddress(B_SD->getFragment()->getParent());
+ FixedValue -= Writer->getSectionAddress(SB->getFragment()->getParent());
}
// Relocations are written out in reverse order, so the PAIR comes first.
// See <reloc.h>.
const MCSymbol *A = &Target.getSymA()->getSymbol();
- const MCSymbol *A_SD = &A->getData();
- if (!A_SD->getFragment())
+ if (!A->getFragment())
Asm.getContext().reportFatalError(Fixup.getLoc(),
"symbol '" + A->getName() +
"' can not be undefined in a subtraction expression");
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
- uint64_t SecAddr =
- Writer->getSectionAddress(A_SD->getFragment()->getParent());
+ uint64_t SecAddr = Writer->getSectionAddress(A->getFragment()->getParent());
FixedValue += SecAddr;
uint32_t Value2 = 0;
if (const MCSymbolRefExpr *B = Target.getSymB()) {
assert(Type == MachO::ARM_RELOC_VANILLA && "invalid reloc for 2 symbols");
- const MCSymbol *B_SD = &B->getSymbol().getData();
+ const MCSymbol *SB = &B->getSymbol();
- if (!B_SD->getFragment())
+ if (!SB->getFragment())
Asm.getContext().reportFatalError(Fixup.getLoc(),
"symbol '" + B->getSymbol().getName() +
"' can not be undefined in a subtraction expression");
// Select the appropriate difference relocation type.
Type = MachO::ARM_RELOC_SECTDIFF;
Value2 = Writer->getSymbolAddress(B->getSymbol(), Layout);
- FixedValue -= Writer->getSectionAddress(B_SD->getFragment()->getParent());
+ FixedValue -= Writer->getSectionAddress(SB->getFragment()->getParent());
}
// Relocations are written out in reverse order, so the PAIR comes first.
// See <reloc.h>.
const MCSymbol *A = &Target.getSymA()->getSymbol();
- const MCSymbol *A_SD = &A->getData();
- if (!A_SD->getFragment())
+ if (!A->getFragment())
report_fatal_error("symbol '" + A->getName() +
"' can not be undefined in a subtraction expression");
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
- uint64_t SecAddr =
- Writer->getSectionAddress(A_SD->getFragment()->getParent());
+ uint64_t SecAddr = Writer->getSectionAddress(A->getFragment()->getParent());
FixedValue += SecAddr;
uint32_t Value2 = 0;
if (const MCSymbolRefExpr *B = Target.getSymB()) {
- const MCSymbol *B_SD = &B->getSymbol().getData();
+ const MCSymbol *SB = &B->getSymbol();
- if (!B_SD->getFragment())
+ if (!SB->getFragment())
report_fatal_error("symbol '" + B->getSymbol().getName() +
"' can not be undefined in a subtraction expression");
// FIXME: is Type correct? see include/llvm/Support/MachO.h
Value2 = Writer->getSymbolAddress(B->getSymbol(), Layout);
- FixedValue -= Writer->getSectionAddress(B_SD->getFragment()->getParent());
+ FixedValue -= Writer->getSectionAddress(SB->getFragment()->getParent());
}
// FIXME: does FixedValue get used??
const MCSymbol *A = &Target.getSymA()->getSymbol();
if (A->isTemporary())
A = &Writer->findAliasedSymbol(*A);
- 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 MCSymbol &B_SD = B->getData();
const MCSymbol *B_Base = Asm.getAtom(*B);
// Neither symbol can be modified.
(!B_Base ? 0 : Writer->getSymbolAddress(*B_Base, Layout));
if (!A_Base)
- Index = A_SD.getFragment()->getParent()->getOrdinal() + 1;
+ Index = A->getFragment()->getParent()->getOrdinal() + 1;
Type = MachO::X86_64_RELOC_UNSIGNED;
MachO::any_relocation_info MRE;
if (B_Base)
RelSymbol = B_Base;
else
- Index = B_SD.getFragment()->getParent()->getOrdinal() + 1;
+ Index = B->getFragment()->getParent()->getOrdinal() + 1;
Type = MachO::X86_64_RELOC_SUBTRACTOR;
} else {
const MCSymbol *Symbol = &Target.getSymA()->getSymbol();
if (!Asm.getContext().getAsmInfo()->isSectionAtomizableBySymbols(Sec))
Asm.addLocalUsedInReloc(*Symbol);
}
- const MCSymbol &SD = Symbol->getData();
RelSymbol = Asm.getAtom(*Symbol);
// Relocations inside debug sections always use local relocations when
Layout.getSymbolOffset(*RelSymbol);
} else if (Symbol->isInSection() && !Symbol->isVariable()) {
// The index is the section ordinal (1-based).
- Index = SD.getFragment()->getParent()->getOrdinal() + 1;
+ Index = Symbol->getFragment()->getParent()->getOrdinal() + 1;
Value += Writer->getSymbolAddress(*Symbol, Layout);
if (IsPCRel)
// See <reloc.h>.
const MCSymbol *A = &Target.getSymA()->getSymbol();
- const MCSymbol *A_SD = &A->getData();
- if (!A_SD->getFragment())
+ if (!A->getFragment())
report_fatal_error("symbol '" + A->getName() +
"' can not be undefined in a subtraction expression",
false);
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
- uint64_t SecAddr =
- Writer->getSectionAddress(A_SD->getFragment()->getParent());
+ uint64_t SecAddr = Writer->getSectionAddress(A->getFragment()->getParent());
FixedValue += SecAddr;
uint32_t Value2 = 0;
if (const MCSymbolRefExpr *B = Target.getSymB()) {
- const MCSymbol *B_SD = &B->getSymbol().getData();
+ const MCSymbol *SB = &B->getSymbol();
- if (!B_SD->getFragment())
+ if (!SB->getFragment())
report_fatal_error("symbol '" + B->getSymbol().getName() +
"' can not be undefined in a subtraction expression",
false);
// Note that there is no longer any semantic difference between these two
// relocation types from the linkers point of view, this is done solely for
// pedantic compatibility with 'as'.
- Type = A_SD->isExternal() ? (unsigned)MachO::GENERIC_RELOC_SECTDIFF :
- (unsigned)MachO::GENERIC_RELOC_LOCAL_SECTDIFF;
+ Type = A->isExternal() ? (unsigned)MachO::GENERIC_RELOC_SECTDIFF
+ : (unsigned)MachO::GENERIC_RELOC_LOCAL_SECTDIFF;
Value2 = Writer->getSymbolAddress(B->getSymbol(), Layout);
- FixedValue -= Writer->getSectionAddress(B_SD->getFragment()->getParent());
+ FixedValue -= Writer->getSectionAddress(SB->getFragment()->getParent());
}
// Relocations are written out in reverse order, so the PAIR comes first.