[lld] r261881 - Add support for weak symbols in LTO.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 25 08:25:41 PST 2016
Author: rafael
Date: Thu Feb 25 10:25:41 2016
New Revision: 261881
URL: http://llvm.org/viewvc/llvm-project?rev=261881&view=rev
Log:
Add support for weak symbols in LTO.
Added:
lld/trunk/test/ELF/lto/weak.ll
Modified:
lld/trunk/ELF/InputFiles.cpp
lld/trunk/ELF/Symbols.cpp
lld/trunk/ELF/Symbols.h
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=261881&r1=261880&r2=261881&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Thu Feb 25 10:25:41 2016
@@ -450,10 +450,12 @@ void BitcodeFile::parse() {
Sym.printName(OS);
StringRef NameRef = Saver.save(StringRef(Name));
SymbolBody *Body;
- if (Sym.getFlags() & BasicSymbolRef::SF_Undefined)
+ uint32_t Flags = Sym.getFlags();
+ if (Flags & BasicSymbolRef::SF_Undefined)
Body = new (Alloc) Undefined(NameRef, false, STV_DEFAULT, false);
else
- Body = new (Alloc) DefinedBitcode(NameRef);
+ Body =
+ new (Alloc) DefinedBitcode(NameRef, Flags & BasicSymbolRef::SF_Weak);
SymbolBodies.push_back(Body);
}
}
Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=261881&r1=261880&r2=261881&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Thu Feb 25 10:25:41 2016
@@ -161,8 +161,8 @@ Defined::Defined(Kind K, StringRef Name,
bool IsTls, bool IsFunction)
: SymbolBody(K, Name, IsWeak, Visibility, IsTls, IsFunction) {}
-DefinedBitcode::DefinedBitcode(StringRef Name)
- : Defined(DefinedBitcodeKind, Name, false, STV_DEFAULT, false, false) {}
+DefinedBitcode::DefinedBitcode(StringRef Name, bool IsWeak)
+ : Defined(DefinedBitcodeKind, Name, IsWeak, STV_DEFAULT, false, false) {}
bool DefinedBitcode::classof(const SymbolBody *S) {
return S->kind() == DefinedBitcodeKind;
Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=261881&r1=261880&r2=261881&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Thu Feb 25 10:25:41 2016
@@ -190,7 +190,7 @@ public:
class DefinedBitcode : public Defined {
public:
- DefinedBitcode(StringRef Name);
+ DefinedBitcode(StringRef Name, bool IsWeak);
static bool classof(const SymbolBody *S);
};
Added: lld/trunk/test/ELF/lto/weak.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/weak.ll?rev=261881&view=auto
==============================================================================
--- lld/trunk/test/ELF/lto/weak.ll (added)
+++ lld/trunk/test/ELF/lto/weak.ll Thu Feb 25 10:25:41 2016
@@ -0,0 +1,16 @@
+; REQUIRES: x86
+; RUN: llvm-as %s -o %t.o
+; RUN: ld.lld -m elf_x86_64 %t.o %t.o -o %t.so -shared
+; RUN: llvm-readobj -t %t.so | FileCheck %s
+
+target triple = "x86_64-unknown-linux-gnu"
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+define weak void @f() {
+ ret void
+}
+
+; CHECK: Name: f
+; CHECK-NEXT: Value: 0x1000
+; CHECK-NEXT: Size: 1
+; CHECK-NEXT: Binding: Weak
More information about the llvm-commits
mailing list