[PATCH] D13355: [ELF2] --no-undefined flag implemented

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 1 11:22:17 PDT 2015


grimar updated this revision to Diff 36277.
grimar added a comment.

Review comments addressed


http://reviews.llvm.org/D13355

Files:
  ELF/Config.h
  ELF/Driver.cpp
  ELF/Options.td
  ELF/Writer.cpp
  test/elf2/no-undefined.s

Index: test/elf2/no-undefined.s
===================================================================
--- test/elf2/no-undefined.s
+++ test/elf2/no-undefined.s
@@ -0,0 +1,7 @@
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: not lld --no-undefined -shared -flavor gnu2 %t -o %t.so 
+# RUN: lld -shared -flavor gnu2 %t -o %t1.so 
+
+.globl _shared
+_shared: 
+  call _unresolved
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -271,7 +271,7 @@
   typedef typename ELFFile<ELFT>::Elf_Sym Elf_Sym;
   typedef typename ELFFile<ELFT>::Elf_Sym_Range Elf_Sym_Range;
 
-  if (Config->Shared)
+  if (Config->Shared && !Config->NoUndefined)
     return;
 
   const Elf_Sym &SymE = cast<ELFSymbolBody<ELFT>>(Sym).Sym;
Index: ELF/Options.td
===================================================================
--- ELF/Options.td
+++ ELF/Options.td
@@ -36,6 +36,9 @@
 def noinhibit_exec : Flag<["--"], "noinhibit-exec">,
   HelpText<"Retain the executable output file whenever it is still usable">;
 
+def no_undefined : Flag<["--"], "no-undefined">,
+  HelpText<"Report unresolved symbols even if the linker is creating a shared library">;
+
 def output : Separate<["-"], "o">, MetaVarName<"<path>">,
   HelpText<"Path to file to write output">;
 
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -123,6 +123,7 @@
   Config->DiscardNone = Args.hasArg(OPT_discard_none);
   Config->ExportDynamic = Args.hasArg(OPT_export_dynamic);
   Config->NoInhibitExec = Args.hasArg(OPT_noinhibit_exec);
+  Config->NoUndefined = Args.hasArg(OPT_no_undefined);
   Config->Shared = Args.hasArg(OPT_shared);
 
   for (auto *Arg : Args) {
Index: ELF/Config.h
===================================================================
--- ELF/Config.h
+++ ELF/Config.h
@@ -30,6 +30,7 @@
   bool DiscardNone;
   bool ExportDynamic;
   bool NoInhibitExec;
+  bool NoUndefined;
   bool Shared;
   bool Static = false;
 };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13355.36277.patch
Type: text/x-patch
Size: 2070 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151001/ecfc232a/attachment.bin>


More information about the llvm-commits mailing list