[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
Wed Sep 1 11:31:56 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.

We end up calling resolveBranchVA(), which asserts for Undefineds.

As fix, just return early in Writer::run() if there are any diagnostics
after processing relocations (which is where undefined symbol errors are
emitted). This matches what the ELF port does.


https://reviews.llvm.org/D109079

Files:
  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
+
+_filler3:
+.space 0x4000000


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109079.369998.patch
Type: text/x-patch
Size: 601 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210901/50e56454/attachment.bin>


More information about the llvm-commits mailing list