Index: ELF/Driver.cpp =================================================================== --- ELF/Driver.cpp +++ ELF/Driver.cpp @@ -984,7 +984,7 @@ if (isa(File)) return File->getName(); if (!File->ArchiveName.empty()) - return File->ArchiveName; + return StringRef(File->ArchiveName); return None; } Index: ELF/InputFiles.h =================================================================== --- ELF/InputFiles.h +++ ELF/InputFiles.h @@ -98,7 +98,7 @@ // Filename of .a which contained this file. If this file was // not in an archive file, it is the empty string. We use this // string for creating error messages. - StringRef ArchiveName; + std::string ArchiveName; // If this is an architecture-specific file, the following members // have ELF type (i.e. ELF{32,64}{LE,BE}) and target machine type. Index: ELF/InputSection.cpp =================================================================== --- ELF/InputSection.cpp +++ ELF/InputSection.cpp @@ -277,7 +277,7 @@ std::string Archive; if (!File->ArchiveName.empty()) - Archive = (" in archive " + File->ArchiveName).str(); + Archive = " in archive " + File->ArchiveName; // Find a symbol that encloses a given location. for (Symbol *B : File->getSymbols()) Index: test/ELF/Inputs/whole-archive-name.s =================================================================== --- /dev/null +++ test/ELF/Inputs/whole-archive-name.s @@ -0,0 +1,3 @@ +.global foo +foo: + nop Index: test/ELF/whole-archive-name.s =================================================================== --- /dev/null +++ test/ELF/whole-archive-name.s @@ -0,0 +1,15 @@ +// REQUIRES: x86 +// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \ +// RUN: %p/Inputs/whole-archive-name.s -o %tfoo.o +// RUN: mkdir -p %t.dir +// RUN: rm -f %t.dir/libfoo.a +// RUN: llvm-ar rcs %t.dir/libfoo.a %tfoo.o +// RUN: ld.lld -L%t.dir %t.o --whole-archive -lfoo -o %t -Map=- | tee %t.map | FileCheck %s + +.globl _start, foo +_start: + call foo + +// CHECK: libfoo.a(whole-archive-name.s.tmpfoo.o):(.text) +// CHECK-NEXT: foo