[ELF2] Implement --no-undefined flag.

llvm-svn: 249064
This commit is contained in:
George Rimar 2015-10-01 20:14:45 +00:00
parent 195b3b0074
commit 57e40deb8d
5 changed files with 13 additions and 1 deletions

View File

@ -31,6 +31,7 @@ struct Configuration {
bool DiscardNone;
bool ExportDynamic;
bool NoInhibitExec;
bool NoUndefined;
bool Shared;
bool Static = false;
bool WholeArchive = false;

View File

@ -126,6 +126,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
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) {

View File

@ -43,6 +43,9 @@ def no_whole_archive : Flag<["--"], "no-whole-archive">,
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">;

View File

@ -271,7 +271,7 @@ static void reportUndefined(const SymbolTable &S, const SymbolBody &Sym) {
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;

View File

@ -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