[COFF] Fix wholearchive with thin archives
authorMartin Storsjo <martin@martin.st>
Thu, 1 Aug 2019 18:47:27 +0000 (18:47 +0000)
committerMartin Storsjo <martin@martin.st>
Thu, 1 Aug 2019 18:47:27 +0000 (18:47 +0000)
commit90b4388f5612f3088b15a351a0ad421f312fbabb
tree9596572f9af099aad6c765ec76943b239b9f9384
parentbb582ebdba0e85b3ef1661d9ea0bd824f55c32ae
[COFF] Fix wholearchive with thin archives

The Archive object created when loading an archive specified with
wholearchive got cleaned up immediately, when the owning std::unique_ptr
went out of scope, even if persisted StringRefs pointed to memory that
belonged to the archive, which no longer was mapped in memory.

This hasn't been an issue with regular (as opposed to thin) archives,
as references to the member objects has kept the mapping for the whole
archive file alive - but with thin archives, all such references point
to other files.

Add the std::unique_ptr to the arena allocator, to retain it as long
as necessary.

This fixes (the last issue raised in) PR42388.

Differential Revision: https://reviews.llvm.org/D65565

llvm-svn: 367599
lld/COFF/Driver.cpp
lld/test/COFF/thin-archive.s