[PATCH] D112643: [lld/mac] Don't crash on undefined symbols with --icf=all
Nico Weber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 27 11:41:46 PDT 2021
thakis created this revision.
thakis added a reviewer: lld-macho.
Herald added a reviewer: gkm.
Herald added a project: lld-macho.
thakis requested review of this revision.
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.
https://reviews.llvm.org/D112643
Files:
lld/MachO/ICF.cpp
lld/test/MachO/invalid/undefined-symbol.s
Index: lld/test/MachO/invalid/undefined-symbol.s
===================================================================
--- lld/test/MachO/invalid/undefined-symbol.s
+++ 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)'
Index: lld/MachO/ICF.cpp
===================================================================
--- lld/MachO/ICF.cpp
+++ lld/MachO/ICF.cpp
@@ -246,7 +246,7 @@
} else {
hash += defined->value;
}
- } else
+ } else if (!isa<Undefined>(sym))
llvm_unreachable("foldIdenticalSections symbol kind");
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112643.382735.patch
Type: text/x-patch
Size: 1094 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211027/5bd64f28/attachment.bin>
More information about the llvm-commits
mailing list