diff --git a/lld/MachO/SymbolTable.cpp b/lld/MachO/SymbolTable.cpp --- a/lld/MachO/SymbolTable.cpp +++ b/lld/MachO/SymbolTable.cpp @@ -230,8 +230,9 @@ uint64_t value, bool isPrivateExtern, bool includeInSymtab, bool referencedDynamically) { + assert(!isec || !isec->getFile()); // See makeSyntheticInputSection(). Defined *s = - addDefined(name, nullptr, isec, value, /*size=*/0, + addDefined(name, /*file=*/nullptr, isec, value, /*size=*/0, /*isWeakDef=*/false, isPrivateExtern, /*isThumb=*/false, referencedDynamically, /*noDeadStrip=*/false, /*isWeakDefCanBeHidden=*/false); diff --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp --- a/lld/MachO/SyntheticSections.cpp +++ b/lld/MachO/SyntheticSections.cpp @@ -908,6 +908,11 @@ ObjFile *file = dyn_cast_or_null(isec->getFile()); if (!file || !file->compileUnit) continue; + + // All symbols that set includeInSymtab to false are synthetic symbols. + // Those have `file` set to nullptr and were already skipped due to that. + assert(defined->includeInSymtab); + symbolsNeedingStabs.push_back(defined); } }