Skip to content

Commit

Permalink
Merge r367599 - [COFF] Fix wholearchive with thin archives (PR42388, …
Browse files Browse the repository at this point in the history
…D65565)

llvm-svn: 367806
  • Loading branch information
zmodem committed Aug 5, 2019
1 parent 8aaba9f commit 6c8e44e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lld/COFF/Driver.cpp
Expand Up @@ -184,8 +184,10 @@ void LinkerDriver::addBuffer(std::unique_ptr<MemoryBuffer> mb,
if (wholeArchive) {
std::unique_ptr<Archive> file =
CHECK(Archive::create(mbref), filename + ": failed to parse archive");
Archive *archive = file.get();
make<std::unique_ptr<Archive>>(std::move(file)); // take ownership

for (MemoryBufferRef m : getArchiveMembers(file.get()))
for (MemoryBufferRef m : getArchiveMembers(archive))
addArchiveBuffer(m, "<whole-archive>", filename, 0);
return;
}
Expand Down
9 changes: 9 additions & 0 deletions lld/test/COFF/Inputs/mangled-symbol.s
@@ -0,0 +1,9 @@
.text

.def "?f@@YAHXZ"
.scl 2
.type 32
.endef
.global "?f@@YAHXZ"
"?f@@YAHXZ":
retq $0
32 changes: 32 additions & 0 deletions lld/test/COFF/thin-archive.s
@@ -0,0 +1,32 @@
# REQUIRES: x86

# RUN: llvm-mc -filetype=obj -triple=x86_64-windows-msvc -o %t.main.obj %s

# RUN: llvm-mc -filetype=obj -triple=x86_64-windows-msvc -o %t.lib.obj \
# RUN: %S/Inputs/mangled-symbol.s
# RUN: lld-link /lib /out:%t.lib %t.lib.obj
# RUN: lld-link /lib /llvmlibthin /out:%t_thin.lib %t.lib.obj

# RUN: lld-link /entry:main %t.main.obj %t.lib /out:%t.exe 2>&1 | \
# RUN: FileCheck --allow-empty %s
# RUN: lld-link /entry:main %t.main.obj %t_thin.lib /out:%t.exe 2>&1 | \
# RUN: FileCheck --allow-empty %s
# RUN: lld-link /entry:main %t.main.obj /wholearchive:%t_thin.lib /out:%t.exe 2>&1 | \
# RUN: FileCheck --allow-empty %s

# RUN: rm %t.lib.obj
# RUN: lld-link /entry:main %t.main.obj %t.lib /out:%t.exe 2>&1 | \
# RUN: FileCheck --allow-empty %s

# CHECK-NOT: error: could not get the buffer for the member defining

.text

.def main
.scl 2
.type 32
.endef
.global main
main:
call "?f@@YAHXZ"
retq $0

0 comments on commit 6c8e44e

Please sign in to comment.