diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2010-03-19 03:18:09 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2010-03-19 03:18:09 +0000 |
| commit | c558ec211f971872f462666fa4ef06bb15aad520 (patch) | |
| tree | cabbc611366b8d1ce0e53800594d39b9d0186839 /llvm | |
| parent | fab9b02fc82c46b8c192f3f36c420033704615b1 (diff) | |
| download | bcm5719-llvm-c558ec211f971872f462666fa4ef06bb15aad520.tar.gz bcm5719-llvm-c558ec211f971872f462666fa4ef06bb15aad520.zip | |
MC/Mach-O: Factor out isSymbolLinkerVisible method; "linker visible" is a made up term to refer to non-temporary labels + temporary labels in sections-which-require symbols. For Darwin, it corresponds to symbols which effectively define an atom.
llvm-svn: 98923
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/MC/MCAssembler.h | 6 | ||||
| -rw-r--r-- | llvm/lib/MC/MCAssembler.cpp | 28 |
2 files changed, 24 insertions, 10 deletions
diff --git a/llvm/include/llvm/MC/MCAssembler.h b/llvm/include/llvm/MC/MCAssembler.h index 1d8051fdb06..620b4f4ec21 100644 --- a/llvm/include/llvm/MC/MCAssembler.h +++ b/llvm/include/llvm/MC/MCAssembler.h @@ -636,6 +636,12 @@ private: // FIXME: Make protected once we factor out object writer classes. public: + /// Check whether a particular symbol is visible to the linker and is required + /// in the symbol table, or whether it can be discarded by the assembler. This + /// also effects whether the assembler treats the label as potentially + /// defining a separate atom. + bool isSymbolLinkerVisible(const MCSymbolData *SD) const; + /// Evaluate a fixup to a relocatable expression and the value which should be /// placed into the fixup. /// diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp index 51b12734afe..065c49e7282 100644 --- a/llvm/lib/MC/MCAssembler.cpp +++ b/llvm/lib/MC/MCAssembler.cpp @@ -673,11 +673,8 @@ public: ie = Asm.symbol_end(); it != ie; ++it) { const MCSymbol &Symbol = it->getSymbol(); - // Ignore assembler temporaries. - if (it->getSymbol().isTemporary() && - (!it->getFragment() || - !Asm.getBackend().doesSectionRequireSymbols( - it->getFragment()->getParent()->getSection()))) + // Ignore non-linker visible symbols. + if (!Asm.isSymbolLinkerVisible(it)) continue; if (!it->isExternal() && !Symbol.isUndefined()) @@ -712,11 +709,8 @@ public: ie = Asm.symbol_end(); it != ie; ++it) { const MCSymbol &Symbol = it->getSymbol(); - // Ignore assembler temporaries. - if (it->getSymbol().isTemporary() && - (!it->getFragment() || - !Asm.getBackend().doesSectionRequireSymbols( - it->getFragment()->getParent()->getSection()))) + // Ignore non-linker visible symbols. + if (!Asm.isSymbolLinkerVisible(it)) continue; if (it->isExternal() || Symbol.isUndefined()) @@ -1016,6 +1010,20 @@ MCAssembler::MCAssembler(MCContext &_Context, TargetAsmBackend &_Backend, MCAssembler::~MCAssembler() { } +bool MCAssembler::isSymbolLinkerVisible(const MCSymbolData *SD) const { + // Non-temporary labels should always be visible to the linker. + if (!SD->getSymbol().isTemporary()) + return true; + + // Absolute temporary labels are never visible. + if (!SD->getFragment()) + return false; + + // Otherwise, check if the section requires symbols even for temporary labels. + return getBackend().doesSectionRequireSymbols( + SD->getFragment()->getParent()->getSection()); +} + bool MCAssembler::EvaluateFixup(const MCAsmLayout &Layout, MCAsmFixup &Fixup, MCDataFragment *DF, MCValue &Target, uint64_t &Value) const { |

