Skip to content

Commit

Permalink
[lld/mac] Don't crash on undefined symbols with --icf=all
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nico committed Oct 27, 2021
1 parent 01870d5 commit 7f36930
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lld/MachO/ICF.cpp
Expand Up @@ -246,7 +246,7 @@ void ICF::run() {
} else {
hash += defined->value;
}
} else
} else if (!isa<Undefined>(sym))
llvm_unreachable("foldIdenticalSections symbol kind");
}
}
Expand Down
2 changes: 1 addition & 1 deletion lld/test/MachO/invalid/undefined-symbol.s
Expand Up @@ -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)'
Expand Down

0 comments on commit 7f36930

Please sign in to comment.