diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 4e33f24ef1c1..40989b39bd85 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -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() { diff --git a/lld/test/ELF/mips-dynamic.s b/lld/test/ELF/mips-dynamic.s index e1831221f419..820776be6eeb 100644 --- a/lld/test/ELF/mips-dynamic.s +++ b/lld/test/ELF/mips-dynamic.s @@ -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 diff --git a/lld/test/ELF/mips-mgot.s b/lld/test/ELF/mips-mgot.s index ca9703dbee14..e911d5d0f0eb 100644 --- a/lld/test/ELF/mips-mgot.s +++ b/lld/test/ELF/mips-mgot.s @@ -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: ] diff --git a/lld/test/ELF/mips-sto-plt.s b/lld/test/ELF/mips-sto-plt.s index 56a7c055b6a8..d02d93ada08f 100644 --- a/lld/test/ELF/mips-sto-plt.s +++ b/lld/test/ELF/mips-sto-plt.s @@ -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 [ diff --git a/lld/test/ELF/mips-tls-64.s b/lld/test/ELF/mips-tls-64.s index 7d191f963e4c..32671370fd44 100644 --- a/lld/test/ELF/mips-tls-64.s +++ b/lld/test/ELF/mips-tls-64.s @@ -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 { diff --git a/lld/test/ELF/mips-tls.s b/lld/test/ELF/mips-tls.s index a8bd9235bc65..5008c3757773 100644 --- a/lld/test/ELF/mips-tls.s +++ b/lld/test/ELF/mips-tls.s @@ -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 {