aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-11-14 03:12:24 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-11-14 03:12:24 +0000
commitab4a7afe98fcd86418bd1672f880b7d3672f4543 (patch)
tree11e85415de720a04d6d8e8fa18e9d36cdf5347c1 /lib
parent7e528a1724d8f38dd817396938aaf768887c8b30 (diff)
downloadexternal_llvm-ab4a7afe98fcd86418bd1672f880b7d3672f4543.zip
external_llvm-ab4a7afe98fcd86418bd1672f880b7d3672f4543.tar.gz
external_llvm-ab4a7afe98fcd86418bd1672f880b7d3672f4543.tar.bz2
Simplify getSymbolIndexInSymbolTable by setting the actual index of
the symbols. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119022 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/MC/ELFObjectWriter.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp
index e019e18..085b301 100644
--- a/lib/MC/ELFObjectWriter.cpp
+++ b/lib/MC/ELFObjectWriter.cpp
@@ -159,8 +159,6 @@ namespace {
/// @}
- int NumRegularSections;
-
bool NeedsGOT;
bool NeedsSymtabShndx;
@@ -874,13 +872,7 @@ uint64_t
ELFObjectWriter::getSymbolIndexInSymbolTable(const MCAssembler &Asm,
const MCSymbol *S) {
MCSymbolData &SD = Asm.getSymbolData(*S);
-
- // Local symbol.
- if (!SD.isExternal() && !S->isUndefined())
- return SD.getIndex() + /* empty symbol */ 1;
-
- // External or undefined symbol.
- return SD.getIndex() + NumRegularSections + /* empty symbol */ 1;
+ return SD.getIndex();
}
static bool isInSymtab(const MCAssembler &Asm, const MCSymbolData &Data,
@@ -957,7 +949,7 @@ void ELFObjectWriter::ComputeSymbolTable(MCAssembler &Asm,
}
// Build section lookup table.
- NumRegularSections = Asm.size();
+ int NumRegularSections = Asm.size();
// Index 0 is always the empty string.
StringMap<uint64_t> StringIndexMap;
@@ -1033,9 +1025,12 @@ void ELFObjectWriter::ComputeSymbolTable(MCAssembler &Asm,
// Set the symbol indices. Local symbols must come before all other
// symbols with non-local bindings.
- unsigned Index = 0;
+ unsigned Index = 1;
for (unsigned i = 0, e = LocalSymbolData.size(); i != e; ++i)
LocalSymbolData[i].SymbolData->setIndex(Index++);
+
+ Index += NumRegularSections;
+
for (unsigned i = 0, e = ExternalSymbolData.size(); i != e; ++i)
ExternalSymbolData[i].SymbolData->setIndex(Index++);
for (unsigned i = 0, e = UndefinedSymbolData.size(); i != e; ++i)