[PATCH] D42929: Add -no-allow-multiple-definition, -no-pic-executable and -no-warn-common.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 5 16:42:01 PST 2018


LGTM

Rui Ueyama via Phabricator <reviews at reviews.llvm.org> writes:

> ruiu created this revision.
> ruiu added a reviewer: rafael.
> Herald added a subscriber: emaste.
>
> GNU gold has these options.
>
>
> https://reviews.llvm.org/D42929
>
> Files:
>   lld/ELF/Driver.cpp
>   lld/ELF/Options.td
>   lld/test/ELF/allow-multiple-definition.s
>   lld/test/ELF/pie.s
>   lld/test/ELF/warn-common.s
>
> Index: lld/test/ELF/warn-common.s
> ===================================================================
> --- lld/test/ELF/warn-common.s
> +++ lld/test/ELF/warn-common.s
> @@ -7,9 +7,7 @@
>  # RUN: ld.lld --warn-common %t1.o %t2.o -o %t.out 2>&1 | FileCheck %s --check-prefix=WARN
>  # WARN: multiple common of arr
>  
> -## no-warn-common is ignored
> -# RUN: ld.lld --no-warn-common %t1.o %t2.o -o %t.out
> -# RUN: llvm-readobj %t.out > /dev/null
> +# RUN: ld.lld --fatal-warnings --warn-common --no-warn-common %t1.o %t2.o -o %t.out
>  
>  ## Report if common is overridden
>  # RUN: ld.lld --warn-common %t1.o %t3.o -o %t.out 2>&1 | FileCheck %s --check-prefix=OVER
> Index: lld/test/ELF/pie.s
> ===================================================================
> --- lld/test/ELF/pie.s
> +++ lld/test/ELF/pie.s
> @@ -50,6 +50,8 @@
>  ## Check -nopie
>  # RUN: ld.lld -no-pie %t1.o -o %t2
>  # RUN: llvm-readobj -file-headers -r %t2 | FileCheck %s --check-prefix=NOPIE
> +# RUN: ld.lld -no-pic-executable %t1.o -o %t2
> +# RUN: llvm-readobj -file-headers -r %t2 | FileCheck %s --check-prefix=NOPIE
>  # NOPIE-NOT: Type: SharedObject
>  
>  .globl _start
> Index: lld/test/ELF/allow-multiple-definition.s
> ===================================================================
> --- lld/test/ELF/allow-multiple-definition.s
> +++ lld/test/ELF/allow-multiple-definition.s
> @@ -3,6 +3,7 @@
>  # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1
>  # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/allow-multiple-definition.s -o %t2
>  # RUN: not ld.lld %t1 %t2 -o %t3
> +# RUN: not ld.lld --allow-multiple-definition --no-allow-multiple-definition %t1 %t2 -o %t3
>  # RUN: ld.lld --allow-multiple-definition %t1 %t2 -o %t3
>  # RUN: ld.lld --allow-multiple-definition %t2 %t1 -o %t4
>  # RUN: llvm-objdump -d %t3 | FileCheck %s
> Index: lld/ELF/Options.td
> ===================================================================
> --- lld/ELF/Options.td
> +++ lld/ELF/Options.td
> @@ -54,8 +54,9 @@
>  defm Ttext: Eq<"Ttext">,
>    HelpText<"Same as --section-start with .text as the sectionname">;
>  
> -def allow_multiple_definition: F<"allow-multiple-definition">,
> -  HelpText<"Allow multiple definitions">;
> +defm allow_multiple_definition: B<"allow-multiple-definition",
> +    "Allow multiple definitions",
> +    "Do not allow multiple definitions">;
>  
>  defm apply_dynamic_relocs: B<"apply-dynamic-relocs",
>      "Apply dynamic relocations to place",
> @@ -319,8 +320,9 @@
>  
>  defm version_script: Eq<"version-script">, HelpText<"Read a version script">;
>  
> -def warn_common: F<"warn-common">,
> -  HelpText<"Warn about duplicate common symbols">;
> +defm warn_common: B<"warn-common",
> +    "Warn about duplicate common symbols",
> +    "Do not warn about duplicate common symbols">;
>  
>  def warn_unresolved_symbols: F<"warn-unresolved-symbols">,
>    HelpText<"Report unresolved symbols as warnings">;
> @@ -354,6 +356,7 @@
>  def alias_format_b: S<"b">, Alias<format>;
>  def alias_library: JoinedOrSeparate<["-"], "l">, Alias<library>;
>  def alias_library_path: JoinedOrSeparate<["-"], "L">, Alias<library_path>;
> +def alias_no_pie_pic_executable: F<"no-pic-executable">, Alias<no_pie>;
>  def alias_omagic: Flag<["-"], "N">, Alias<omagic>;
>  def alias_o_output: Joined<["--"], "output=">, Alias<o>;
>  def alias_o_output2 : Separate<["--"], "output">, Alias<o>;
> @@ -424,7 +427,6 @@
>  def no_ctors_in_init_array: F<"no-ctors-in-init-array">;
>  def no_keep_memory: F<"no-keep-memory">;
>  def no_mmap_output_file: F<"no-mmap-output-file">;
> -def no_warn_common: F<"no-warn-common">;
>  def no_warn_mismatch: F<"no-warn-mismatch">;
>  def rpath_link: S<"rpath-link">;
>  def rpath_link_eq: J<"rpath-link=">;
> Index: lld/ELF/Driver.cpp
> ===================================================================
> --- lld/ELF/Driver.cpp
> +++ lld/ELF/Driver.cpp
> @@ -596,7 +596,9 @@
>  // Initializes Config members by the command line options.
>  void LinkerDriver::readConfigs(opt::InputArgList &Args) {
>    Config->AllowMultipleDefinition =
> -      Args.hasArg(OPT_allow_multiple_definition) || hasZOption(Args, "muldefs");
> +      Args.hasFlag(OPT_allow_multiple_definition,
> +                   OPT_no_allow_multiple_definition, false) ||
> +      hasZOption(Args, "muldefs");
>    Config->ApplyDynamicRelocs = Args.hasFlag(OPT_apply_dynamic_relocs,
>                                              OPT_no_apply_dynamic_relocs, false);
>    Config->AuxiliaryList = args::getStrings(Args, OPT_auxiliary);
> @@ -680,7 +682,7 @@
>    Config->UnresolvedSymbols = getUnresolvedSymbolPolicy(Args);
>    Config->Verbose = Args.hasArg(OPT_verbose);
>    errorHandler().Verbose = Config->Verbose;
> -  Config->WarnCommon = Args.hasArg(OPT_warn_common);
> +  Config->WarnCommon = Args.hasFlag(OPT_warn_common, OPT_no_warn_common, false);
>    Config->ZCombreloc = !hasZOption(Args, "nocombreloc");
>    Config->ZExecstack = hasZOption(Args, "execstack");
>    Config->ZNocopyreloc = hasZOption(Args, "nocopyreloc");


More information about the llvm-commits mailing list