diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp --- a/lld/MachO/InputFiles.cpp +++ b/lld/MachO/InputFiles.cpp @@ -407,7 +407,11 @@ const section_64 &sec = sectionHeaders[sym.n_sect - 1]; SubsectionMap &subsecMap = subsections[sym.n_sect - 1]; - assert(!subsecMap.empty()); + + // parseSections() may have chosen not to parse this section. + if (subsecMap.empty()) + continue; + uint64_t offset = sym.n_value - sec.addr; // If the input file does not use subsections-via-symbols, all symbols can diff --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp --- a/lld/MachO/SyntheticSections.cpp +++ b/lld/MachO/SyntheticSections.cpp @@ -733,6 +733,8 @@ for (InputFile *file : inputFiles) { if (auto *objFile = dyn_cast(file)) { for (Symbol *sym : objFile->symbols) { + if (sym == nullptr) + continue; // TODO: when we implement -dead_strip, we should filter out symbols // that belong to dead sections. if (auto *defined = dyn_cast(sym)) { diff --git a/lld/test/MachO/stabs.s b/lld/test/MachO/stabs.s --- a/lld/test/MachO/stabs.s +++ b/lld/test/MachO/stabs.s @@ -181,6 +181,10 @@ .subsections_via_symbols .section __DWARF,__debug_line,regular,debug +.section __DWARF,__debug_aranges,regular,debug +ltmp1: + .byte 0 + #--- no-debug.s ## This file has no debug info. .text