[lld] r309391 - Fix the order of section that are not on an order file.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 28 08:36:15 PDT 2017


Author: rafael
Date: Fri Jul 28 08:36:15 2017
New Revision: 309391

URL: http://llvm.org/viewvc/llvm-project?rev=309391&view=rev
Log:
Fix the order of section that are not on an order file.

They were being placed before sections that were listed.

Added:
    lld/trunk/test/ELF/symbol-ordering-file2.s
Modified:
    lld/trunk/ELF/OutputSections.cpp

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=309391&r1=309390&r2=309391&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Fri Jul 28 08:36:15 2017
@@ -291,7 +291,7 @@ bool OutputSection::classof(const BaseCo
 }
 
 void OutputSection::sort(std::function<int(InputSectionBase *S)> Order) {
-  typedef std::pair<unsigned, InputSection *> Pair;
+  typedef std::pair<int, InputSection *> Pair;
   auto Comp = [](const Pair &A, const Pair &B) { return A.first < B.first; };
 
   std::vector<Pair> V;

Added: lld/trunk/test/ELF/symbol-ordering-file2.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/symbol-ordering-file2.s?rev=309391&view=auto
==============================================================================
--- lld/trunk/test/ELF/symbol-ordering-file2.s (added)
+++ lld/trunk/test/ELF/symbol-ordering-file2.s Fri Jul 28 08:36:15 2017
@@ -0,0 +1,21 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: echo "bar" > %t.order
+# RUN: ld.lld --symbol-ordering-file %t.order -shared %t.o -o %t.so
+# RUN: llvm-nm %t.so | FileCheck %s
+
+# CHECK:      0000000000002000 d _DYNAMIC
+# CHECK-NEXT: 0000000000001000 T bar
+# CHECK-NEXT: 0000000000001004 T foo
+
+        .section .text.foo,"ax", at progbits
+        .align 4
+        .global foo
+foo:
+        retq
+
+        .section .text.bar,"ax", at progbits
+        .align 4
+        .global bar
+bar:
+        retq




More information about the llvm-commits mailing list