diff --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp --- a/lld/MachO/SyntheticSections.cpp +++ b/lld/MachO/SyntheticSections.cpp @@ -585,8 +585,10 @@ } static bool shouldExportSymbol(const Defined *defined) { - if (defined->privateExtern) + if (defined->privateExtern) { + assert(defined->isExternal() && "invalid input file"); return false; + } // TODO: Is this a performance bottleneck? If a build has mostly // global symbols in the input but uses -exported_symbols to filter // out most of them, then it would be better to set the value of @@ -844,7 +846,6 @@ if (!shouldExportSymbol(defined)) { // Private external -- dylib scoped symbol. // Promote to non-external at link time. - assert(defined->isExternal() && "invalid input file"); scope = N_PEXT; } else if (defined->isExternal()) { // Normal global symbol. diff --git a/lld/test/MachO/export-options.s b/lld/test/MachO/export-options.s --- a/lld/test/MachO/export-options.s +++ b/lld/test/MachO/export-options.s @@ -38,6 +38,8 @@ .private_extern _private_extern _private_extern: retq +_private: + retq ## Check that the export trie is unaltered # RUN: %lld -dylib %t/default.o -o %t/default