[lld] r293513 - Port r292910.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 30 10:03:22 PST 2017
Author: rafael
Date: Mon Jan 30 12:03:21 2017
New Revision: 293513
URL: http://llvm.org/viewvc/llvm-project?rev=293513&view=rev
Log:
Port r292910.
[ELF] Correct sh_info for static symbol table
The sh_info field of the SHT_SYMTAB section holds the index for the
first non-local symbol. When there are global symbols that are output
with STB_LOCAL binding due to having hidden visibility or matching
the local version from a version script, the calculated value of
NumLocals + 1 does not account for them. This change accounts for
global symbols being output with local binding.
Differential Revision: https://reviews.llvm.org/D28950
Modified:
lld/branches/release_40/ELF/SyntheticSections.cpp
lld/branches/release_40/test/ELF/basic-mips.s
lld/branches/release_40/test/ELF/basic-ppc.s
Modified: lld/branches/release_40/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_40/ELF/SyntheticSections.cpp?rev=293513&r1=293512&r2=293513&view=diff
==============================================================================
--- lld/branches/release_40/ELF/SyntheticSections.cpp (original)
+++ lld/branches/release_40/ELF/SyntheticSections.cpp Mon Jan 30 12:03:21 2017
@@ -1070,11 +1070,13 @@ template <class ELFT> void SymbolTableSe
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;
}
Modified: lld/branches/release_40/test/ELF/basic-mips.s
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_40/test/ELF/basic-mips.s?rev=293513&r1=293512&r2=293513&view=diff
==============================================================================
--- lld/branches/release_40/test/ELF/basic-mips.s (original)
+++ lld/branches/release_40/test/ELF/basic-mips.s Mon Jan 30 12:03:21 2017
@@ -176,7 +176,7 @@ __start:
# 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: }
Modified: lld/branches/release_40/test/ELF/basic-ppc.s
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_40/test/ELF/basic-ppc.s?rev=293513&r1=293512&r2=293513&view=diff
==============================================================================
--- lld/branches/release_40/test/ELF/basic-ppc.s (original)
+++ lld/branches/release_40/test/ELF/basic-ppc.s Mon Jan 30 12:03:21 2017
@@ -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 (
More information about the llvm-commits
mailing list