Add support for weak absolute symbols.
On ELF being weak is independent of what we call the kind of the symbol. So
this also makes the code simpler.
llvm-svn: 246326
diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index 359632f..33f9a7e 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -20,27 +20,17 @@
// Returns 1, 0 or -1 if this symbol should take precedence
// over the Other, tie or lose, respectively.
int SymbolBody::compare(SymbolBody *Other) {
- Kind LK = kind();
- Kind RK = Other->kind();
+ std::pair<bool, bool> L(isDefined(), isWeak());
+ std::pair<bool, bool> R(Other->isDefined(), Other->isWeak());
- // Normalize so that the smaller kind is on the left.
- if (LK > RK)
+ // Normalize
+ if (L > R)
return -Other->compare(this);
- // First handle comparisons between two different kinds.
- if (LK != RK)
- return 1;
+ if (L != R)
+ return -1;
- // Now handle the case where the kinds are the same.
- switch (LK) {
- case DefinedAbsoluteKind:
- case DefinedRegularKind:
+ if (L.first && !L.second)
return 0;
- case DefinedWeakKind:
- case UndefinedKind:
- case UndefinedWeakKind:
- case UndefinedSyntheticKind:
- return 1;
- }
- llvm_unreachable("unknown symbol kind");
+ return 1;
}