[PATCH] D56110: Fix linker-defined symbols possibly not being defined when -wrap is used

Tom Anderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 2 11:31:44 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL350251: Fix linker-defined symbols possibly not being defined when -wrap is used (authored by thomasanderson, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56110?vs=179666&id=179902#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56110/new/

https://reviews.llvm.org/D56110

Files:
  lld/trunk/ELF/Driver.cpp
  lld/trunk/test/ELF/Inputs/wrap-with-archive.s
  lld/trunk/test/ELF/wrap-with-archive.s


Index: lld/trunk/test/ELF/Inputs/wrap-with-archive.s
===================================================================
--- lld/trunk/test/ELF/Inputs/wrap-with-archive.s
+++ lld/trunk/test/ELF/Inputs/wrap-with-archive.s
@@ -0,0 +1,5 @@
+.global __executable_start
+.global __wrap_get_executable_start
+
+__wrap_get_executable_start:	
+	movabs $__executable_start,%rdx
Index: lld/trunk/test/ELF/wrap-with-archive.s
===================================================================
--- lld/trunk/test/ELF/wrap-with-archive.s
+++ lld/trunk/test/ELF/wrap-with-archive.s
@@ -0,0 +1,13 @@
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/wrap-with-archive.s -o %t2
+// RUN: llvm-ar rcs %t3 %t2
+// RUN: ld.lld -o %t4 %t %t3 -wrap get_executable_start
+
+// Regression test for https://bugs.llvm.org/show_bug.cgi?id=40134
+	
+.global get_executable_start
+.global _start
+
+_start:
+	jmp get_executable_start
Index: lld/trunk/ELF/Driver.cpp
===================================================================
--- lld/trunk/ELF/Driver.cpp
+++ lld/trunk/ELF/Driver.cpp
@@ -1550,6 +1550,9 @@
   Out::ElfHeader = make<OutputSection>("", 0, SHF_ALLOC);
   Out::ElfHeader->Size = sizeof(typename ELFT::Ehdr);
 
+  // Create wrapped symbols for -wrap option.
+  std::vector<WrappedSymbol> Wrapped = addWrappedSymbols<ELFT>(Args);
+
   // We need to create some reserved symbols such as _end. Create them.
   if (!Config->Relocatable)
     addReservedSymbols();
@@ -1562,9 +1565,6 @@
   if (!Config->Relocatable)
     Symtab->scanVersionScript();
 
-  // Create wrapped symbols for -wrap option.
-  std::vector<WrappedSymbol> Wrapped = addWrappedSymbols<ELFT>(Args);
-
   // Do link-time optimization if given files are LLVM bitcode files.
   // This compiles bitcode files into real object files.
   //


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56110.179902.patch
Type: text/x-patch
Size: 1890 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190102/9829213a/attachment.bin>


More information about the llvm-commits mailing list