Index: ELF/InputFiles.cpp =================================================================== --- ELF/InputFiles.cpp +++ ELF/InputFiles.cpp @@ -444,6 +444,8 @@ if (const Comdat *C = GV->getComdat()) if (!KeptComdats.count(C)) continue; + if (GV->getLinkage() == GlobalValue::PrivateLinkage) + continue; Visibility = getGvVisibility(GV); } Index: test/ELF/lto/Inputs/linkage.ll =================================================================== --- /dev/null +++ test/ELF/lto/Inputs/linkage.ll @@ -0,0 +1,4 @@ +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +@.str = private unnamed_addr constant [4 x i8] c"Hey\00", align 1 Index: test/ELF/lto/linkage.ll =================================================================== --- /dev/null +++ test/ELF/lto/linkage.ll @@ -0,0 +1,11 @@ +; REQUIRES: x86 +; RUN: llvm-as %s -o %t1.o +; RUN: llvm-as %p/Inputs/linkage.ll -o %t2.o +; RUN: ld.lld -m elf_x86_64 %t1.o %t2.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