Skip to content

Commit 7f36930

Browse files
committed
[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
1 parent 01870d5 commit 7f36930

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lld/MachO/ICF.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ void ICF::run() {
246246
} else {
247247
hash += defined->value;
248248
}
249-
} else
249+
} else if (!isa<Undefined>(sym))
250250
llvm_unreachable("foldIdenticalSections symbol kind");
251251
}
252252
}

lld/test/MachO/invalid/undefined-symbol.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/main.s -o %t/main.o
44
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo.s -o %t/foo.o
55
# RUN: llvm-ar crs %t/foo.a %t/foo.o
6-
# RUN: not %lld -o /dev/null %t/main.o 2>&1 | \
6+
# RUN: not %lld --icf=all -o /dev/null %t/main.o 2>&1 | \
77
# RUN: FileCheck %s -DSYM=_foo -DFILENAME=%t/main.o
88
# RUN: not %lld -o /dev/null %t/main.o %t/foo.a 2>&1 | \
99
# RUN: FileCheck %s -DSYM=_bar -DFILENAME='%t/foo.a(foo.o)'

0 commit comments

Comments
 (0)