[lld] r260592 - ELF: Release Target at end of link().
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 11 13:18:02 PST 2016
Author: ruiu
Date: Thu Feb 11 15:18:01 2016
New Revision: 260592
URL: http://llvm.org/viewvc/llvm-project?rev=260592&view=rev
Log:
ELF: Release Target at end of link().
Previously, Target held a value until a new value is assigned to the
variable. That was a benign leak -- that was not an unbounded leak
and didn't grab any resources except a small amount of memory. But
it is better to fix than leaving as is.
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/Target.cpp
lld/trunk/ELF/Target.h
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=260592&r1=260591&r2=260592&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Thu Feb 11 15:18:01 2016
@@ -294,7 +294,8 @@ void LinkerDriver::createFiles(opt::Inpu
template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) {
SymbolTable<ELFT> Symtab;
- Target.reset(createTarget());
+ std::unique_ptr<TargetInfo> TI(createTarget());
+ Target = TI.get();
Script->finalize();
if (!Config->Shared) {
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=260592&r1=260591&r2=260592&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Thu Feb 11 15:18:01 2016
@@ -33,7 +33,7 @@ using namespace llvm::ELF;
namespace lld {
namespace elf2 {
-std::unique_ptr<TargetInfo> Target;
+TargetInfo *Target;
template <endianness E> static void add32(void *P, int32_t V) {
write32<E>(P, read32<E>(P) + V);
Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=260592&r1=260591&r2=260592&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Thu Feb 11 15:18:01 2016
@@ -100,7 +100,7 @@ typename llvm::object::ELFFile<ELFT>::ui
template <class ELFT> bool isGnuIFunc(const SymbolBody &S);
-extern std::unique_ptr<TargetInfo> Target;
+extern TargetInfo *Target;
TargetInfo *createTarget();
}
}
More information about the llvm-commits
mailing list