[lld/mac] Don't crash on absolute symbols in unwind info generation
authorNico Weber <thakis@chromium.org>
Wed, 23 Jun 2021 18:25:08 +0000 (14:25 -0400)
committerNico Weber <thakis@chromium.org>
Wed, 23 Jun 2021 18:25:34 +0000 (14:25 -0400)
Fixes a regression from d6565a2dbcbe and PR50820.

lld/MachO/UnwindInfoSection.cpp
lld/test/MachO/compact-unwind.s

index 13be856..e1e8d30 100644 (file)
@@ -297,7 +297,9 @@ static void addEntriesForFunctionsWithoutUnwindInfo(
   // Add explicit "has no unwind info" entries for all global and local symbols
   // without unwind info.
   auto markNoUnwindInfo = [&cuVector, &hasUnwindInfo](const Defined *d) {
-    if (d->isLive() && isCodeSection(d->isec)) {
+    // FIXME: The d->isec null check might be incorrect for symbols
+    // from LTO files.
+    if (d->isLive() && d->isec && isCodeSection(d->isec)) {
       Ptr ptr = d->getVA();
       if (!hasUnwindInfo.count(ptr))
         cuVector.push_back({ptr, 0, 0, 0, 0});
index 72aeaf8..075bb32 100644 (file)
@@ -110,6 +110,9 @@ _main:
 _quux:
   ret
 
+.globl _abs
+_abs = 4
+
 .p2align 2
 _baz:
   .cfi_startproc