[llvm-commits] [llvm] r119022 - /llvm/trunk/lib/MC/ELFObjectWriter.cpp

Rafael Espindola rafael.espindola at gmail.com
Sat Nov 13 19:12:25 PST 2010


Author: rafael
Date: Sat Nov 13 21:12:24 2010
New Revision: 119022

URL: http://llvm.org/viewvc/llvm-project?rev=119022&view=rev
Log:
Simplify getSymbolIndexInSymbolTable by setting the actual index of
the symbols.

Modified:
    llvm/trunk/lib/MC/ELFObjectWriter.cpp

Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=119022&r1=119021&r2=119022&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Sat Nov 13 21:12:24 2010
@@ -159,8 +159,6 @@
 
     /// @}
 
-    int NumRegularSections;
-
     bool NeedsGOT;
 
     bool NeedsSymtabShndx;
@@ -874,13 +872,7 @@
 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 @@
   }
 
   // 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 @@
 
   // 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)





More information about the llvm-commits mailing list