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.

llvm-svn: 260633
This commit is contained in:
Rui Ueyama 2016-02-12 00:38:46 +00:00
parent ba6ca87ffb
commit 24b794e8aa
2 changed files with 4 additions and 4 deletions

View File

@ -844,8 +844,8 @@ static bool compCtors(const InputSection<ELFT> *A,
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;
}

View File

@ -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