diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp --- a/lld/MachO/InputFiles.cpp +++ b/lld/MachO/InputFiles.cpp @@ -698,7 +698,10 @@ sym.n_desc & REFERENCED_DYNAMICALLY, sym.n_desc & N_NO_DEAD_STRIP, isWeakDefCanBeHidden); } - assert(!isWeakDefCanBeHidden && + // weak_def_can_be_hidden symbols should not reach this point, however a + // private alias to one can, so only assert if a weak_def_can_be_hidden symbol + // reaches this point, which is not an alias. + assert((!isWeakDefCanBeHidden || sym.n_type & N_INDR) && "weak_def_can_be_hidden on already-hidden symbol?"); bool includeInSymtab = !isPrivateLabel(name) && !isEhFrameSection(isec); return make( diff --git a/lld/test/MachO/weak-def-can-be-hidden.s b/lld/test/MachO/weak-def-can-be-hidden.s --- a/lld/test/MachO/weak-def-can-be-hidden.s +++ b/lld/test/MachO/weak-def-can-be-hidden.s @@ -116,6 +116,9 @@ _foo: retq +# A private alias to a weak_def_can_be_hidden symbol should not raise an error or assertion +.set l_foo, _foo + #--- weak-foo-pe.s .private_extern _foo .globl _foo