[lld] r296319 - Simplify sortMipsSymbols function a bit.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 26 19:31:38 PST 2017


Author: ruiu
Date: Sun Feb 26 21:31:38 2017
New Revision: 296319

URL: http://llvm.org/viewvc/llvm-project?rev=296319&view=rev
Log:
Simplify sortMipsSymbols function a bit.

Modified:
    lld/trunk/ELF/SyntheticSections.cpp

Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=296319&r1=296318&r2=296319&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Sun Feb 26 21:31:38 2017
@@ -1283,14 +1283,14 @@ SymbolTableSection<ELFT>::SymbolTableSec
 // See "Global Offset Table" in Chapter 5 in the following document
 // for detailed description:
 // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
-static bool sortMipsSymbols(const SymbolBody *L, const SymbolBody *R) {
+static bool sortMipsSymbols(const SymbolTableEntry &L, const SymbolTableEntry &R) {
   // Sort entries related to non-local preemptible symbols by GOT indexes.
   // All other entries go to the first part of GOT in arbitrary order.
-  bool LIsInLocalGot = !L->IsInGlobalMipsGot;
-  bool RIsInLocalGot = !R->IsInGlobalMipsGot;
+  bool LIsInLocalGot = !L.Symbol->IsInGlobalMipsGot;
+  bool RIsInLocalGot = !R.Symbol->IsInGlobalMipsGot;
   if (LIsInLocalGot || RIsInLocalGot)
     return !RIsInLocalGot;
-  return L->GotIndex < R->GotIndex;
+  return L.Symbol->GotIndex < R.Symbol->GotIndex;
 }
 
 // Finalize a symbol table. The ELF spec requires that all local
@@ -1314,9 +1314,9 @@ template <class ELFT> void SymbolTableSe
     return;
 
   if (!StrTabSec.isDynamic()) {
-    auto GlobBegin = Symbols.begin() + NumLocals;
+    auto GlobalBegin = Symbols.begin() + NumLocals;
     auto It = std::stable_partition(
-        GlobBegin, Symbols.end(), [](const SymbolTableEntry &S) {
+        GlobalBegin, Symbols.end(), [](const SymbolTableEntry &S) {
           return S.Symbol->symbol()->computeBinding() == STB_LOCAL;
         });
     // update sh_info with number of Global symbols output with computed
@@ -1329,10 +1329,7 @@ template <class ELFT> void SymbolTableSe
     // NB: It also sorts Symbols to meet the GNU hash table requirements.
     In<ELFT>::GnuHashTab->addSymbols(Symbols);
   } else if (Config->EMachine == EM_MIPS) {
-    std::stable_sort(Symbols.begin(), Symbols.end(),
-                     [](const SymbolTableEntry &L, const SymbolTableEntry &R) {
-                       return sortMipsSymbols(L.Symbol, R.Symbol);
-                     });
+    std::stable_sort(Symbols.begin(), Symbols.end(), sortMipsSymbols);
   }
 
   size_t I = 0;




More information about the llvm-commits mailing list