diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h --- a/lld/ELF/Config.h +++ b/lld/ELF/Config.h @@ -160,7 +160,6 @@ bool compressDebugSections; bool cref; std::vector> deadRelocInNonAlloc; - bool defineCommon; bool demangle = true; bool dependentLibraries; bool disableVerify; diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -327,9 +327,6 @@ if (!config->shared && !config->auxiliaryList.empty()) error("-f may not be used without -shared"); - if (!config->relocatable && !config->defineCommon) - error("-no-define-common not supported in non relocatable output"); - if (config->strip == StripPolicy::All && config->emitRelocs) error("--strip-all and --emit-relocs may not be used together"); @@ -989,8 +986,6 @@ config->chroot = args.getLastArgValue(OPT_chroot); config->compressDebugSections = getCompressDebugSections(args); config->cref = args.hasArg(OPT_cref); - config->defineCommon = args.hasFlag(OPT_define_common, OPT_no_define_common, - !args.hasArg(OPT_relocatable)); config->optimizeBBJumps = args.hasFlag(OPT_optimize_bb_jumps, OPT_no_optimize_bb_jumps, false); config->demangle = args.hasFlag(OPT_demangle, OPT_no_demangle, true); diff --git a/lld/ELF/Options.td b/lld/ELF/Options.td --- a/lld/ELF/Options.td +++ b/lld/ELF/Options.td @@ -129,10 +129,6 @@ def cref: FF<"cref">, HelpText<"Output cross reference table. If -Map is specified, print to the map file">; -defm define_common: B<"define-common", - "Assign space to common symbols", - "Do not assign space to common symbols">; - defm demangle: B<"demangle", "Demangle symbol names (default)", "Do not demangle symbol names">; @@ -512,9 +508,6 @@ def: F<"dn">, Alias, HelpText<"Alias for --Bstatic">; def: F<"non_shared">, Alias, HelpText<"Alias for --Bstatic">; def: F<"static">, Alias, HelpText<"Alias for --Bstatic">; -def: Flag<["-"], "d">, Alias, HelpText<"Alias for --define-common">; -def: F<"dc">, Alias, HelpText<"Alias for --define-common">; -def: F<"dp">, Alias, HelpText<"Alias for --define-common">; def: Flag<["-"], "x">, Alias, HelpText<"Alias for --discard-all">; def: Flag<["-"], "X">, Alias, HelpText<"Alias for --discard-locals">; def: Flag<["-"], "q">, Alias, HelpText<"Alias for --emit-relocs">; @@ -693,6 +686,7 @@ // Options listed below are silently ignored for now for compatibility. def: F<"detect-odr-violations">; +def: Flag<["-"], "d">; def: Flag<["-"], "g">; def: F<"long-plt">; def: F<"no-copy-dt-needed-entries">; diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -2193,7 +2193,7 @@ } static BssSection *getCommonSec(Symbol *sym) { - if (!config->defineCommon) + if (config->relocatable) if (auto *d = dyn_cast(sym)) return dyn_cast_or_null(d->section); return nullptr; @@ -2235,8 +2235,8 @@ eSym->st_other |= sym->stOther & STO_AARCH64_VARIANT_PCS; if (BssSection *commonSec = getCommonSec(sym)) { - // st_value is usually an address of a symbol, but that has a special - // meaning for uninstantiated common symbols (--no-define-common). + // When -r is specified, a COMMON symbol is not allocated. Its st_shndx + // holds SHN_COMMON and st_value holds the alignment. eSym->st_shndx = SHN_COMMON; eSym->st_value = commonSec->alignment; eSym->st_size = cast(sym)->size; diff --git a/lld/docs/ReleaseNotes.rst b/lld/docs/ReleaseNotes.rst --- a/lld/docs/ReleaseNotes.rst +++ b/lld/docs/ReleaseNotes.rst @@ -29,7 +29,8 @@ Breaking changes ---------------- -* ... +* The GNU ld incompatible ``--no-define-common`` has been removed. +* The obscure ``-d``/``-dc``/``-dp`` options have been removed. COFF Improvements ----------------- diff --git a/lld/docs/ld.lld.1 b/lld/docs/ld.lld.1 --- a/lld/docs/ld.lld.1 +++ b/lld/docs/ld.lld.1 @@ -144,8 +144,9 @@ Output cross reference table. If .Fl Map is specified, print to the map file. -.It Fl -define-common , Fl d -Assign space to common symbols. +.It Fl dc +.Fl r +specific: assign space to COMMON symbols like building an executable or shared object. .It Fl -defsym Ns = Ns Ar symbol Ns = Ns Ar expression Define a symbol alias. .Ar expression @@ -326,8 +327,6 @@ for shared libraries. .It Fl -no-color-diagnostics Do not use colors in diagnostics. -.It Fl -no-define-common -Do not assign space to common symbols. .It Fl -no-demangle Do not demangle symbol names. .It Fl -no-dynamic-linker diff --git a/lld/test/ELF/relocatable-common.s b/lld/test/ELF/relocatable-common.s --- a/lld/test/ELF/relocatable-common.s +++ b/lld/test/ELF/relocatable-common.s @@ -2,16 +2,6 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o # RUN: ld.lld -r %t1.o -o %t # RUN: llvm-readobj --symbols -r %t | FileCheck %s -# RUN: ld.lld -r --no-define-common %t1.o -o %t -# RUN: llvm-readobj --symbols -r %t | FileCheck %s -# RUN: ld.lld -r --define-common %t1.o -o %t -# RUN: llvm-readobj --symbols -r %t | FileCheck -check-prefix=DEFCOMM %s -# RUN: ld.lld -r -d %t1.o -o %t -# RUN: llvm-readobj --symbols -r %t | FileCheck -check-prefix=DEFCOMM %s -# RUN: ld.lld -r -dc %t1.o -o %t -# RUN: llvm-readobj --symbols -r %t | FileCheck -check-prefix=DEFCOMM %s -# RUN: ld.lld -r -dp %t1.o -o %t -# RUN: llvm-readobj --symbols -r %t | FileCheck -check-prefix=DEFCOMM %s # CHECK: Symbol { # CHECK: Name: common @@ -23,17 +13,4 @@ # CHECK-NEXT: Section: Common (0xFFF2) # CHECK-NEXT: } -# DEFCOMM: Symbol { -# DEFCOMM: Name: common -# DEFCOMM-NEXT: Value: 0x0 -# DEFCOMM-NEXT: Size: 4 -# DEFCOMM-NEXT: Binding: Global -# DEFCOMM-NEXT: Type: Object -# DEFCOMM-NEXT: Other: 0 -# DEFCOMM-NEXT: Section: COMMON -# DEFCOMM-NEXT: } - -# RUN: not ld.lld -shared --no-define-common %t1.o -o /dev/null 2>&1 | FileCheck --check-prefix=ERROR %s -# ERROR: error: -no-define-common not supported in non relocatable output - .comm common,4,4 diff --git a/lld/test/ELF/silent-ignore.test b/lld/test/ELF/silent-ignore.test --- a/lld/test/ELF/silent-ignore.test +++ b/lld/test/ELF/silent-ignore.test @@ -1,4 +1,5 @@ RUN: ld.lld --version \ +RUN: -d \ RUN: -detect-odr-violations \ RUN: -g \ RUN: -long-plt \