From: Rafael Espindola Date: Fri, 29 May 2015 15:07:27 +0000 (+0000) Subject: Simplify now that symbols contain the correct section. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=616c7afb7008b365463e0495ba8c1ec925f10ce4;p=oota-llvm.git Simplify now that symbols contain the correct section. The complexity in here was because before r233995 variable symbols would report the incorrect section. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238559 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index 827a1e3b6d7..27b8b9be9fd 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -823,24 +823,19 @@ void ELFObjectWriter::computeSymbolTable( ELFSymbolData MSD; MSD.Symbol = &Symbol; - const MCSymbol *BaseSymbol = Layout.getBaseSymbol(Symbol); // Undefined symbols are global, but this is the first place we // are able to set it. bool Local = isLocal(Symbol, Used, isSignature); - if (!Local && MCELF::GetBinding(SD) == ELF::STB_LOCAL) { - assert(BaseSymbol); - MCSymbolData &BaseData = BaseSymbol->getData(); + if (!Local && MCELF::GetBinding(SD) == ELF::STB_LOCAL) MCELF::SetBinding(SD, ELF::STB_GLOBAL); - MCELF::SetBinding(BaseData, ELF::STB_GLOBAL); - } - if (!BaseSymbol) { + if (Symbol.isAbsolute()) { MSD.SectionIndex = ELF::SHN_ABS; } else if (SD.isCommon()) { assert(!Local); MSD.SectionIndex = ELF::SHN_COMMON; - } else if (BaseSymbol->isUndefined()) { + } else if (Symbol.isUndefined()) { if (isSignature && !Used) { MSD.SectionIndex = RevGroupMap.lookup(&Symbol); if (MSD.SectionIndex >= ELF::SHN_LORESERVE) @@ -852,7 +847,7 @@ void ELFObjectWriter::computeSymbolTable( MCELF::SetBinding(SD, ELF::STB_WEAK); } else { const MCSectionELF &Section = - static_cast(BaseSymbol->getSection()); + static_cast(Symbol.getSection()); MSD.SectionIndex = SectionIndexMap.lookup(&Section); assert(MSD.SectionIndex && "Invalid section index!"); if (MSD.SectionIndex >= ELF::SHN_LORESERVE)