[lld] r249064 - [ELF2] Implement --no-undefined flag.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 1 13:14:46 PDT 2015
Author: grimar
Date: Thu Oct 1 15:14:45 2015
New Revision: 249064
URL: http://llvm.org/viewvc/llvm-project?rev=249064&view=rev
Log:
[ELF2] Implement --no-undefined flag.
Added:
lld/trunk/test/elf2/no-undefined.s
Modified:
lld/trunk/ELF/Config.h
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/Options.td
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=249064&r1=249063&r2=249064&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Thu Oct 1 15:14:45 2015
@@ -31,6 +31,7 @@ struct Configuration {
bool DiscardNone;
bool ExportDynamic;
bool NoInhibitExec;
+ bool NoUndefined;
bool Shared;
bool Static = false;
bool WholeArchive = false;
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=249064&r1=249063&r2=249064&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Thu Oct 1 15:14:45 2015
@@ -126,6 +126,7 @@ void LinkerDriver::link(ArrayRef<const c
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) {
Modified: lld/trunk/ELF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Options.td?rev=249064&r1=249063&r2=249064&view=diff
==============================================================================
--- lld/trunk/ELF/Options.td (original)
+++ lld/trunk/ELF/Options.td Thu Oct 1 15:14:45 2015
@@ -43,6 +43,9 @@ def no_whole_archive : Flag<["--"], "no-
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">;
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=249064&r1=249063&r2=249064&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Thu Oct 1 15:14:45 2015
@@ -271,7 +271,7 @@ static void reportUndefined(const Symbol
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;
Added: lld/trunk/test/elf2/no-undefined.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/no-undefined.s?rev=249064&view=auto
==============================================================================
--- lld/trunk/test/elf2/no-undefined.s (added)
+++ lld/trunk/test/elf2/no-undefined.s Thu Oct 1 15:14:45 2015
@@ -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
More information about the llvm-commits
mailing list