diff options
author | Sean Silva <chisophugis@gmail.com> | 2016-03-08 23:50:56 +0000 |
---|---|---|
committer | Sean Silva <chisophugis@gmail.com> | 2016-03-08 23:50:56 +0000 |
commit | b284e71e03bf8d5a5274e68b4e4faba3b764af64 (patch) | |
tree | 4b5145d4c3b8ecdb25380405906a69192a6e5f04 | |
parent | bbbe6184678e6c0c159cfff1f24c95508a7708fa (diff) | |
download | bcm5719-llvm-b284e71e03bf8d5a5274e68b4e4faba3b764af64.tar.gz bcm5719-llvm-b284e71e03bf8d5a5274e68b4e4faba3b764af64.zip |
[lto] Don't add variables with private linkage to the symbol table.
Summary:
This causes the issue in PR26872 to go away now that we aren't creating
symbols for the string literals, but that may just be concealing a
deeper problem, so best to keep that PR open.
Reviewers: rafael
Subscribers: Bigcheese, llvm-commits, joker.eph
Differential Revision: http://reviews.llvm.org/D17971
llvm-svn: 262968
-rw-r--r-- | lld/ELF/InputFiles.cpp | 4 | ||||
-rw-r--r-- | lld/test/ELF/lto/linkage.ll | 9 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index c62ff7126ce..96499ea0af2 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -440,10 +440,13 @@ void BitcodeFile::parse(DenseSet<StringRef> &ComdatGroups) { for (const BasicSymbolRef &Sym : Obj->symbols()) { uint8_t Visibility = STV_DEFAULT; const GlobalValue *GV = Obj->getSymbolGV(Sym.getRawDataRefImpl()); + uint32_t Flags = Sym.getFlags(); if (GV) { if (const Comdat *C = GV->getComdat()) if (!KeptComdats.count(C)) continue; + if (!(Flags & object::BasicSymbolRef::SF_Global)) + continue; Visibility = getGvVisibility(GV); } @@ -453,7 +456,6 @@ void BitcodeFile::parse(DenseSet<StringRef> &ComdatGroups) { StringRef NameRef = Saver.save(StringRef(Name)); SymbolBody *Body; - uint32_t Flags = Sym.getFlags(); bool IsWeak = Flags & BasicSymbolRef::SF_Weak; if (Flags & BasicSymbolRef::SF_Undefined) { Body = new (Alloc) Undefined(NameRef, IsWeak, Visibility, false); diff --git a/lld/test/ELF/lto/linkage.ll b/lld/test/ELF/lto/linkage.ll new file mode 100644 index 00000000000..8ed5ddc52bb --- /dev/null +++ b/lld/test/ELF/lto/linkage.ll @@ -0,0 +1,9 @@ +; REQUIRES: x86 +; RUN: llvm-as %s -o %t1.o +; RUN: ld.lld -m elf_x86_64 %t1.o %t1.o -o %t.so -shared + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +; Should not encounter a duplicate symbol error for @.str +@.str = private unnamed_addr constant [4 x i8] c"Hey\00", align 1 |