[PATCH] D30258: [ELF] - Implemented --no-dynamic-linker option

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 23 07:03:41 PST 2017


LGTM.

This does look a bit odd, but it seems better to implement it than to
just ignore it.

Please wait to see if Rui agrees.

Cheers,
Rafael

George Rimar via Phabricator <reviews at reviews.llvm.org> writes:

> grimar updated this revision to Diff 89474.
> grimar added a comment.
>
> - Addressed review comment.
>
>
> https://reviews.llvm.org/D30258
>
> Files:
>   ELF/Driver.cpp
>   ELF/Options.td
>   test/ELF/no-dynamic-linker.s
>
>
> Index: test/ELF/no-dynamic-linker.s
> ===================================================================
> --- test/ELF/no-dynamic-linker.s
> +++ test/ELF/no-dynamic-linker.s
> @@ -0,0 +1,12 @@
> +# REQUIRES: x86
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/shared.s -o %tso.o
> +# RUN: ld.lld -shared %tso.o -o %t.so
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
> +
> +# RUN: ld.lld -dynamic-linker foo --no-dynamic-linker %t.o %t.so -o %t
> +# RUN: llvm-readobj --program-headers %t | FileCheck %s --check-prefix=NODL
> +# NODL-NOT: PT_INTERP
> +
> +# RUN: ld.lld --no-dynamic-linker -dynamic-linker foo %t.o %t.so -o %t
> +# RUN: llvm-readobj --program-headers %t | FileCheck %s --check-prefix=WITHDL
> +# WITHDL: PT_INTERP
> Index: ELF/Options.td
> ===================================================================
> --- ELF/Options.td
> +++ ELF/Options.td
> @@ -148,6 +148,8 @@
>  def no_demangle: F<"no-demangle">,
>    HelpText<"Do not demangle symbol names">;
>  
> +def no_dynamic_linker: F<"no-dynamic-linker">;
> +
>  def no_export_dynamic: F<"no-export-dynamic">;
>  def no_fatal_warnings: F<"no-fatal-warnings">;
>  
> @@ -357,7 +359,6 @@
>  def no_allow_shlib_undefined: F<"no-allow-shlib-undefined">;
>  def no_copy_dt_needed_entries: F<"no-copy-dt-needed-entries">,
>    Alias<no_add_needed>;
> -def no_dynamic_linker: F<"no-dynamic-linker">;
>  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">;
> Index: ELF/Driver.cpp
> ===================================================================
> --- ELF/Driver.cpp
> +++ ELF/Driver.cpp
> @@ -434,6 +434,13 @@
>    return DiscardPolicy::None;
>  }
>  
> +static StringRef getDynamicLinkerOption(opt::InputArgList &Args) {
> +  auto *Arg = Args.getLastArg(OPT_dynamic_linker, OPT_no_dynamic_linker);
> +  if (!Arg || Arg->getOption().getID() == OPT_no_dynamic_linker)
> +    return "";
> +  return Arg->getValue();
> +}
> +
>  static StripPolicy getStripOption(opt::InputArgList &Args) {
>    if (auto *Arg = Args.getLastArg(OPT_strip_all, OPT_strip_debug)) {
>      if (Arg->getOption().getID() == OPT_strip_all)
> @@ -548,8 +555,7 @@
>    Config->Trace = Args.hasArg(OPT_trace);
>    Config->Verbose = Args.hasArg(OPT_verbose);
>    Config->WarnCommon = Args.hasArg(OPT_warn_common);
> -
> -  Config->DynamicLinker = getString(Args, OPT_dynamic_linker);
> +  Config->DynamicLinker = getDynamicLinkerOption(Args);
>    Config->Entry = getString(Args, OPT_entry);
>    Config->Fini = getString(Args, OPT_fini, "_fini");
>    Config->Init = getString(Args, OPT_init, "_init");
>
>
> Index: test/ELF/no-dynamic-linker.s
> ===================================================================
> --- test/ELF/no-dynamic-linker.s
> +++ test/ELF/no-dynamic-linker.s
> @@ -0,0 +1,12 @@
> +# REQUIRES: x86
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/shared.s -o %tso.o
> +# RUN: ld.lld -shared %tso.o -o %t.so
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
> +
> +# RUN: ld.lld -dynamic-linker foo --no-dynamic-linker %t.o %t.so -o %t
> +# RUN: llvm-readobj --program-headers %t | FileCheck %s --check-prefix=NODL
> +# NODL-NOT: PT_INTERP
> +
> +# RUN: ld.lld --no-dynamic-linker -dynamic-linker foo %t.o %t.so -o %t
> +# RUN: llvm-readobj --program-headers %t | FileCheck %s --check-prefix=WITHDL
> +# WITHDL: PT_INTERP
> Index: ELF/Options.td
> ===================================================================
> --- ELF/Options.td
> +++ ELF/Options.td
> @@ -148,6 +148,8 @@
>  def no_demangle: F<"no-demangle">,
>    HelpText<"Do not demangle symbol names">;
>  
> +def no_dynamic_linker: F<"no-dynamic-linker">;
> +
>  def no_export_dynamic: F<"no-export-dynamic">;
>  def no_fatal_warnings: F<"no-fatal-warnings">;
>  
> @@ -357,7 +359,6 @@
>  def no_allow_shlib_undefined: F<"no-allow-shlib-undefined">;
>  def no_copy_dt_needed_entries: F<"no-copy-dt-needed-entries">,
>    Alias<no_add_needed>;
> -def no_dynamic_linker: F<"no-dynamic-linker">;
>  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">;
> Index: ELF/Driver.cpp
> ===================================================================
> --- ELF/Driver.cpp
> +++ ELF/Driver.cpp
> @@ -434,6 +434,13 @@
>    return DiscardPolicy::None;
>  }
>  
> +static StringRef getDynamicLinkerOption(opt::InputArgList &Args) {
> +  auto *Arg = Args.getLastArg(OPT_dynamic_linker, OPT_no_dynamic_linker);
> +  if (!Arg || Arg->getOption().getID() == OPT_no_dynamic_linker)
> +    return "";
> +  return Arg->getValue();
> +}
> +
>  static StripPolicy getStripOption(opt::InputArgList &Args) {
>    if (auto *Arg = Args.getLastArg(OPT_strip_all, OPT_strip_debug)) {
>      if (Arg->getOption().getID() == OPT_strip_all)
> @@ -548,8 +555,7 @@
>    Config->Trace = Args.hasArg(OPT_trace);
>    Config->Verbose = Args.hasArg(OPT_verbose);
>    Config->WarnCommon = Args.hasArg(OPT_warn_common);
> -
> -  Config->DynamicLinker = getString(Args, OPT_dynamic_linker);
> +  Config->DynamicLinker = getDynamicLinkerOption(Args);
>    Config->Entry = getString(Args, OPT_entry);
>    Config->Fini = getString(Args, OPT_fini, "_fini");
>    Config->Init = getString(Args, OPT_init, "_init");


More information about the llvm-commits mailing list