[PATCH] D13355: [ELF2] --no-undefined flag implemented
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 1 10:37:21 PDT 2015
grimar created this revision.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: grimar, llvm-commits.
Report unresolved symbol references from regular object files. This is done even if the linker is creating a non-symbolic shared library.
http://reviews.llvm.org/D13355
Files:
ELF/Config.h
ELF/Driver.cpp
ELF/Options.td
ELF/Writer.cpp
test/elf2/Inputs/no-undefined.s
test/elf2/no-undefined.s
Index: test/elf2/no-undefined.s
===================================================================
--- test/elf2/no-undefined.s
+++ test/elf2/no-undefined.s
@@ -0,0 +1,16 @@
+# 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
+
+# Try to make a DSO that links to another DSO with unresolved.
+# Specify --no-undefined and that should not fail because this flag
+# does not control the behaviour for reporting unresolved references
+# found in shared libraries being linked in.
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/no-undefined.s -o %t2
+# RUN: lld -shared --no-undefined -flavor gnu2 %t2 %t1.so -o %t3.so
+
+
+
+.globl _shared
+_shared:
+ call _unresolved
Index: test/elf2/Inputs/no-undefined.s
===================================================================
--- test/elf2/Inputs/no-undefined.s
+++ test/elf2/Inputs/no-undefined.s
@@ -0,0 +1,2 @@
+.globl _start
+_start:
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,11 @@
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 symbol references from regular object files "
+ "even if the linker is creating a non-symbolic 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.36269.patch
Type: text/x-patch
Size: 2786 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151001/698a4413/attachment.bin>
More information about the llvm-commits
mailing list