[PATCH] D109079: [lld/mac] Don't assert during thunk insertion if there are undefined symbols
Nico Weber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 3 09:23:04 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc15b5888527b: [lld/mac] Don't assert during thunk insertion if there are undefined symbols (authored by thakis).
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109079/new/
https://reviews.llvm.org/D109079
Files:
lld/MachO/Writer.cpp
lld/test/MachO/invalid/arm64-thunk-undefined.s
Index: lld/test/MachO/invalid/arm64-thunk-undefined.s
===================================================================
--- /dev/null
+++ lld/test/MachO/invalid/arm64-thunk-undefined.s
@@ -0,0 +1,24 @@
+# REQUIRES: aarch64
+
+# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %s -o %t.o
+## This shouldn't assert.
+# RUN: not %lld -arch arm64 -lSystem -o %t/thunk %t.o 2>&1 | FileCheck %s
+
+# CHECK: error: undefined symbol: _g
+
+.subsections_via_symbols
+
+.p2align 2
+
+.globl _main, _g
+
+.globl _main
+_main:
+ bl _g
+ ret
+
+_filler1:
+.space 0x4000000
+
+_filler2:
+.space 0x4000000
Index: lld/MachO/Writer.cpp
===================================================================
--- lld/MachO/Writer.cpp
+++ lld/MachO/Writer.cpp
@@ -1102,10 +1102,16 @@
if (config->entry && !isa<Undefined>(config->entry))
prepareBranchTarget(config->entry);
scanRelocations();
+
+ // Do not proceed if there was an undefined symbol.
+ if (errorCount())
+ return;
+
if (in.stubHelper->isNeeded())
in.stubHelper->setup();
scanSymbols();
createOutputSections<LP>();
+
// After this point, we create no new segments; HOWEVER, we might
// yet create branch-range extension thunks for architectures whose
// hardware call instructions have limited range, e.g., ARM(64).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109079.370604.patch
Type: text/x-patch
Size: 1305 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210903/11561657/attachment.bin>
More information about the llvm-commits
mailing list