[lld] 7f36930 - [lld/mac] Don't crash on undefined symbols with --icf=all
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 27 13:25:56 PDT 2021
Author: Nico Weber
Date: 2021-10-27T16:20:10-04:00
New Revision: 7f369304dfe9e3a62db0244b3427319d33bec4df
URL: https://github.com/llvm/llvm-project/commit/7f369304dfe9e3a62db0244b3427319d33bec4df
DIFF: https://github.com/llvm/llvm-project/commit/7f369304dfe9e3a62db0244b3427319d33bec4df.diff
LOG: [lld/mac] Don't crash on undefined symbols with --icf=all
ICF runs before relocation processing, but undefined symbol errors
are only emitted during relocation processing.
So just ignore Undefineds during ICF (instead of crashing) -- lld
will emit an error once ICF is done.
Fixes PR52330.
Differential Revision: https://reviews.llvm.org/D112643
Added:
Modified:
lld/MachO/ICF.cpp
lld/test/MachO/invalid/undefined-symbol.s
Removed:
################################################################################
diff --git a/lld/MachO/ICF.cpp b/lld/MachO/ICF.cpp
index 2fb3c9440b281..e583741e30855 100644
--- a/lld/MachO/ICF.cpp
+++ b/lld/MachO/ICF.cpp
@@ -246,7 +246,7 @@ void ICF::run() {
} else {
hash += defined->value;
}
- } else
+ } else if (!isa<Undefined>(sym))
llvm_unreachable("foldIdenticalSections symbol kind");
}
}
diff --git a/lld/test/MachO/invalid/undefined-symbol.s b/lld/test/MachO/invalid/undefined-symbol.s
index b2f5eee700fdd..deb543a31462f 100644
--- a/lld/test/MachO/invalid/undefined-symbol.s
+++ b/lld/test/MachO/invalid/undefined-symbol.s
@@ -3,7 +3,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/main.s -o %t/main.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo.s -o %t/foo.o
# RUN: llvm-ar crs %t/foo.a %t/foo.o
-# RUN: not %lld -o /dev/null %t/main.o 2>&1 | \
+# RUN: not %lld --icf=all -o /dev/null %t/main.o 2>&1 | \
# RUN: FileCheck %s -DSYM=_foo -DFILENAME=%t/main.o
# RUN: not %lld -o /dev/null %t/main.o %t/foo.a 2>&1 | \
# RUN: FileCheck %s -DSYM=_bar -DFILENAME='%t/foo.a(foo.o)'
More information about the llvm-commits
mailing list