[PATCH] D18357: [LTO] Include in .symtab/.dynsym symbols introduced by optimizations

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 28 17:21:05 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL264688: [LTO] Include in .symtab/.dynsym symbols introduced by optimizations. (authored by davide).

Changed prior to commit:
  http://reviews.llvm.org/D18357?vs=51847&id=51861#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18357

Files:
  lld/trunk/ELF/SymbolTable.cpp
  lld/trunk/ELF/Symbols.h
  lld/trunk/test/ELF/lto/Inputs/shared.s
  lld/trunk/test/ELF/lto/undefined-puts.ll

Index: lld/trunk/ELF/SymbolTable.cpp
===================================================================
--- lld/trunk/ELF/SymbolTable.cpp
+++ lld/trunk/ELF/SymbolTable.cpp
@@ -108,6 +108,7 @@
   Obj->parse(DummyGroups);
   for (SymbolBody *Body : Obj->getNonLocalSymbols()) {
     Symbol *Sym = insert(Body);
+    Sym->Body->setUsedInRegularObj();
     if (!Sym->Body->isUndefined() && Body->isUndefined())
       continue;
     Sym->Body = Body;
Index: lld/trunk/ELF/Symbols.h
===================================================================
--- lld/trunk/ELF/Symbols.h
+++ lld/trunk/ELF/Symbols.h
@@ -89,6 +89,8 @@
   bool isInGot() const { return GotIndex != -1U; }
   bool isInPlt() const { return PltIndex != -1U; }
 
+  void setUsedInRegularObj() { IsUsedInRegularObj = true; }
+
   template <class ELFT>
   typename ELFT::uint getVA(typename ELFT::uint Addend = 0) const;
 
@@ -319,7 +321,6 @@
   std::unique_ptr<InputFile> getMember();
 
   void setWeak() { IsWeak = true; }
-  void setUsedInRegularObj() { IsUsedInRegularObj = true; }
 
 private:
   ArchiveFile *File;
Index: lld/trunk/test/ELF/lto/Inputs/shared.s
===================================================================
--- lld/trunk/test/ELF/lto/Inputs/shared.s
+++ lld/trunk/test/ELF/lto/Inputs/shared.s
@@ -0,0 +1,5 @@
+.globl  printf
+printf:
+
+.globl  puts
+puts:
Index: lld/trunk/test/ELF/lto/undefined-puts.ll
===================================================================
--- lld/trunk/test/ELF/lto/undefined-puts.ll
+++ lld/trunk/test/ELF/lto/undefined-puts.ll
@@ -0,0 +1,28 @@
+; REQUIRES: x86
+; RUN: llvm-mc %p/Inputs/shared.s -o %t1.o -filetype=obj -triple=x86_64-unknown-linux
+; RUN: ld.lld %t1.o -o %t1.so -shared
+; RUN: llvm-as %s -o %t2.o
+; RUN: ld.lld %t1.so %t2.o -m elf_x86_64 -o %t
+; RUN: llvm-readobj -dyn-symbols -dyn-relocations %t | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+ at .str = private unnamed_addr constant [6 x i8] c"blah\0A\00", align 1
+
+define i32 @_start() {
+  %str = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0))
+  ret i32 0
+}
+
+declare i32 @printf(i8*, ...)
+
+; Check that puts symbol is present in the dynamic symbol table and
+; there's a relocation for it.
+; CHECK: Dynamic Relocations {
+; CHECK-NEXT:  0x11007 R_X86_64_PC32 puts 0xFFFFFFFFFFFFFFFC
+; CHECK-NEXT: }
+
+; CHECK: DynamicSymbols [
+; CHECK: Symbol {
+; CHECK:    Name: puts@


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18357.51861.patch
Type: text/x-patch
Size: 2507 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160329/e29c0fe7/attachment.bin>


More information about the llvm-commits mailing list