summaryrefslogtreecommitdiff
path: root/lld/MachO/SymbolTable.cpp
diff options
context:
space:
mode:
authorVy Nguyen <vyng@google.com>2021-11-02 16:28:31 -0400
committerVy Nguyen <vyng@google.com>2021-11-09 10:08:17 -0500
commitb2d92584742e333799ed6a3687c801dde9bb6174 (patch)
tree54d1c5470b0f837c5e19a82b360e49027d7ca621 /lld/MachO/SymbolTable.cpp
parent846ec2c3ccbc8e6fb5cbbaa207b93941af16f434 (diff)
[lld-macho] Fix assertion failure in registerCompactUnwind
PR/52372 Differential Revision: https://reviews.llvm.org/D112977
Diffstat (limited to 'lld/MachO/SymbolTable.cpp')
-rw-r--r--lld/MachO/SymbolTable.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/lld/MachO/SymbolTable.cpp b/lld/MachO/SymbolTable.cpp
index 37c3fe0d38c7..df7237468ae3 100644
--- a/lld/MachO/SymbolTable.cpp
+++ b/lld/MachO/SymbolTable.cpp
@@ -62,28 +62,32 @@ Defined *SymbolTable::addDefined(StringRef name, InputFile *file,
if (!wasInserted) {
if (auto *defined = dyn_cast<Defined>(s)) {
if (isWeakDef) {
+
+ // See further comment in createDefined() in InputFiles.cpp
if (defined->isWeakDef()) {
- // Both old and new symbol weak (e.g. inline function in two TUs):
- // If one of them isn't private extern, the merged symbol isn't.
defined->privateExtern &= isPrivateExtern;
defined->referencedDynamically |= isReferencedDynamically;
defined->noDeadStrip |= noDeadStrip;
-
- // FIXME: Handle this for bitcode files.
- // FIXME: We currently only do this if both symbols are weak.
- // We could do this if either is weak (but getting the
- // case where !isWeakDef && defined->isWeakDef() right
- // requires some care and testing).
- if (auto concatIsec = dyn_cast_or_null<ConcatInputSection>(isec))
- concatIsec->wasCoalesced = true;
}
-
+ // FIXME: Handle this for bitcode files.
+ if (auto concatIsec = dyn_cast_or_null<ConcatInputSection>(isec))
+ concatIsec->wasCoalesced = true;
return defined;
}
- if (!defined->isWeakDef())
+
+ if (defined->isWeakDef()) {
+ // FIXME: Handle this for bitcode files.
+ if (auto concatIsec =
+ dyn_cast_or_null<ConcatInputSection>(defined->isec)) {
+ concatIsec->wasCoalesced = true;
+ concatIsec->symbols.erase(llvm::find(concatIsec->symbols, defined));
+ }
+ } else {
error("duplicate symbol: " + name + "\n>>> defined in " +
toString(defined->getFile()) + "\n>>> defined in " +
toString(file));
+ }
+
} else if (auto *dysym = dyn_cast<DylibSymbol>(s)) {
overridesWeakDef = !isWeakDef && dysym->isWeakDef();
dysym->unreference();