diff options
Diffstat (limited to 'lib/MC/MCAssembler.cpp')
-rw-r--r-- | lib/MC/MCAssembler.cpp | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp index 85d0c13..50ce845 100644 --- a/lib/MC/MCAssembler.cpp +++ b/lib/MC/MCAssembler.cpp @@ -12,6 +12,7 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/Twine.h" #include "llvm/MC/MCAsmBackend.h" +#include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCAsmLayout.h" #include "llvm/MC/MCCodeEmitter.h" #include "llvm/MC/MCContext.h" @@ -20,6 +21,7 @@ #include "llvm/MC/MCFixupKindInfo.h" #include "llvm/MC/MCObjectWriter.h" #include "llvm/MC/MCSection.h" +#include "llvm/MC/MCSectionELF.h" #include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCValue.h" #include "llvm/Support/Debug.h" @@ -27,7 +29,6 @@ #include "llvm/Support/LEB128.h" #include "llvm/Support/TargetRegistry.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/MC/MCSectionELF.h" #include <tuple> using namespace llvm; @@ -200,7 +201,17 @@ const MCSymbol *MCAsmLayout::getBaseSymbol(const MCSymbol &Symbol) const { if (!A) return nullptr; - return &A->getSymbol(); + const MCSymbol &ASym = A->getSymbol(); + const MCAssembler &Asm = getAssembler(); + const MCSymbolData &ASD = Asm.getSymbolData(ASym); + if (ASD.isCommon()) { + // FIXME: we should probably add a SMLoc to MCExpr. + Asm.getContext().FatalError(SMLoc(), + "Common symbol " + ASym.getName() + + " cannot be used in assignment expr"); + } + + return &ASym; } uint64_t MCAsmLayout::getSectionAddressSize(const MCSectionData *SD) const { @@ -424,6 +435,16 @@ bool MCAssembler::isThumbFunc(const MCSymbol *Symbol) const { return true; } +void MCAssembler::addLocalUsedInReloc(const MCSymbol &Sym) { + assert(Sym.isTemporary()); + LocalsUsedInReloc.insert(&Sym); +} + +bool MCAssembler::isLocalUsedInReloc(const MCSymbol &Sym) const { + assert(Sym.isTemporary()); + return LocalsUsedInReloc.count(&Sym); +} + bool MCAssembler::isSymbolLinkerVisible(const MCSymbol &Symbol) const { // Non-temporary labels should always be visible to the linker. if (!Symbol.isTemporary()) @@ -433,8 +454,10 @@ bool MCAssembler::isSymbolLinkerVisible(const MCSymbol &Symbol) const { if (!Symbol.isInSection()) return false; - // Otherwise, check if the section requires symbols even for temporary labels. - return getBackend().doesSectionRequireSymbols(Symbol.getSection()); + if (isLocalUsedInReloc(Symbol)) + return true; + + return false; } const MCSymbolData *MCAssembler::getAtom(const MCSymbolData *SD) const { @@ -448,8 +471,8 @@ const MCSymbolData *MCAssembler::getAtom(const MCSymbolData *SD) const { // Non-linker visible symbols in sections which can't be atomized have no // defining atom. - if (!getBackend().isSectionAtomizable( - SD->getFragment()->getParent()->getSection())) + if (!getContext().getAsmInfo()->isSectionAtomizableBySymbols( + SD->getFragment()->getParent()->getSection())) return nullptr; // Otherwise, return the atom for the containing fragment. |