From dbbc8d8333f29cf4ad6f4793da1adf71bbfdac69 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Wed, 23 Jun 2021 14:25:08 -0400 Subject: [PATCH] [lld/mac] Don't crash on absolute symbols in unwind info generation Fixes a regression from d6565a2dbcbe and PR50820. --- lld/MachO/UnwindInfoSection.cpp | 4 +++- lld/test/MachO/compact-unwind.s | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lld/MachO/UnwindInfoSection.cpp b/lld/MachO/UnwindInfoSection.cpp index 13be856..e1e8d30 100644 --- a/lld/MachO/UnwindInfoSection.cpp +++ b/lld/MachO/UnwindInfoSection.cpp @@ -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}); diff --git a/lld/test/MachO/compact-unwind.s b/lld/test/MachO/compact-unwind.s index 72aeaf8..075bb32 100644 --- a/lld/test/MachO/compact-unwind.s +++ b/lld/test/MachO/compact-unwind.s @@ -110,6 +110,9 @@ _main: _quux: ret +.globl _abs +_abs = 4 + .p2align 2 _baz: .cfi_startproc -- 2.7.4