[ELF][MIPS] Fix stable_sort predicate to satisfy strict-ordering requirement. NFC

Fix for PR37785.

llvm-svn: 334851
This commit is contained in:
Simon Atanasyan 2018-06-15 18:15:26 +00:00
parent f1792bb3d6
commit 9655fe6322
6 changed files with 24 additions and 22 deletions

View File

@ -1703,10 +1703,12 @@ SymbolTableBaseSection::SymbolTableBaseSection(StringTableSection &StrTabSec)
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.
if (!L.Sym->isInGot() || !R.Sym->isInGot())
return !L.Sym->isInGot();
return L.Sym->GotIndex < R.Sym->GotIndex;
// All other entries go to the beginning of a dynsym in arbitrary order.
if (L.Sym->isInGot() && R.Sym->isInGot())
return L.Sym->GotIndex < R.Sym->GotIndex;
if (!L.Sym->isInGot() && !R.Sym->isInGot())
return false;
return !L.Sym->isInGot();
}
void SymbolTableBaseSection::finalizeContents() {

View File

@ -99,8 +99,8 @@
# DSO: ]
# DSO: DynamicSymbols [
# DSO: Name: @
# DSO: Name: _foo@
# DSO: Name: __start@
# DSO: Name: _foo@
# DSO: ]
# DSO: DynamicSection [
# DSO-NEXT: Tag Type Name/Value

View File

@ -47,13 +47,13 @@
# GOT-NEXT: 0x6005C R_MIPS_REL32 foo0 0x0
# GOT-NEXT: 0x60060 R_MIPS_REL32 foo2 0x0
# GOT-NEXT: 0x6003C R_MIPS_TLS_DTPMOD32 - 0x0
# GOT-NEXT: 0x60030 R_MIPS_TLS_TPREL32 tls1 0x0
# GOT-NEXT: 0x6002C R_MIPS_TLS_TPREL32 tls0 0x0
# GOT-NEXT: 0x60034 R_MIPS_TLS_DTPMOD32 tls0 0x0
# GOT-NEXT: 0x60038 R_MIPS_TLS_DTPREL32 tls0 0x0
# GOT-NEXT: 0x60064 R_MIPS_TLS_TPREL32 tls0 0x0
# GOT-NEXT: 0x60068 R_MIPS_TLS_DTPMOD32 tls0 0x0
# GOT-NEXT: 0x6006C R_MIPS_TLS_DTPREL32 tls0 0x0
# GOT-NEXT: 0x60030 R_MIPS_TLS_TPREL32 tls1 0x0
# GOT-NEXT: }
# GOT-NEXT: ]

View File

@ -10,7 +10,16 @@
# REQUIRES: mips
# CHECK: Symbol {
# CHECK: Name: foo1@
# CHECK: Name: foo0@
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Global
# CHECK-NEXT: Type: Function
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: Undefined
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: foo1@
# CHECK-NEXT: Value: 0x[[FOO1:[0-9A-F]+]]
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Global
@ -20,15 +29,6 @@
# CHECK-NEXT: ]
# CHECK-NEXT: Section: Undefined
# CHECK-NEXT: }
# CHECK: Symbol {
# CHECK: Name: foo0@
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Global
# CHECK-NEXT: Type: Function
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: Undefined
# CHECK-NEXT: }
# CHECK: Primary GOT {
# CHECK: Local entries [

View File

@ -68,12 +68,12 @@
# SO: Relocations [
# SO-NEXT: Section (7) .rel.dyn {
# SO-NEXT: 0x20030 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE - 0x0
# SO-NEXT: 0x20010 R_MIPS_TLS_TPREL64/R_MIPS_NONE/R_MIPS_NONE foo 0x0
# SO-NEXT: 0x20020 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE foo 0x0
# SO-NEXT: 0x20028 R_MIPS_TLS_DTPREL64/R_MIPS_NONE/R_MIPS_NONE foo 0x0
# SO-NEXT: 0x20018 R_MIPS_TLS_TPREL64/R_MIPS_NONE/R_MIPS_NONE bar 0x0
# SO-NEXT: 0x20040 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE bar 0x0
# SO-NEXT: 0x20048 R_MIPS_TLS_DTPREL64/R_MIPS_NONE/R_MIPS_NONE bar 0x0
# SO-NEXT: 0x20010 R_MIPS_TLS_TPREL64/R_MIPS_NONE/R_MIPS_NONE foo 0x0
# SO-NEXT: 0x20020 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE foo 0x0
# SO-NEXT: 0x20028 R_MIPS_TLS_DTPREL64/R_MIPS_NONE/R_MIPS_NONE foo 0x0
# SO-NEXT: }
# SO-NEXT: ]
# SO-NEXT: Primary GOT {

View File

@ -64,12 +64,12 @@
# SO: Relocations [
# SO-NEXT: Section (7) .rel.dyn {
# SO-NEXT: 0x20018 R_MIPS_TLS_DTPMOD32 - 0x0
# SO-NEXT: 0x20008 R_MIPS_TLS_TPREL32 foo 0x0
# SO-NEXT: 0x20010 R_MIPS_TLS_DTPMOD32 foo 0x0
# SO-NEXT: 0x20014 R_MIPS_TLS_DTPREL32 foo 0x0
# SO-NEXT: 0x2000C R_MIPS_TLS_TPREL32 bar 0x0
# SO-NEXT: 0x20020 R_MIPS_TLS_DTPMOD32 bar 0x0
# SO-NEXT: 0x20024 R_MIPS_TLS_DTPREL32 bar 0x0
# SO-NEXT: 0x20008 R_MIPS_TLS_TPREL32 foo 0x0
# SO-NEXT: 0x20010 R_MIPS_TLS_DTPMOD32 foo 0x0
# SO-NEXT: 0x20014 R_MIPS_TLS_DTPREL32 foo 0x0
# SO-NEXT: }
# SO-NEXT: ]
# SO-NEXT: Primary GOT {