[llvm-commits] [llvm] r98923 - in /llvm/trunk: include/llvm/MC/MCAssembler.h lib/MC/MCAssembler.cpp
Daniel Dunbar
daniel at zuster.org
Thu Mar 18 20:18:09 PDT 2010
Author: ddunbar
Date: Thu Mar 18 22:18:09 2010
New Revision: 98923
URL: http://llvm.org/viewvc/llvm-project?rev=98923&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/MC/MCAssembler.h
llvm/trunk/lib/MC/MCAssembler.cpp
Modified: llvm/trunk/include/llvm/MC/MCAssembler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAssembler.h?rev=98923&r1=98922&r2=98923&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAssembler.h (original)
+++ llvm/trunk/include/llvm/MC/MCAssembler.h Thu Mar 18 22:18:09 2010
@@ -636,6 +636,12 @@
// 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.
///
Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=98923&r1=98922&r2=98923&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Thu Mar 18 22:18:09 2010
@@ -673,11 +673,8 @@
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 @@
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() {
}
+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 {
More information about the llvm-commits
mailing list