Fix the order of section that are not on an order file.
authorRafael Espindola <rafael.espindola@gmail.com>
Fri, 28 Jul 2017 15:36:15 +0000 (15:36 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Fri, 28 Jul 2017 15:36:15 +0000 (15:36 +0000)
They were being placed before sections that were listed.

llvm-svn: 309391

lld/ELF/OutputSections.cpp
lld/test/ELF/symbol-ordering-file2.s [new file with mode: 0644]

index c33f547..581a07c 100644 (file)
@@ -291,7 +291,7 @@ bool OutputSection::classof(const BaseCommand *C) {
 }
 
 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;
diff --git a/lld/test/ELF/symbol-ordering-file2.s b/lld/test/ELF/symbol-ordering-file2.s
new file mode 100644 (file)
index 0000000..723eef1
--- /dev/null
@@ -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",@progbits
+        .align 4
+        .global foo
+foo:
+        retq
+
+        .section .text.bar,"ax",@progbits
+        .align 4
+        .global bar
+bar:
+        retq