diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 040657a6b81c..4b71874511f4 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -1277,8 +1277,10 @@ static bool sortMipsSymbols(const std::pair &L, const std::pair &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.first->IsInGlobalMipsGot || !R.first->IsInGlobalMipsGot) - return !L.first->IsInGlobalMipsGot; + bool LIsInLocalGot = !L.first->IsInGlobalMipsGot; + bool RIsInLocalGot = !R.first->IsInGlobalMipsGot; + if (LIsInLocalGot || RIsInLocalGot) + return !RIsInLocalGot; return L.first->GotIndex < R.first->GotIndex; } diff --git a/lld/test/ELF/mips-dynamic.s b/lld/test/ELF/mips-dynamic.s index 797628b7b510..cceaf6d0cbd1 100644 --- a/lld/test/ELF/mips-dynamic.s +++ b/lld/test/ELF/mips-dynamic.s @@ -71,8 +71,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-plt-copy.s b/lld/test/ELF/mips-plt-copy.s index bdbb1d71f315..58883d884563 100644 --- a/lld/test/ELF/mips-plt-copy.s +++ b/lld/test/ELF/mips-plt-copy.s @@ -12,8 +12,8 @@ # CHECK: Relocations [ # CHECK-NEXT: Section ({{.*}}) .rel.dyn { -# CHECK-NEXT: 0x{{[0-9A-F]+}} R_MIPS_COPY data1 0x0 # CHECK-NEXT: 0x{{[0-9A-F]+}} R_MIPS_COPY data0 0x0 +# CHECK-NEXT: 0x{{[0-9A-F]+}} R_MIPS_COPY data1 0x0 # CHECK-NEXT: } # CHECK-NEXT: Section ({{.*}}) .rel.plt { # CHECK-NEXT: 0x{{[0-9A-F]+}} R_MIPS_JUMP_SLOT foo0 0x0 diff --git a/lld/test/ELF/mips-sto-plt.s b/lld/test/ELF/mips-sto-plt.s index 18964e96d05a..bd8de416680a 100644 --- a/lld/test/ELF/mips-sto-plt.s +++ b/lld/test/ELF/mips-sto-plt.s @@ -9,6 +9,15 @@ # REQUIRES: mips +# 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: Symbol { # CHECK: Name: foo1@ # CHECK-NEXT: Value: 0x20050 @@ -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 [