[PATCH] D28950: [LLD][ELF] Correct sh_info for static symbol table

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 24 02:54:57 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL292910: [ELF] Correct sh_info for static symbol table (authored by psmith).

Changed prior to commit:
  https://reviews.llvm.org/D28950?vs=85402&id=85554#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28950

Files:
  lld/trunk/ELF/SyntheticSections.cpp
  lld/trunk/test/ELF/basic-mips.s
  lld/trunk/test/ELF/basic-ppc.s


Index: lld/trunk/test/ELF/basic-mips.s
===================================================================
--- lld/trunk/test/ELF/basic-mips.s
+++ lld/trunk/test/ELF/basic-mips.s
@@ -176,7 +176,7 @@
 # CHECK-NEXT:     Offset: 0x20010
 # CHECK-NEXT:     Size: 48
 # CHECK-NEXT:     Link: 10
-# CHECK-NEXT:     Info: 1
+# CHECK-NEXT:     Info: 2
 # CHECK-NEXT:     AddressAlignment: 4
 # CHECK-NEXT:     EntrySize: 16
 # CHECK-NEXT:   }
Index: lld/trunk/test/ELF/basic-ppc.s
===================================================================
--- lld/trunk/test/ELF/basic-ppc.s
+++ lld/trunk/test/ELF/basic-ppc.s
@@ -178,7 +178,7 @@
 // CHECK-NEXT:     Offset: 0x2038
 // CHECK-NEXT:     Size: 32
 // CHECK-NEXT:     Link: 9
-// CHECK-NEXT:     Info: 1
+// CHECK-NEXT:     Info: 2
 // CHECK-NEXT:     AddressAlignment: 4
 // CHECK-NEXT:     EntrySize: 16
 // CHECK-NEXT:     SectionData (
Index: lld/trunk/ELF/SyntheticSections.cpp
===================================================================
--- lld/trunk/ELF/SyntheticSections.cpp
+++ lld/trunk/ELF/SyntheticSections.cpp
@@ -1073,11 +1073,13 @@
 
   if (!StrTabSec.isDynamic()) {
     auto GlobBegin = Symbols.begin() + NumLocals;
-    std::stable_sort(GlobBegin, Symbols.end(), [](const SymbolTableEntry &L,
-                                                  const SymbolTableEntry &R) {
-      return L.Symbol->symbol()->computeBinding() == STB_LOCAL &&
-             R.Symbol->symbol()->computeBinding() != STB_LOCAL;
-    });
+    auto It = std::stable_partition(
+        GlobBegin, Symbols.end(), [](const SymbolTableEntry &S) {
+          return S.Symbol->symbol()->computeBinding() == STB_LOCAL;
+        });
+    // update sh_info with number of Global symbols output with computed
+    // binding of STB_LOCAL
+    this->OutSec->Info = this->Info = 1 + It - Symbols.begin();
     return;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28950.85554.patch
Type: text/x-patch
Size: 1862 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170124/6520d02b/attachment.bin>


More information about the llvm-commits mailing list