Index: ELF/Driver.cpp =================================================================== --- ELF/Driver.cpp +++ ELF/Driver.cpp @@ -667,6 +667,9 @@ Config->ZText = !hasZOption(Args, "notext"); Config->ZWxneeded = hasZOption(Args, "wxneeded"); + if (!Config->Relocatable && !Config->DefineCommon) + error("-no-define-common not supported in non relocatable output"); + // Parse LTO plugin-related options for compatibility with gold. for (auto *Arg : Args.filtered(OPT_plugin_opt, OPT_plugin_opt_eq)) { StringRef S = Arg->getValue(); Index: test/ELF/relocatable-common.s =================================================================== --- test/ELF/relocatable-common.s +++ test/ELF/relocatable-common.s @@ -33,4 +33,7 @@ # DEFCOMM-NEXT: Section: COMMON # DEFCOMM-NEXT: } +# RUN: not ld.lld -shared --no-define-common %t1.o -o %t 2>&1 | FileCheck --check-prefix=ERROR %s +# ERROR: error: -no-define-common not supported in non relocatable output + .comm common,4,4