[lld] r260633 - Make compCtors strict weak ordering.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 11 16:38:46 PST 2016


Author: ruiu
Date: Thu Feb 11 18:38:46 2016
New Revision: 260633

URL: http://llvm.org/viewvc/llvm-project?rev=260633&view=rev
Log:
Make compCtors strict weak ordering.

Previously, if both A and B are ".ctors", both compCtors(A, B) and
compCtors(B, A) are true, which is a violation of the strict weak
ordering because such function is not antisymmetric.

Modified:
    lld/trunk/ELF/OutputSections.cpp
    lld/trunk/test/ELF/ctors_dtors_priority.s

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=260633&r1=260632&r2=260633&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Thu Feb 11 18:38:46 2016
@@ -844,8 +844,8 @@ static bool compCtors(const InputSection
   assert(Y.startswith(".ctors") || Y.startswith(".dtors"));
   X = X.substr(6);
   Y = Y.substr(6);
-  if (X.empty() || Y.empty())
-    return X.empty();
+  if (X.empty() && Y.empty())
+    return false;
   return X < Y;
 }
 

Modified: lld/trunk/test/ELF/ctors_dtors_priority.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/ctors_dtors_priority.s?rev=260633&r1=260632&r2=260633&view=diff
==============================================================================
--- lld/trunk/test/ELF/ctors_dtors_priority.s (original)
+++ lld/trunk/test/ELF/ctors_dtors_priority.s Thu Feb 11 18:38:46 2016
@@ -36,6 +36,6 @@ _start:
   .byte 0x15
 
 // CHECK:      Contents of section .ctors:
-// CHECK-NEXT: a1b10104 050302c1
+// CHECK-NEXT: a1010405 b10302c1
 // CHECK:      Contents of section .dtors:
-// CHECK-NEXT: a2b21114 151312c2
+// CHECK-NEXT: a2111415 b21312c2




More information about the llvm-commits mailing list