mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-14 09:38:40 +00:00
Remove getData.
This completes the mechanical part of merging MCSymbol and MCSymbolData. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238617 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
38a2e49d1c
commit
cfac75ad0e
@ -117,8 +117,6 @@ public:
|
|||||||
|
|
||||||
bool hasData() const { return HasData; }
|
bool hasData() const { return HasData; }
|
||||||
|
|
||||||
MCSymbol &getData() const { return *const_cast<MCSymbol *>(this); }
|
|
||||||
|
|
||||||
/// Initialize symbol data.
|
/// Initialize symbol data.
|
||||||
///
|
///
|
||||||
/// Nothing really to do here, but this is enables an assertion that \a
|
/// Nothing really to do here, but this is enables an assertion that \a
|
||||||
|
@ -359,8 +359,7 @@ void ELFObjectWriter::writeHeader(const MCAssembler &Asm) {
|
|||||||
|
|
||||||
uint64_t ELFObjectWriter::SymbolValue(const MCSymbol &Sym,
|
uint64_t ELFObjectWriter::SymbolValue(const MCSymbol &Sym,
|
||||||
const MCAsmLayout &Layout) {
|
const MCAsmLayout &Layout) {
|
||||||
MCSymbol &Data = Sym.getData();
|
if (Sym.isCommon() && Sym.isExternal())
|
||||||
if (Sym.isCommon() && Data.isExternal())
|
|
||||||
return Sym.getCommonAlignment();
|
return Sym.getCommonAlignment();
|
||||||
|
|
||||||
uint64_t Res;
|
uint64_t Res;
|
||||||
@ -379,8 +378,6 @@ void ELFObjectWriter::ExecutePostLayoutBinding(MCAssembler &Asm,
|
|||||||
// versions declared with @@@ to be renamed.
|
// versions declared with @@@ to be renamed.
|
||||||
|
|
||||||
for (const MCSymbol &Alias : Asm.symbols()) {
|
for (const MCSymbol &Alias : Asm.symbols()) {
|
||||||
MCSymbol &OriginalData = Alias.getData();
|
|
||||||
|
|
||||||
// Not an alias.
|
// Not an alias.
|
||||||
if (!Alias.isVariable())
|
if (!Alias.isVariable())
|
||||||
continue;
|
continue;
|
||||||
@ -388,7 +385,6 @@ void ELFObjectWriter::ExecutePostLayoutBinding(MCAssembler &Asm,
|
|||||||
if (!Ref)
|
if (!Ref)
|
||||||
continue;
|
continue;
|
||||||
const MCSymbol &Symbol = Ref->getSymbol();
|
const MCSymbol &Symbol = Ref->getSymbol();
|
||||||
MCSymbol &SD = Symbol.getData();
|
|
||||||
|
|
||||||
StringRef AliasName = Alias.getName();
|
StringRef AliasName = Alias.getName();
|
||||||
size_t Pos = AliasName.find('@');
|
size_t Pos = AliasName.find('@');
|
||||||
@ -397,7 +393,7 @@ void ELFObjectWriter::ExecutePostLayoutBinding(MCAssembler &Asm,
|
|||||||
|
|
||||||
// Aliases defined with .symvar copy the binding from the symbol they alias.
|
// Aliases defined with .symvar copy the binding from the symbol they alias.
|
||||||
// This is the first place we are able to copy this information.
|
// 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));
|
MCELF::SetBinding(Alias, MCELF::GetBinding(Symbol));
|
||||||
|
|
||||||
StringRef Rest = AliasName.substr(Pos);
|
StringRef Rest = AliasName.substr(Pos);
|
||||||
@ -451,33 +447,28 @@ static uint8_t mergeTypeForSet(uint8_t origType, uint8_t newType) {
|
|||||||
void ELFObjectWriter::writeSymbol(SymbolTableWriter &Writer,
|
void ELFObjectWriter::writeSymbol(SymbolTableWriter &Writer,
|
||||||
uint32_t StringIndex, ELFSymbolData &MSD,
|
uint32_t StringIndex, ELFSymbolData &MSD,
|
||||||
const MCAsmLayout &Layout) {
|
const MCAsmLayout &Layout) {
|
||||||
#ifndef NDEBUG
|
const MCSymbol &Symbol = *MSD.Symbol;
|
||||||
MCSymbol &OrigData = MSD.Symbol->getData();
|
assert((!Symbol.getFragment() ||
|
||||||
assert((!OrigData.getFragment() ||
|
(Symbol.getFragment()->getParent() == &Symbol.getSection())) &&
|
||||||
(OrigData.getFragment()->getParent() == &MSD.Symbol->getSection())) &&
|
|
||||||
"The symbol's section doesn't match the fragment's symbol");
|
"The symbol's section doesn't match the fragment's symbol");
|
||||||
#endif
|
const MCSymbol *Base = Layout.getBaseSymbol(Symbol);
|
||||||
const MCSymbol *Base = Layout.getBaseSymbol(*MSD.Symbol);
|
|
||||||
|
|
||||||
// This has to be in sync with when computeSymbolTable uses SHN_ABS or
|
// This has to be in sync with when computeSymbolTable uses SHN_ABS or
|
||||||
// SHN_COMMON.
|
// 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
|
// Binding and Type share the same byte as upper and lower nibbles
|
||||||
uint8_t Binding = MCELF::GetBinding(*MSD.Symbol);
|
uint8_t Binding = MCELF::GetBinding(Symbol);
|
||||||
uint8_t Type = MCELF::GetType(*MSD.Symbol);
|
uint8_t Type = MCELF::GetType(Symbol);
|
||||||
MCSymbol *BaseSD = nullptr;
|
|
||||||
if (Base) {
|
if (Base) {
|
||||||
BaseSD = &Base->getData();
|
|
||||||
Type = mergeTypeForSet(Type, MCELF::GetType(*Base));
|
Type = mergeTypeForSet(Type, MCELF::GetType(*Base));
|
||||||
}
|
}
|
||||||
uint8_t Info = (Binding << ELF_STB_Shift) | (Type << ELF_STT_Shift);
|
uint8_t Info = (Binding << ELF_STB_Shift) | (Type << ELF_STT_Shift);
|
||||||
|
|
||||||
// Other and Visibility share the same byte with Visibility using the lower
|
// Other and Visibility share the same byte with Visibility using the lower
|
||||||
// 2 bits
|
// 2 bits
|
||||||
uint8_t Visibility = MCELF::GetVisibility(*MSD.Symbol);
|
uint8_t Visibility = MCELF::GetVisibility(Symbol);
|
||||||
uint8_t Other = MCELF::getOther(*MSD.Symbol)
|
uint8_t Other = MCELF::getOther(Symbol) << (ELF_STO_Shift - ELF_STV_Shift);
|
||||||
<< (ELF_STO_Shift - ELF_STV_Shift);
|
|
||||||
Other |= Visibility;
|
Other |= Visibility;
|
||||||
|
|
||||||
uint64_t Value = SymbolValue(*MSD.Symbol, Layout);
|
uint64_t Value = SymbolValue(*MSD.Symbol, Layout);
|
||||||
@ -769,8 +760,7 @@ bool ELFObjectWriter::isInSymtab(const MCAsmLayout &Layout,
|
|||||||
|
|
||||||
bool ELFObjectWriter::isLocal(const MCSymbol &Symbol, bool IsUsedInReloc,
|
bool ELFObjectWriter::isLocal(const MCSymbol &Symbol, bool IsUsedInReloc,
|
||||||
bool IsSignature) {
|
bool IsSignature) {
|
||||||
const MCSymbol &Data = Symbol.getData();
|
if (Symbol.isExternal())
|
||||||
if (Data.isExternal())
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (Symbol.isDefined())
|
if (Symbol.isDefined())
|
||||||
|
@ -120,14 +120,13 @@ uint64_t MCAsmLayout::getFragmentOffset(const MCFragment *F) const {
|
|||||||
// Simple getSymbolOffset helper for the non-varibale case.
|
// Simple getSymbolOffset helper for the non-varibale case.
|
||||||
static bool getLabelOffset(const MCAsmLayout &Layout, const MCSymbol &S,
|
static bool getLabelOffset(const MCAsmLayout &Layout, const MCSymbol &S,
|
||||||
bool ReportError, uint64_t &Val) {
|
bool ReportError, uint64_t &Val) {
|
||||||
const MCSymbol &SD = S.getData();
|
if (!S.getFragment()) {
|
||||||
if (!SD.getFragment()) {
|
|
||||||
if (ReportError)
|
if (ReportError)
|
||||||
report_fatal_error("unable to evaluate offset to undefined symbol '" +
|
report_fatal_error("unable to evaluate offset to undefined symbol '" +
|
||||||
S.getName() + "'");
|
S.getName() + "'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Val = Layout.getFragmentOffset(SD.getFragment()) + S.getOffset();
|
Val = Layout.getFragmentOffset(S.getFragment()) + S.getOffset();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,17 +376,17 @@ const MCSymbol *MCAssembler::getAtom(const MCSymbol &S) const {
|
|||||||
return &S;
|
return &S;
|
||||||
|
|
||||||
// Absolute and undefined symbols have no defining atom.
|
// Absolute and undefined symbols have no defining atom.
|
||||||
if (!S.getData().getFragment())
|
if (!S.getFragment())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
// Non-linker visible symbols in sections which can't be atomized have no
|
// Non-linker visible symbols in sections which can't be atomized have no
|
||||||
// defining atom.
|
// defining atom.
|
||||||
if (!getContext().getAsmInfo()->isSectionAtomizableBySymbols(
|
if (!getContext().getAsmInfo()->isSectionAtomizableBySymbols(
|
||||||
*S.getData().getFragment()->getParent()))
|
*S.getFragment()->getParent()))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
// Otherwise, return the atom for the containing fragment.
|
// Otherwise, return the atom for the containing fragment.
|
||||||
return S.getData().getFragment()->getAtom();
|
return S.getFragment()->getAtom();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MCAssembler::evaluateFixup(const MCAsmLayout &Layout,
|
bool MCAssembler::evaluateFixup(const MCAsmLayout &Layout,
|
||||||
@ -1200,7 +1199,6 @@ void MCAssembler::dump() {
|
|||||||
OS << "(";
|
OS << "(";
|
||||||
it->dump();
|
it->dump();
|
||||||
OS << ", Index:" << it->getIndex() << ", ";
|
OS << ", Index:" << it->getIndex() << ", ";
|
||||||
it->getData().dump();
|
|
||||||
OS << ")";
|
OS << ")";
|
||||||
}
|
}
|
||||||
OS << "]>\n";
|
OS << "]>\n";
|
||||||
|
@ -214,7 +214,6 @@ bool MCELFStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
|
|||||||
// important side effect of calling registerSymbol here is to register
|
// important side effect of calling registerSymbol here is to register
|
||||||
// the symbol with the assembler.
|
// the symbol with the assembler.
|
||||||
getAssembler().registerSymbol(*Symbol);
|
getAssembler().registerSymbol(*Symbol);
|
||||||
MCSymbol &SD = Symbol->getData();
|
|
||||||
|
|
||||||
// The implementation of symbol attributes is designed to match 'as', but it
|
// 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
|
// leaves much to desired. It doesn't really make sense to arbitrarily add and
|
||||||
@ -241,26 +240,26 @@ bool MCELFStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
|
|||||||
MCELF::SetType(
|
MCELF::SetType(
|
||||||
*Symbol, CombineSymbolTypes(MCELF::GetType(*Symbol), ELF::STT_OBJECT));
|
*Symbol, CombineSymbolTypes(MCELF::GetType(*Symbol), ELF::STT_OBJECT));
|
||||||
MCELF::SetBinding(*Symbol, ELF::STB_GNU_UNIQUE);
|
MCELF::SetBinding(*Symbol, ELF::STB_GNU_UNIQUE);
|
||||||
SD.setExternal(true);
|
Symbol->setExternal(true);
|
||||||
BindingExplicitlySet.insert(Symbol);
|
BindingExplicitlySet.insert(Symbol);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MCSA_Global:
|
case MCSA_Global:
|
||||||
MCELF::SetBinding(*Symbol, ELF::STB_GLOBAL);
|
MCELF::SetBinding(*Symbol, ELF::STB_GLOBAL);
|
||||||
SD.setExternal(true);
|
Symbol->setExternal(true);
|
||||||
BindingExplicitlySet.insert(Symbol);
|
BindingExplicitlySet.insert(Symbol);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MCSA_WeakReference:
|
case MCSA_WeakReference:
|
||||||
case MCSA_Weak:
|
case MCSA_Weak:
|
||||||
MCELF::SetBinding(*Symbol, ELF::STB_WEAK);
|
MCELF::SetBinding(*Symbol, ELF::STB_WEAK);
|
||||||
SD.setExternal(true);
|
Symbol->setExternal(true);
|
||||||
BindingExplicitlySet.insert(Symbol);
|
BindingExplicitlySet.insert(Symbol);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MCSA_Local:
|
case MCSA_Local:
|
||||||
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
|
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
|
||||||
SD.setExternal(false);
|
Symbol->setExternal(false);
|
||||||
BindingExplicitlySet.insert(Symbol);
|
BindingExplicitlySet.insert(Symbol);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -314,11 +313,10 @@ bool MCELFStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
|
|||||||
void MCELFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
void MCELFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||||
unsigned ByteAlignment) {
|
unsigned ByteAlignment) {
|
||||||
getAssembler().registerSymbol(*Symbol);
|
getAssembler().registerSymbol(*Symbol);
|
||||||
MCSymbol &SD = Symbol->getData();
|
|
||||||
|
|
||||||
if (!BindingExplicitlySet.count(Symbol)) {
|
if (!BindingExplicitlySet.count(Symbol)) {
|
||||||
MCELF::SetBinding(*Symbol, ELF::STB_GLOBAL);
|
MCELF::SetBinding(*Symbol, ELF::STB_GLOBAL);
|
||||||
SD.setExternal(true);
|
Symbol->setExternal(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
MCELF::SetType(*Symbol, ELF::STT_OBJECT);
|
MCELF::SetType(*Symbol, ELF::STT_OBJECT);
|
||||||
@ -346,9 +344,8 @@ void MCELFStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
|||||||
unsigned ByteAlignment) {
|
unsigned ByteAlignment) {
|
||||||
// FIXME: Should this be caught and done earlier?
|
// FIXME: Should this be caught and done earlier?
|
||||||
getAssembler().registerSymbol(*Symbol);
|
getAssembler().registerSymbol(*Symbol);
|
||||||
MCSymbol &SD = Symbol->getData();
|
|
||||||
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
|
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
|
||||||
SD.setExternal(false);
|
Symbol->setExternal(false);
|
||||||
BindingExplicitlySet.insert(Symbol);
|
BindingExplicitlySet.insert(Symbol);
|
||||||
EmitCommonSymbol(Symbol, Size, ByteAlignment);
|
EmitCommonSymbol(Symbol, Size, ByteAlignment);
|
||||||
}
|
}
|
||||||
@ -648,7 +645,7 @@ void MCELFStreamer::Flush() {
|
|||||||
new MCAlignFragment(ByteAlignment, 0, 1, ByteAlignment, &Section);
|
new MCAlignFragment(ByteAlignment, 0, 1, ByteAlignment, &Section);
|
||||||
|
|
||||||
MCFragment *F = new MCFillFragment(0, 0, Size, &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.
|
// Update the maximum alignment of the section if necessary.
|
||||||
if (ByteAlignment > Section.getAlignment())
|
if (ByteAlignment > Section.getAlignment())
|
||||||
|
@ -471,10 +471,7 @@ static void AttemptToFoldSymbolOffsetDifference(
|
|||||||
if (!Asm->getWriter().IsSymbolRefDifferenceFullyResolved(*Asm, A, B, InSet))
|
if (!Asm->getWriter().IsSymbolRefDifferenceFullyResolved(*Asm, A, B, InSet))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const MCSymbol &AD = SA.getData();
|
if (SA.getFragment() == SB.getFragment()) {
|
||||||
const MCSymbol &BD = SB.getData();
|
|
||||||
|
|
||||||
if (AD.getFragment() == BD.getFragment()) {
|
|
||||||
Addend += (SA.getOffset() - SB.getOffset());
|
Addend += (SA.getOffset() - SB.getOffset());
|
||||||
|
|
||||||
// Pointers to Thumb symbols need to have their low-bit set to allow
|
// Pointers to Thumb symbols need to have their low-bit set to allow
|
||||||
@ -491,8 +488,8 @@ static void AttemptToFoldSymbolOffsetDifference(
|
|||||||
if (!Layout)
|
if (!Layout)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const MCSection &SecA = *AD.getFragment()->getParent();
|
const MCSection &SecA = *SA.getFragment()->getParent();
|
||||||
const MCSection &SecB = *BD.getFragment()->getParent();
|
const MCSection &SecB = *SB.getFragment()->getParent();
|
||||||
|
|
||||||
if ((&SecA != &SecB) && !Addrs)
|
if ((&SecA != &SecB) && !Addrs)
|
||||||
return;
|
return;
|
||||||
|
@ -173,12 +173,11 @@ void MCMachOStreamer::ChangeSection(MCSection *Section,
|
|||||||
void MCMachOStreamer::EmitEHSymAttributes(const MCSymbol *Symbol,
|
void MCMachOStreamer::EmitEHSymAttributes(const MCSymbol *Symbol,
|
||||||
MCSymbol *EHSymbol) {
|
MCSymbol *EHSymbol) {
|
||||||
getAssembler().registerSymbol(*Symbol);
|
getAssembler().registerSymbol(*Symbol);
|
||||||
MCSymbol &SD = Symbol->getData();
|
if (Symbol->isExternal())
|
||||||
if (SD.isExternal())
|
|
||||||
EmitSymbolAttribute(EHSymbol, MCSA_Global);
|
EmitSymbolAttribute(EHSymbol, MCSA_Global);
|
||||||
if (Symbol->getFlags() & SF_WeakDefinition)
|
if (Symbol->getFlags() & SF_WeakDefinition)
|
||||||
EmitSymbolAttribute(EHSymbol, MCSA_WeakDefinition);
|
EmitSymbolAttribute(EHSymbol, MCSA_WeakDefinition);
|
||||||
if (SD.isPrivateExtern())
|
if (Symbol->isPrivateExtern())
|
||||||
EmitSymbolAttribute(EHSymbol, MCSA_PrivateExtern);
|
EmitSymbolAttribute(EHSymbol, MCSA_PrivateExtern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,7 +295,6 @@ bool MCMachOStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
|
|||||||
// important side effect of calling registerSymbol here is to register
|
// important side effect of calling registerSymbol here is to register
|
||||||
// the symbol with the assembler.
|
// the symbol with the assembler.
|
||||||
getAssembler().registerSymbol(*Symbol);
|
getAssembler().registerSymbol(*Symbol);
|
||||||
MCSymbol &SD = Symbol->getData();
|
|
||||||
|
|
||||||
// The implementation of symbol attributes is designed to match 'as', but it
|
// 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
|
// leaves much to desired. It doesn't really make sense to arbitrarily add and
|
||||||
@ -322,7 +320,7 @@ bool MCMachOStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
case MCSA_Global:
|
case MCSA_Global:
|
||||||
SD.setExternal(true);
|
Symbol->setExternal(true);
|
||||||
// This effectively clears the undefined lazy bit, in Darwin 'as', although
|
// This effectively clears the undefined lazy bit, in Darwin 'as', although
|
||||||
// it isn't very consistent because it implements this as part of symbol
|
// it isn't very consistent because it implements this as part of symbol
|
||||||
// lookup.
|
// lookup.
|
||||||
@ -351,8 +349,8 @@ bool MCMachOStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MCSA_PrivateExtern:
|
case MCSA_PrivateExtern:
|
||||||
SD.setExternal(true);
|
Symbol->setExternal(true);
|
||||||
SD.setPrivateExtern(true);
|
Symbol->setPrivateExtern(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MCSA_WeakReference:
|
case MCSA_WeakReference:
|
||||||
@ -391,8 +389,7 @@ void MCMachOStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
|||||||
AssignSection(Symbol, nullptr);
|
AssignSection(Symbol, nullptr);
|
||||||
|
|
||||||
getAssembler().registerSymbol(*Symbol);
|
getAssembler().registerSymbol(*Symbol);
|
||||||
MCSymbol &SD = Symbol->getData();
|
Symbol->setExternal(true);
|
||||||
SD.setExternal(true);
|
|
||||||
Symbol->setCommon(Size, ByteAlignment);
|
Symbol->setCommon(Size, ByteAlignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,14 +414,13 @@ void MCMachOStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol,
|
|||||||
assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
|
assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
|
||||||
|
|
||||||
getAssembler().registerSymbol(*Symbol);
|
getAssembler().registerSymbol(*Symbol);
|
||||||
MCSymbol &SD = Symbol->getData();
|
|
||||||
|
|
||||||
// Emit an align fragment if necessary.
|
// Emit an align fragment if necessary.
|
||||||
if (ByteAlignment != 1)
|
if (ByteAlignment != 1)
|
||||||
new MCAlignFragment(ByteAlignment, 0, 0, ByteAlignment, Section);
|
new MCAlignFragment(ByteAlignment, 0, 0, ByteAlignment, Section);
|
||||||
|
|
||||||
MCFragment *F = new MCFillFragment(0, 0, Size, Section);
|
MCFragment *F = new MCFillFragment(0, 0, Size, Section);
|
||||||
SD.setFragment(F);
|
Symbol->setFragment(F);
|
||||||
|
|
||||||
AssignSection(Symbol, Section);
|
AssignSection(Symbol, Section);
|
||||||
|
|
||||||
@ -469,12 +465,11 @@ void MCMachOStreamer::FinishImpl() {
|
|||||||
// defining symbols.
|
// defining symbols.
|
||||||
DenseMap<const MCFragment *, const MCSymbol *> DefiningSymbolMap;
|
DenseMap<const MCFragment *, const MCSymbol *> DefiningSymbolMap;
|
||||||
for (const MCSymbol &Symbol : getAssembler().symbols()) {
|
for (const MCSymbol &Symbol : getAssembler().symbols()) {
|
||||||
MCSymbol &SD = Symbol.getData();
|
if (getAssembler().isSymbolLinkerVisible(Symbol) && Symbol.getFragment()) {
|
||||||
if (getAssembler().isSymbolLinkerVisible(Symbol) && SD.getFragment()) {
|
|
||||||
// An atom defining symbol should never be internal to a fragment.
|
// An atom defining symbol should never be internal to a fragment.
|
||||||
assert(Symbol.getOffset() == 0 &&
|
assert(Symbol.getOffset() == 0 &&
|
||||||
"Invalid offset in atom defining symbol!");
|
"Invalid offset in atom defining symbol!");
|
||||||
DefiningSymbolMap[SD.getFragment()] = &Symbol;
|
DefiningSymbolMap[Symbol.getFragment()] = &Symbol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,8 +47,7 @@ void MCObjectStreamer::flushPendingLabels(MCFragment *F, uint64_t FOffset) {
|
|||||||
F->setParent(CurSection);
|
F->setParent(CurSection);
|
||||||
}
|
}
|
||||||
for (MCSymbol *Sym : PendingLabels) {
|
for (MCSymbol *Sym : PendingLabels) {
|
||||||
MCSymbol *SD = &Sym->getData();
|
Sym->setFragment(F);
|
||||||
SD->setFragment(F);
|
|
||||||
Sym->setOffset(FOffset);
|
Sym->setOffset(FOffset);
|
||||||
}
|
}
|
||||||
PendingLabels.clear();
|
PendingLabels.clear();
|
||||||
@ -61,15 +60,13 @@ bool MCObjectStreamer::emitAbsoluteSymbolDiff(const MCSymbol *Hi,
|
|||||||
// Must have symbol data.
|
// Must have symbol data.
|
||||||
if (!Assembler->hasSymbolData(*Hi) || !Assembler->hasSymbolData(*Lo))
|
if (!Assembler->hasSymbolData(*Hi) || !Assembler->hasSymbolData(*Lo))
|
||||||
return false;
|
return false;
|
||||||
auto &HiD = Hi->getData();
|
|
||||||
auto &LoD = Lo->getData();
|
|
||||||
|
|
||||||
// Must both be assigned to the same (valid) fragment.
|
// 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;
|
return false;
|
||||||
|
|
||||||
// Must be a data fragment.
|
// Must be a data fragment.
|
||||||
if (!isa<MCDataFragment>(HiD.getFragment()))
|
if (!isa<MCDataFragment>(Hi->getFragment()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
assert(Hi->getOffset() >= Lo->getOffset() &&
|
assert(Hi->getOffset() >= Lo->getOffset() &&
|
||||||
@ -164,8 +161,7 @@ void MCObjectStreamer::EmitLabel(MCSymbol *Symbol) {
|
|||||||
MCStreamer::EmitLabel(Symbol);
|
MCStreamer::EmitLabel(Symbol);
|
||||||
|
|
||||||
getAssembler().registerSymbol(*Symbol);
|
getAssembler().registerSymbol(*Symbol);
|
||||||
MCSymbol &SD = Symbol->getData();
|
assert(!Symbol->getFragment() && "Unexpected fragment on symbol data!");
|
||||||
assert(!SD.getFragment() && "Unexpected fragment on symbol data!");
|
|
||||||
|
|
||||||
// If there is a current fragment, mark the symbol as pointing into it.
|
// 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
|
// Otherwise queue the label and set its fragment pointer when we emit the
|
||||||
@ -173,7 +169,7 @@ void MCObjectStreamer::EmitLabel(MCSymbol *Symbol) {
|
|||||||
auto *F = dyn_cast_or_null<MCDataFragment>(getCurrentFragment());
|
auto *F = dyn_cast_or_null<MCDataFragment>(getCurrentFragment());
|
||||||
if (F && !(getAssembler().isBundlingEnabled() &&
|
if (F && !(getAssembler().isBundlingEnabled() &&
|
||||||
getAssembler().getRelaxAll())) {
|
getAssembler().getRelaxAll())) {
|
||||||
SD.setFragment(F);
|
Symbol->setFragment(F);
|
||||||
Symbol->setOffset(F->getContents().size());
|
Symbol->setOffset(F->getContents().size());
|
||||||
} else {
|
} else {
|
||||||
PendingLabels.push_back(Symbol);
|
PendingLabels.push_back(Symbol);
|
||||||
|
@ -30,12 +30,10 @@ bool MCObjectWriter::IsSymbolRefDifferenceFullyResolved(
|
|||||||
if (SA.isUndefined() || SB.isUndefined())
|
if (SA.isUndefined() || SB.isUndefined())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const MCSymbol &DataA = SA.getData();
|
if (!SA.getFragment() || !SB.getFragment())
|
||||||
const MCSymbol &DataB = SB.getData();
|
|
||||||
if(!DataA.getFragment() || !DataB.getFragment())
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return IsSymbolRefDifferenceFullyResolvedImpl(Asm, SA, *DataB.getFragment(),
|
return IsSymbolRefDifferenceFullyResolvedImpl(Asm, SA, *SB.getFragment(),
|
||||||
InSet, false);
|
InSet, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ uint64_t MachObjectWriter::getSymbolAddress(const MCSymbol &S,
|
|||||||
return Address;
|
return Address;
|
||||||
}
|
}
|
||||||
|
|
||||||
return getSectionAddress(S.getData().getFragment()->getParent()) +
|
return getSectionAddress(S.getFragment()->getParent()) +
|
||||||
Layout.getSymbolOffset(S);
|
Layout.getSymbolOffset(S);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,7 +329,7 @@ const MCSymbol &MachObjectWriter::findAliasedSymbol(const MCSymbol &Sym) const {
|
|||||||
void MachObjectWriter::WriteNlist(MachSymbolData &MSD,
|
void MachObjectWriter::WriteNlist(MachSymbolData &MSD,
|
||||||
const MCAsmLayout &Layout) {
|
const MCAsmLayout &Layout) {
|
||||||
const MCSymbol *Symbol = MSD.Symbol;
|
const MCSymbol *Symbol = MSD.Symbol;
|
||||||
MCSymbol &Data = Symbol->getData();
|
const MCSymbol &Data = *Symbol;
|
||||||
const MCSymbol *AliasedSymbol = &findAliasedSymbol(*Symbol);
|
const MCSymbol *AliasedSymbol = &findAliasedSymbol(*Symbol);
|
||||||
uint8_t SectionIndex = MSD.SectionIndex;
|
uint8_t SectionIndex = MSD.SectionIndex;
|
||||||
uint8_t Type = 0;
|
uint8_t Type = 0;
|
||||||
@ -554,13 +554,11 @@ void MachObjectWriter::ComputeSymbolTable(
|
|||||||
// match 'as'. Even though it doesn't matter for correctness, this is
|
// match 'as'. Even though it doesn't matter for correctness, this is
|
||||||
// important for letting us diff .o files.
|
// important for letting us diff .o files.
|
||||||
for (const MCSymbol &Symbol : Asm.symbols()) {
|
for (const MCSymbol &Symbol : Asm.symbols()) {
|
||||||
MCSymbol &SD = Symbol.getData();
|
|
||||||
|
|
||||||
// Ignore non-linker visible symbols.
|
// Ignore non-linker visible symbols.
|
||||||
if (!Asm.isSymbolLinkerVisible(Symbol))
|
if (!Asm.isSymbolLinkerVisible(Symbol))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!SD.isExternal() && !Symbol.isUndefined())
|
if (!Symbol.isExternal() && !Symbol.isUndefined())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
MachSymbolData MSD;
|
MachSymbolData MSD;
|
||||||
@ -582,13 +580,11 @@ void MachObjectWriter::ComputeSymbolTable(
|
|||||||
|
|
||||||
// Now add the data for local symbols.
|
// Now add the data for local symbols.
|
||||||
for (const MCSymbol &Symbol : Asm.symbols()) {
|
for (const MCSymbol &Symbol : Asm.symbols()) {
|
||||||
MCSymbol &SD = Symbol.getData();
|
|
||||||
|
|
||||||
// Ignore non-linker visible symbols.
|
// Ignore non-linker visible symbols.
|
||||||
if (!Asm.isSymbolLinkerVisible(Symbol))
|
if (!Asm.isSymbolLinkerVisible(Symbol))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (SD.isExternal() || Symbol.isUndefined())
|
if (Symbol.isExternal() || Symbol.isUndefined())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
MachSymbolData MSD;
|
MachSymbolData MSD;
|
||||||
@ -692,8 +688,7 @@ bool MachObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(
|
|||||||
bool hasReliableSymbolDifference = isX86_64();
|
bool hasReliableSymbolDifference = isX86_64();
|
||||||
if (!hasReliableSymbolDifference) {
|
if (!hasReliableSymbolDifference) {
|
||||||
if (!SA.isInSection() || &SecA != &SecB ||
|
if (!SA.isInSection() || &SecA != &SecB ||
|
||||||
(!SA.isTemporary() &&
|
(!SA.isTemporary() && FB.getAtom() != SA.getFragment()->getAtom() &&
|
||||||
FB.getAtom() != SA.getData().getFragment()->getAtom() &&
|
|
||||||
Asm.getSubsectionsViaSymbols()))
|
Asm.getSubsectionsViaSymbols()))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
@ -717,7 +712,7 @@ bool MachObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(
|
|||||||
if (&SecA != &SecB)
|
if (&SecA != &SecB)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const MCFragment *FA = SA.getData().getFragment();
|
const MCFragment *FA = SA.getFragment();
|
||||||
|
|
||||||
// Bail if the symbol has no fragment.
|
// Bail if the symbol has no fragment.
|
||||||
if (!FA)
|
if (!FA)
|
||||||
@ -968,7 +963,7 @@ void MachObjectWriter::WriteObject(MCAssembler &Asm,
|
|||||||
static_cast<const MCSectionMachO &>(*it->Section);
|
static_cast<const MCSectionMachO &>(*it->Section);
|
||||||
if (Section.getType() == MachO::S_NON_LAZY_SYMBOL_POINTERS) {
|
if (Section.getType() == MachO::S_NON_LAZY_SYMBOL_POINTERS) {
|
||||||
// If this symbol is defined and internal, mark it as such.
|
// 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;
|
uint32_t Flags = MachO::INDIRECT_SYMBOL_LOCAL;
|
||||||
if (it->Symbol->isAbsolute())
|
if (it->Symbol->isAbsolute())
|
||||||
Flags |= MachO::INDIRECT_SYMBOL_ABS;
|
Flags |= MachO::INDIRECT_SYMBOL_ABS;
|
||||||
|
@ -364,8 +364,7 @@ void WinCOFFObjectWriter::defineSection(MCSectionCOFF const &Sec) {
|
|||||||
|
|
||||||
static uint64_t getSymbolValue(const MCSymbol &Symbol,
|
static uint64_t getSymbolValue(const MCSymbol &Symbol,
|
||||||
const MCAsmLayout &Layout) {
|
const MCAsmLayout &Layout) {
|
||||||
const MCSymbol &Data = Symbol.getData();
|
if (Symbol.isCommon() && Symbol.isExternal())
|
||||||
if (Symbol.isCommon() && Data.isExternal())
|
|
||||||
return Symbol.getCommonSize();
|
return Symbol.getCommonSize();
|
||||||
|
|
||||||
uint64_t Res;
|
uint64_t Res;
|
||||||
@ -414,7 +413,6 @@ void WinCOFFObjectWriter::DefineSymbol(const MCSymbol &Symbol,
|
|||||||
|
|
||||||
coff_symbol->MC = &Symbol;
|
coff_symbol->MC = &Symbol;
|
||||||
} else {
|
} else {
|
||||||
const MCSymbol &ResSymData = Symbol.getData();
|
|
||||||
const MCSymbol *Base = Layout.getBaseSymbol(Symbol);
|
const MCSymbol *Base = Layout.getBaseSymbol(Symbol);
|
||||||
coff_symbol->Data.Value = getSymbolValue(Symbol, Layout);
|
coff_symbol->Data.Value = getSymbolValue(Symbol, Layout);
|
||||||
|
|
||||||
@ -423,8 +421,8 @@ void WinCOFFObjectWriter::DefineSymbol(const MCSymbol &Symbol,
|
|||||||
|
|
||||||
// If no storage class was specified in the streamer, define it here.
|
// If no storage class was specified in the streamer, define it here.
|
||||||
if (coff_symbol->Data.StorageClass == 0) {
|
if (coff_symbol->Data.StorageClass == 0) {
|
||||||
bool IsExternal = ResSymData.isExternal() ||
|
bool IsExternal = Symbol.isExternal() ||
|
||||||
(!ResSymData.getFragment() && !Symbol.isVariable());
|
(!Symbol.getFragment() && !Symbol.isVariable());
|
||||||
|
|
||||||
coff_symbol->Data.StorageClass = IsExternal
|
coff_symbol->Data.StorageClass = IsExternal
|
||||||
? COFF::IMAGE_SYM_CLASS_EXTERNAL
|
? COFF::IMAGE_SYM_CLASS_EXTERNAL
|
||||||
@ -434,9 +432,8 @@ void WinCOFFObjectWriter::DefineSymbol(const MCSymbol &Symbol,
|
|||||||
if (!Base) {
|
if (!Base) {
|
||||||
coff_symbol->Data.SectionNumber = COFF::IMAGE_SYM_ABSOLUTE;
|
coff_symbol->Data.SectionNumber = COFF::IMAGE_SYM_ABSOLUTE;
|
||||||
} else {
|
} else {
|
||||||
const MCSymbol &BaseData = Base->getData();
|
if (Base->getFragment()) {
|
||||||
if (BaseData.getFragment()) {
|
COFFSection *Sec = SectionMap[Base->getFragment()->getParent()];
|
||||||
COFFSection *Sec = SectionMap[BaseData.getFragment()->getParent()];
|
|
||||||
|
|
||||||
if (coff_symbol->Section && coff_symbol->Section != Sec)
|
if (coff_symbol->Section && coff_symbol->Section != Sec)
|
||||||
report_fatal_error("conflicting sections for symbol");
|
report_fatal_error("conflicting sections for symbol");
|
||||||
@ -672,8 +669,7 @@ bool WinCOFFObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool WinCOFFObjectWriter::isWeak(const MCSymbol &Sym) const {
|
bool WinCOFFObjectWriter::isWeak(const MCSymbol &Sym) const {
|
||||||
const MCSymbol &SD = Sym.getData();
|
if (!Sym.isExternal())
|
||||||
if (!SD.isExternal())
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!Sym.isInSection())
|
if (!Sym.isInSection())
|
||||||
@ -701,8 +697,6 @@ void WinCOFFObjectWriter::RecordRelocation(
|
|||||||
Twine("symbol '") + A.getName() +
|
Twine("symbol '") + A.getName() +
|
||||||
"' can not be undefined");
|
"' can not be undefined");
|
||||||
|
|
||||||
const MCSymbol &A_SD = A.getData();
|
|
||||||
|
|
||||||
MCSection *Section = Fragment->getParent();
|
MCSection *Section = Fragment->getParent();
|
||||||
|
|
||||||
// Mark this symbol as requiring an entry in the symbol table.
|
// Mark this symbol as requiring an entry in the symbol table.
|
||||||
@ -718,14 +712,13 @@ void WinCOFFObjectWriter::RecordRelocation(
|
|||||||
|
|
||||||
if (SymB) {
|
if (SymB) {
|
||||||
const MCSymbol *B = &SymB->getSymbol();
|
const MCSymbol *B = &SymB->getSymbol();
|
||||||
const MCSymbol &B_SD = B->getData();
|
if (!B->getFragment())
|
||||||
if (!B_SD.getFragment())
|
|
||||||
Asm.getContext().reportFatalError(
|
Asm.getContext().reportFatalError(
|
||||||
Fixup.getLoc(),
|
Fixup.getLoc(),
|
||||||
Twine("symbol '") + B->getName() +
|
Twine("symbol '") + B->getName() +
|
||||||
"' can not be undefined in a subtraction expression");
|
"' can not be undefined in a subtraction expression");
|
||||||
|
|
||||||
if (!A_SD.getFragment())
|
if (!A.getFragment())
|
||||||
Asm.getContext().reportFatalError(
|
Asm.getContext().reportFatalError(
|
||||||
Fixup.getLoc(),
|
Fixup.getLoc(),
|
||||||
Twine("symbol '") + Symbol.getName() +
|
Twine("symbol '") + Symbol.getName() +
|
||||||
@ -762,9 +755,8 @@ void WinCOFFObjectWriter::RecordRelocation(
|
|||||||
// Turn relocations for temporary symbols into section relocations.
|
// Turn relocations for temporary symbols into section relocations.
|
||||||
if (coff_symbol->MC->isTemporary() || CrossSection) {
|
if (coff_symbol->MC->isTemporary() || CrossSection) {
|
||||||
Reloc.Symb = coff_symbol->Section->Symbol;
|
Reloc.Symb = coff_symbol->Section->Symbol;
|
||||||
FixedValue +=
|
FixedValue += Layout.getFragmentOffset(coff_symbol->MC->getFragment()) +
|
||||||
Layout.getFragmentOffset(coff_symbol->MC->getData().getFragment()) +
|
coff_symbol->MC->getOffset();
|
||||||
coff_symbol->MC->getOffset();
|
|
||||||
} else
|
} else
|
||||||
Reloc.Symb = coff_symbol;
|
Reloc.Symb = coff_symbol;
|
||||||
|
|
||||||
|
@ -97,17 +97,16 @@ bool MCWinCOFFStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
|
|||||||
"Got non-COFF section in the COFF backend!");
|
"Got non-COFF section in the COFF backend!");
|
||||||
|
|
||||||
getAssembler().registerSymbol(*Symbol);
|
getAssembler().registerSymbol(*Symbol);
|
||||||
MCSymbol &SD = Symbol->getData();
|
|
||||||
|
|
||||||
switch (Attribute) {
|
switch (Attribute) {
|
||||||
default: return false;
|
default: return false;
|
||||||
case MCSA_WeakReference:
|
case MCSA_WeakReference:
|
||||||
case MCSA_Weak:
|
case MCSA_Weak:
|
||||||
Symbol->modifyFlags(COFF::SF_WeakExternal, COFF::SF_WeakExternal);
|
Symbol->modifyFlags(COFF::SF_WeakExternal, COFF::SF_WeakExternal);
|
||||||
SD.setExternal(true);
|
Symbol->setExternal(true);
|
||||||
break;
|
break;
|
||||||
case MCSA_Global:
|
case MCSA_Global:
|
||||||
SD.setExternal(true);
|
Symbol->setExternal(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,8 +196,7 @@ void MCWinCOFFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
|||||||
AssignSection(Symbol, nullptr);
|
AssignSection(Symbol, nullptr);
|
||||||
|
|
||||||
getAssembler().registerSymbol(*Symbol);
|
getAssembler().registerSymbol(*Symbol);
|
||||||
MCSymbol &SD = Symbol->getData();
|
Symbol->setExternal(true);
|
||||||
SD.setExternal(true);
|
|
||||||
Symbol->setCommon(Size, ByteAlignment);
|
Symbol->setCommon(Size, ByteAlignment);
|
||||||
|
|
||||||
if (!T.isKnownWindowsMSVCEnvironment() && ByteAlignment > 1) {
|
if (!T.isKnownWindowsMSVCEnvironment() && ByteAlignment > 1) {
|
||||||
@ -227,8 +225,7 @@ void MCWinCOFFStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
|||||||
Section->setAlignment(ByteAlignment);
|
Section->setAlignment(ByteAlignment);
|
||||||
|
|
||||||
getAssembler().registerSymbol(*Symbol);
|
getAssembler().registerSymbol(*Symbol);
|
||||||
MCSymbol &SD = Symbol->getData();
|
Symbol->setExternal(false);
|
||||||
SD.setExternal(false);
|
|
||||||
|
|
||||||
AssignSection(Symbol, Section);
|
AssignSection(Symbol, Section);
|
||||||
|
|
||||||
@ -238,7 +235,7 @@ void MCWinCOFFStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
|||||||
|
|
||||||
MCFillFragment *Fragment = new MCFillFragment(
|
MCFillFragment *Fragment = new MCFillFragment(
|
||||||
/*Value=*/0, /*ValueSize=*/0, Size, Section);
|
/*Value=*/0, /*ValueSize=*/0, Size, Section);
|
||||||
SD.setFragment(Fragment);
|
Symbol->setFragment(Fragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCWinCOFFStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol,
|
void MCWinCOFFStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol,
|
||||||
|
@ -165,10 +165,9 @@ private:
|
|||||||
Name + "." + Twine(MappingSymbolCounter++));
|
Name + "." + Twine(MappingSymbolCounter++));
|
||||||
|
|
||||||
getAssembler().registerSymbol(*Symbol);
|
getAssembler().registerSymbol(*Symbol);
|
||||||
MCSymbol &SD = Symbol->getData();
|
|
||||||
MCELF::SetType(*Symbol, ELF::STT_NOTYPE);
|
MCELF::SetType(*Symbol, ELF::STT_NOTYPE);
|
||||||
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
|
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
|
||||||
SD.setExternal(false);
|
Symbol->setExternal(false);
|
||||||
auto Sec = getCurrentSection().first;
|
auto Sec = getCurrentSection().first;
|
||||||
assert(Sec && "need a section");
|
assert(Sec && "need a section");
|
||||||
Symbol->setSection(*Sec);
|
Symbol->setSection(*Sec);
|
||||||
|
@ -209,11 +209,9 @@ void AArch64MachObjectWriter::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();
|
||||||
const MCSymbol &A_SD = A->getData();
|
|
||||||
const MCSymbol *A_Base = Asm.getAtom(*A);
|
const MCSymbol *A_Base = Asm.getAtom(*A);
|
||||||
|
|
||||||
const MCSymbol *B = &Target.getSymB()->getSymbol();
|
const MCSymbol *B = &Target.getSymB()->getSymbol();
|
||||||
const MCSymbol &B_SD = B->getData();
|
|
||||||
const MCSymbol *B_Base = Asm.getAtom(*B);
|
const MCSymbol *B_Base = Asm.getAtom(*B);
|
||||||
|
|
||||||
// Check for "_foo@got - .", which comes through here as:
|
// Check for "_foo@got - .", which comes through here as:
|
||||||
@ -264,14 +262,12 @@ void AArch64MachObjectWriter::RecordRelocation(
|
|||||||
Asm.getContext().reportFatalError(Fixup.getLoc(),
|
Asm.getContext().reportFatalError(Fixup.getLoc(),
|
||||||
"unsupported relocation with identical base");
|
"unsupported relocation with identical base");
|
||||||
|
|
||||||
Value += (!A_SD.getFragment() ? 0 : Writer->getSymbolAddress(*A, Layout)) -
|
Value += (!A->getFragment() ? 0 : Writer->getSymbolAddress(*A, Layout)) -
|
||||||
(!A_Base || !A_Base->getData().getFragment()
|
(!A_Base || !A_Base->getFragment() ? 0 : Writer->getSymbolAddress(
|
||||||
? 0
|
*A_Base, Layout));
|
||||||
: Writer->getSymbolAddress(*A_Base, Layout));
|
Value -= (!B->getFragment() ? 0 : Writer->getSymbolAddress(*B, Layout)) -
|
||||||
Value -= (!B_SD.getFragment() ? 0 : Writer->getSymbolAddress(*B, Layout)) -
|
(!B_Base || !B_Base->getFragment() ? 0 : Writer->getSymbolAddress(
|
||||||
(!B_Base || !B_Base->getData().getFragment()
|
*B_Base, Layout));
|
||||||
? 0
|
|
||||||
: Writer->getSymbolAddress(*B_Base, Layout));
|
|
||||||
|
|
||||||
Type = MachO::ARM64_RELOC_UNSIGNED;
|
Type = MachO::ARM64_RELOC_UNSIGNED;
|
||||||
|
|
||||||
|
@ -601,8 +601,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();
|
const MCSymbol &Sym = A->getSymbol();
|
||||||
const MCSymbol &SymData = Sym.getData();
|
IsResolved = (Sym.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
|
||||||
// a symbol to reference, as the linker relies on knowing the destination
|
// a symbol to reference, as the linker relies on knowing the destination
|
||||||
|
@ -567,10 +567,9 @@ private:
|
|||||||
Twine(MappingSymbolCounter++));
|
Twine(MappingSymbolCounter++));
|
||||||
|
|
||||||
getAssembler().registerSymbol(*Symbol);
|
getAssembler().registerSymbol(*Symbol);
|
||||||
MCSymbol &SD = Symbol->getData();
|
|
||||||
MCELF::SetType(*Symbol, ELF::STT_NOTYPE);
|
MCELF::SetType(*Symbol, ELF::STT_NOTYPE);
|
||||||
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
|
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
|
||||||
SD.setExternal(false);
|
Symbol->setExternal(false);
|
||||||
AssignSection(Symbol, getCurrentSection().first);
|
AssignSection(Symbol, getCurrentSection().first);
|
||||||
|
|
||||||
const MCExpr *Value = MCSymbolRefExpr::Create(Start, getContext());
|
const MCExpr *Value = MCSymbolRefExpr::Create(Start, getContext());
|
||||||
|
@ -152,23 +152,21 @@ RecordARMScatteredHalfRelocation(MachObjectWriter *Writer,
|
|||||||
|
|
||||||
// See <reloc.h>.
|
// See <reloc.h>.
|
||||||
const MCSymbol *A = &Target.getSymA()->getSymbol();
|
const MCSymbol *A = &Target.getSymA()->getSymbol();
|
||||||
const MCSymbol *A_SD = &A->getData();
|
|
||||||
|
|
||||||
if (!A_SD->getFragment())
|
if (!A->getFragment())
|
||||||
Asm.getContext().reportFatalError(Fixup.getLoc(),
|
Asm.getContext().reportFatalError(Fixup.getLoc(),
|
||||||
"symbol '" + A->getName() +
|
"symbol '" + A->getName() +
|
||||||
"' can not be undefined in a subtraction expression");
|
"' can not be undefined in a subtraction expression");
|
||||||
|
|
||||||
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
|
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
|
||||||
uint32_t Value2 = 0;
|
uint32_t Value2 = 0;
|
||||||
uint64_t SecAddr =
|
uint64_t SecAddr = Writer->getSectionAddress(A->getFragment()->getParent());
|
||||||
Writer->getSectionAddress(A_SD->getFragment()->getParent());
|
|
||||||
FixedValue += SecAddr;
|
FixedValue += SecAddr;
|
||||||
|
|
||||||
if (const MCSymbolRefExpr *B = Target.getSymB()) {
|
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(),
|
Asm.getContext().reportFatalError(Fixup.getLoc(),
|
||||||
"symbol '" + B->getSymbol().getName() +
|
"symbol '" + B->getSymbol().getName() +
|
||||||
"' can not be undefined in a subtraction expression");
|
"' can not be undefined in a subtraction expression");
|
||||||
@ -176,7 +174,7 @@ RecordARMScatteredHalfRelocation(MachObjectWriter *Writer,
|
|||||||
// Select the appropriate difference relocation type.
|
// Select the appropriate difference relocation type.
|
||||||
Type = MachO::ARM_RELOC_HALF_SECTDIFF;
|
Type = MachO::ARM_RELOC_HALF_SECTDIFF;
|
||||||
Value2 = Writer->getSymbolAddress(B->getSymbol(), Layout);
|
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.
|
// Relocations are written out in reverse order, so the PAIR comes first.
|
||||||
@ -255,24 +253,22 @@ void ARMMachObjectWriter::RecordARMScatteredRelocation(MachObjectWriter *Writer,
|
|||||||
|
|
||||||
// See <reloc.h>.
|
// See <reloc.h>.
|
||||||
const MCSymbol *A = &Target.getSymA()->getSymbol();
|
const MCSymbol *A = &Target.getSymA()->getSymbol();
|
||||||
const MCSymbol *A_SD = &A->getData();
|
|
||||||
|
|
||||||
if (!A_SD->getFragment())
|
if (!A->getFragment())
|
||||||
Asm.getContext().reportFatalError(Fixup.getLoc(),
|
Asm.getContext().reportFatalError(Fixup.getLoc(),
|
||||||
"symbol '" + A->getName() +
|
"symbol '" + A->getName() +
|
||||||
"' can not be undefined in a subtraction expression");
|
"' can not be undefined in a subtraction expression");
|
||||||
|
|
||||||
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
|
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
|
||||||
uint64_t SecAddr =
|
uint64_t SecAddr = Writer->getSectionAddress(A->getFragment()->getParent());
|
||||||
Writer->getSectionAddress(A_SD->getFragment()->getParent());
|
|
||||||
FixedValue += SecAddr;
|
FixedValue += SecAddr;
|
||||||
uint32_t Value2 = 0;
|
uint32_t Value2 = 0;
|
||||||
|
|
||||||
if (const MCSymbolRefExpr *B = Target.getSymB()) {
|
if (const MCSymbolRefExpr *B = Target.getSymB()) {
|
||||||
assert(Type == MachO::ARM_RELOC_VANILLA && "invalid reloc for 2 symbols");
|
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(),
|
Asm.getContext().reportFatalError(Fixup.getLoc(),
|
||||||
"symbol '" + B->getSymbol().getName() +
|
"symbol '" + B->getSymbol().getName() +
|
||||||
"' can not be undefined in a subtraction expression");
|
"' can not be undefined in a subtraction expression");
|
||||||
@ -280,7 +276,7 @@ void ARMMachObjectWriter::RecordARMScatteredRelocation(MachObjectWriter *Writer,
|
|||||||
// Select the appropriate difference relocation type.
|
// Select the appropriate difference relocation type.
|
||||||
Type = MachO::ARM_RELOC_SECTDIFF;
|
Type = MachO::ARM_RELOC_SECTDIFF;
|
||||||
Value2 = Writer->getSymbolAddress(B->getSymbol(), Layout);
|
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.
|
// Relocations are written out in reverse order, so the PAIR comes first.
|
||||||
|
@ -206,28 +206,26 @@ bool PPCMachObjectWriter::RecordScatteredRelocation(
|
|||||||
|
|
||||||
// See <reloc.h>.
|
// See <reloc.h>.
|
||||||
const MCSymbol *A = &Target.getSymA()->getSymbol();
|
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() +
|
report_fatal_error("symbol '" + A->getName() +
|
||||||
"' can not be undefined in a subtraction expression");
|
"' can not be undefined in a subtraction expression");
|
||||||
|
|
||||||
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
|
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
|
||||||
uint64_t SecAddr =
|
uint64_t SecAddr = Writer->getSectionAddress(A->getFragment()->getParent());
|
||||||
Writer->getSectionAddress(A_SD->getFragment()->getParent());
|
|
||||||
FixedValue += SecAddr;
|
FixedValue += SecAddr;
|
||||||
uint32_t Value2 = 0;
|
uint32_t Value2 = 0;
|
||||||
|
|
||||||
if (const MCSymbolRefExpr *B = Target.getSymB()) {
|
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() +
|
report_fatal_error("symbol '" + B->getSymbol().getName() +
|
||||||
"' can not be undefined in a subtraction expression");
|
"' can not be undefined in a subtraction expression");
|
||||||
|
|
||||||
// FIXME: is Type correct? see include/llvm/Support/MachO.h
|
// FIXME: is Type correct? see include/llvm/Support/MachO.h
|
||||||
Value2 = Writer->getSymbolAddress(B->getSymbol(), Layout);
|
Value2 = Writer->getSymbolAddress(B->getSymbol(), Layout);
|
||||||
FixedValue -= Writer->getSectionAddress(B_SD->getFragment()->getParent());
|
FixedValue -= Writer->getSectionAddress(SB->getFragment()->getParent());
|
||||||
}
|
}
|
||||||
// FIXME: does FixedValue get used??
|
// FIXME: does FixedValue get used??
|
||||||
|
|
||||||
|
@ -142,13 +142,11 @@ void X86MachObjectWriter::RecordX86_64Relocation(
|
|||||||
const MCSymbol *A = &Target.getSymA()->getSymbol();
|
const MCSymbol *A = &Target.getSymA()->getSymbol();
|
||||||
if (A->isTemporary())
|
if (A->isTemporary())
|
||||||
A = &Writer->findAliasedSymbol(*A);
|
A = &Writer->findAliasedSymbol(*A);
|
||||||
const MCSymbol &A_SD = A->getData();
|
|
||||||
const MCSymbol *A_Base = Asm.getAtom(*A);
|
const MCSymbol *A_Base = Asm.getAtom(*A);
|
||||||
|
|
||||||
const MCSymbol *B = &Target.getSymB()->getSymbol();
|
const MCSymbol *B = &Target.getSymB()->getSymbol();
|
||||||
if (B->isTemporary())
|
if (B->isTemporary())
|
||||||
B = &Writer->findAliasedSymbol(*B);
|
B = &Writer->findAliasedSymbol(*B);
|
||||||
const MCSymbol &B_SD = B->getData();
|
|
||||||
const MCSymbol *B_Base = Asm.getAtom(*B);
|
const MCSymbol *B_Base = Asm.getAtom(*B);
|
||||||
|
|
||||||
// Neither symbol can be modified.
|
// Neither symbol can be modified.
|
||||||
@ -190,7 +188,7 @@ void X86MachObjectWriter::RecordX86_64Relocation(
|
|||||||
(!B_Base ? 0 : Writer->getSymbolAddress(*B_Base, Layout));
|
(!B_Base ? 0 : Writer->getSymbolAddress(*B_Base, Layout));
|
||||||
|
|
||||||
if (!A_Base)
|
if (!A_Base)
|
||||||
Index = A_SD.getFragment()->getParent()->getOrdinal() + 1;
|
Index = A->getFragment()->getParent()->getOrdinal() + 1;
|
||||||
Type = MachO::X86_64_RELOC_UNSIGNED;
|
Type = MachO::X86_64_RELOC_UNSIGNED;
|
||||||
|
|
||||||
MachO::any_relocation_info MRE;
|
MachO::any_relocation_info MRE;
|
||||||
@ -202,7 +200,7 @@ void X86MachObjectWriter::RecordX86_64Relocation(
|
|||||||
if (B_Base)
|
if (B_Base)
|
||||||
RelSymbol = B_Base;
|
RelSymbol = B_Base;
|
||||||
else
|
else
|
||||||
Index = B_SD.getFragment()->getParent()->getOrdinal() + 1;
|
Index = B->getFragment()->getParent()->getOrdinal() + 1;
|
||||||
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();
|
||||||
@ -211,7 +209,6 @@ void X86MachObjectWriter::RecordX86_64Relocation(
|
|||||||
if (!Asm.getContext().getAsmInfo()->isSectionAtomizableBySymbols(Sec))
|
if (!Asm.getContext().getAsmInfo()->isSectionAtomizableBySymbols(Sec))
|
||||||
Asm.addLocalUsedInReloc(*Symbol);
|
Asm.addLocalUsedInReloc(*Symbol);
|
||||||
}
|
}
|
||||||
const MCSymbol &SD = Symbol->getData();
|
|
||||||
RelSymbol = Asm.getAtom(*Symbol);
|
RelSymbol = Asm.getAtom(*Symbol);
|
||||||
|
|
||||||
// Relocations inside debug sections always use local relocations when
|
// Relocations inside debug sections always use local relocations when
|
||||||
@ -235,7 +232,7 @@ void X86MachObjectWriter::RecordX86_64Relocation(
|
|||||||
Layout.getSymbolOffset(*RelSymbol);
|
Layout.getSymbolOffset(*RelSymbol);
|
||||||
} else if (Symbol->isInSection() && !Symbol->isVariable()) {
|
} else if (Symbol->isInSection() && !Symbol->isVariable()) {
|
||||||
// The index is the section ordinal (1-based).
|
// 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);
|
Value += Writer->getSymbolAddress(*Symbol, Layout);
|
||||||
|
|
||||||
if (IsPCRel)
|
if (IsPCRel)
|
||||||
@ -354,23 +351,21 @@ bool X86MachObjectWriter::RecordScatteredRelocation(MachObjectWriter *Writer,
|
|||||||
|
|
||||||
// See <reloc.h>.
|
// See <reloc.h>.
|
||||||
const MCSymbol *A = &Target.getSymA()->getSymbol();
|
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() +
|
report_fatal_error("symbol '" + A->getName() +
|
||||||
"' can not be undefined in a subtraction expression",
|
"' can not be undefined in a subtraction expression",
|
||||||
false);
|
false);
|
||||||
|
|
||||||
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
|
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
|
||||||
uint64_t SecAddr =
|
uint64_t SecAddr = Writer->getSectionAddress(A->getFragment()->getParent());
|
||||||
Writer->getSectionAddress(A_SD->getFragment()->getParent());
|
|
||||||
FixedValue += SecAddr;
|
FixedValue += SecAddr;
|
||||||
uint32_t Value2 = 0;
|
uint32_t Value2 = 0;
|
||||||
|
|
||||||
if (const MCSymbolRefExpr *B = Target.getSymB()) {
|
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() +
|
report_fatal_error("symbol '" + B->getSymbol().getName() +
|
||||||
"' can not be undefined in a subtraction expression",
|
"' can not be undefined in a subtraction expression",
|
||||||
false);
|
false);
|
||||||
@ -380,10 +375,10 @@ bool X86MachObjectWriter::RecordScatteredRelocation(MachObjectWriter *Writer,
|
|||||||
// Note that there is no longer any semantic difference between these two
|
// 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
|
// relocation types from the linkers point of view, this is done solely for
|
||||||
// pedantic compatibility with 'as'.
|
// pedantic compatibility with 'as'.
|
||||||
Type = A_SD->isExternal() ? (unsigned)MachO::GENERIC_RELOC_SECTDIFF :
|
Type = A->isExternal() ? (unsigned)MachO::GENERIC_RELOC_SECTDIFF
|
||||||
(unsigned)MachO::GENERIC_RELOC_LOCAL_SECTDIFF;
|
: (unsigned)MachO::GENERIC_RELOC_LOCAL_SECTDIFF;
|
||||||
Value2 = Writer->getSymbolAddress(B->getSymbol(), Layout);
|
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.
|
// Relocations are written out in reverse order, so the PAIR comes first.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user