summaryrefslogtreecommitdiff
path: root/lib/MC/ELFObjectWriter.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-04-28 13:39:57 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-04-28 13:39:57 +0000
commit0af058ff9ce0a8953f0b3bd8a873436ca18a3847 (patch)
tree9c5f28c56273f8bd9b782cfa4f286f49dac3d7a6 /lib/MC/ELFObjectWriter.cpp
parent086e9aaa551916c744cdb1d7f5a637efa69dc650 (diff)
downloadllvm-0af058ff9ce0a8953f0b3bd8a873436ca18a3847.tar.gz
llvm-0af058ff9ce0a8953f0b3bd8a873436ca18a3847.tar.bz2
llvm-0af058ff9ce0a8953f0b3bd8a873436ca18a3847.tar.xz
Don't include an invalid symbol in the symbol table.
The symbol table itself has no relocations, so it is not possible to represent things like a = undefined + 1 With the patch we just omit these variables. That matches the behaviour of the gnu assembler. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207419 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/ELFObjectWriter.cpp')
-rw-r--r--lib/MC/ELFObjectWriter.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp
index 12b5f595ca..ba4ffa4ca9 100644
--- a/lib/MC/ELFObjectWriter.cpp
+++ b/lib/MC/ELFObjectWriter.cpp
@@ -107,7 +107,7 @@ class ELFObjectWriter : public MCObjectWriter {
static bool isFixupKindPCRel(const MCAssembler &Asm, unsigned Kind);
static bool RelocNeedsGOT(MCSymbolRefExpr::VariantKind Variant);
static uint64_t SymbolValue(MCSymbolData &Data, const MCAsmLayout &Layout);
- static bool isInSymtab(const MCAssembler &Asm, const MCSymbolData &Data,
+ static bool isInSymtab(const MCAsmLayout &Layout, const MCSymbolData &Data,
bool Used, bool Renamed);
static bool isLocal(const MCSymbolData &Data, bool isSignature,
bool isUsedInReloc);
@@ -934,9 +934,9 @@ ELFObjectWriter::getSymbolIndexInSymbolTable(const MCAssembler &Asm,
return SD.getIndex();
}
-bool ELFObjectWriter::isInSymtab(const MCAssembler &Asm,
- const MCSymbolData &Data,
- bool Used, bool Renamed) {
+bool ELFObjectWriter::isInSymtab(const MCAsmLayout &Layout,
+ const MCSymbolData &Data, bool Used,
+ bool Renamed) {
const MCSymbol &Symbol = Data.getSymbol();
if (Symbol.isVariable()) {
const MCExpr *Expr = Symbol.getVariableValue();
@@ -955,9 +955,11 @@ bool ELFObjectWriter::isInSymtab(const MCAssembler &Asm,
if (Symbol.getName() == "_GLOBAL_OFFSET_TABLE_")
return true;
- const MCSymbol &A = Symbol.AliasedSymbol();
- if (Symbol.isVariable() && !A.isVariable() && A.isUndefined())
- return false;
+ if (Symbol.isVariable()) {
+ const MCSymbol *Base = getBaseSymbol(Layout, Symbol);
+ if (Base && Base->isUndefined())
+ return false;
+ }
bool IsGlobal = MCELF::GetBinding(Data) == ELF::STB_GLOBAL;
if (!Symbol.isVariable() && Symbol.isUndefined() && !IsGlobal)
@@ -1059,7 +1061,7 @@ ELFObjectWriter::computeSymbolTable(MCAssembler &Asm, const MCAsmLayout &Layout,
bool WeakrefUsed = WeakrefUsedInReloc.count(&Symbol);
bool isSignature = RevGroupMap.count(&Symbol);
- if (!isInSymtab(Asm, SD,
+ if (!isInSymtab(Layout, SD,
Used || WeakrefUsed || isSignature,
Renames.count(&Symbol)))
continue;