[PATCH] D13244: [ELF2] - implemented --allow-shlib-undefined/--no-allow-shlib-undefined

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 1 01:59:30 PDT 2015


grimar updated the summary for this revision.
grimar updated this revision to Diff 36199.
grimar added a comment.

Review comments addressed.


http://reviews.llvm.org/D13244

Files:
  ELF/Options.td
  ELF/Writer.cpp
  test/elf2/Inputs/allow-shlib-undefined.s
  test/elf2/allow-shlib-undefined.s

Index: test/elf2/allow-shlib-undefined.s
===================================================================
--- test/elf2/allow-shlib-undefined.s
+++ test/elf2/allow-shlib-undefined.s
@@ -0,0 +1,25 @@
+# --allow-shlib-undefined and --no-allow-shlib-undefined are fully
+# ignored in linker implementation. 
+# --allow-shlib-undefined is set by default
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
+# RUN: %p/Inputs/allow-shlib-undefined.s -o %t
+# RUN: lld -shared -flavor gnu2 %t -o %t.so 
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1
+
+# Executable: should link with DSO containing undefined symbols in any case.
+# RUN: lld -flavor gnu2 %t1 %t.so -o %t2
+# RUN: lld -flavor gnu2 --no-allow-shlib-undefined %t1 %t.so -o %t2
+# RUN: lld -flavor gnu2 --allow-shlib-undefined %t1 %t.so -o %t2
+ 
+# DSO with undefines: 
+# should link with or without any of these options.
+# RUN: lld -shared -flavor gnu2 %t -o %t.so 
+# RUN: lld -shared --allow-shlib-undefined -flavor gnu2 %t -o %t.so 
+# RUN: lld -shared --no-allow-shlib-undefined -flavor gnu2 %t -o %t.so 
+ 
+# Executable still should not link when have undefines inside.
+# RUN: not lld -flavor gnu2 %t -o %t.so 
+
+.globl _start
+_start: 
+  call _shared
Index: test/elf2/Inputs/allow-shlib-undefined.s
===================================================================
--- test/elf2/Inputs/allow-shlib-undefined.s
+++ test/elf2/Inputs/allow-shlib-undefined.s
@@ -0,0 +1,3 @@
+.globl _shared
+_shared: 
+  call _unresolved
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -271,6 +271,9 @@
   typedef typename ELFFile<ELFT>::Elf_Sym Elf_Sym;
   typedef typename ELFFile<ELFT>::Elf_Sym_Range Elf_Sym_Range;
 
+  if (Config->Shared)
+    return;
+
   const Elf_Sym &SymE = cast<ELFSymbolBody<ELFT>>(Sym).Sym;
   ELFFileBase *SymFile = nullptr;
 
Index: ELF/Options.td
===================================================================
--- ELF/Options.td
+++ ELF/Options.td
@@ -61,3 +61,9 @@
 
 def alias_entry : Separate<["-"], "e">,
      Alias<entry>;
+
+def no_allow_shlib_undefined
+    : Flag<["--"], "no-allow-shlib-undefined">;
+
+def allow_shlib_undefined
+    : Flag<["--"], "allow-shlib-undefined">;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13244.36199.patch
Type: text/x-patch
Size: 2337 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151001/7deed16d/attachment.bin>


More information about the llvm-commits mailing list