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

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 24 00:38:07 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL296097: [ELF] - Implemented --no-dynamic-linker option (authored by grimar).

Changed prior to commit:
  https://reviews.llvm.org/D30258?vs=89474&id=89615#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30258

Files:
  lld/trunk/ELF/Driver.cpp
  lld/trunk/ELF/Options.td
  lld/trunk/test/ELF/no-dynamic-linker.s


Index: lld/trunk/ELF/Driver.cpp
===================================================================
--- lld/trunk/ELF/Driver.cpp
+++ lld/trunk/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,6 @@
   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->Entry = getString(Args, OPT_entry);
   Config->Fini = getString(Args, OPT_fini, "_fini");
   Config->Init = getString(Args, OPT_init, "_init");
@@ -582,6 +587,7 @@
   Config->ZStackSize = getZOptionValue(Args, "stack-size", 0);
   Config->ZWxneeded = hasZOption(Args, "wxneeded");
 
+  Config->DynamicLinker = getDynamicLinkerOption(Args);
   Config->OFormatBinary = isOutputFormatBinary(Args);
   Config->SectionStartMap = getSectionStartMap(Args);
   Config->SortSection = getSortKind(Args);
Index: lld/trunk/ELF/Options.td
===================================================================
--- lld/trunk/ELF/Options.td
+++ lld/trunk/ELF/Options.td
@@ -148,6 +148,9 @@
 def no_demangle: F<"no-demangle">,
   HelpText<"Do not demangle symbol names">;
 
+def no_dynamic_linker: F<"no-dynamic-linker">,
+  HelpText<"Inhibit output of .interp section">;
+
 def no_export_dynamic: F<"no-export-dynamic">;
 def no_fatal_warnings: F<"no-fatal-warnings">;
 
@@ -357,7 +360,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: lld/trunk/test/ELF/no-dynamic-linker.s
===================================================================
--- lld/trunk/test/ELF/no-dynamic-linker.s
+++ lld/trunk/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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30258.89615.patch
Type: text/x-patch
Size: 2978 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170224/845e1ad6/attachment.bin>


More information about the llvm-commits mailing list