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.

llvm-svn: 260592
This commit is contained in:
Rui Ueyama 2016-02-11 21:18:01 +00:00
parent 717677af35
commit c1c282a04e
3 changed files with 4 additions and 3 deletions

View File

@ -294,7 +294,8 @@ void LinkerDriver::createFiles(opt::InputArgList &Args) {
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) {

View File

@ -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);

View File

@ -100,7 +100,7 @@ typename llvm::object::ELFFile<ELFT>::uintX_t getMipsGpAddr();
template <class ELFT> bool isGnuIFunc(const SymbolBody &S);
extern std::unique_ptr<TargetInfo> Target;
extern TargetInfo *Target;
TargetInfo *createTarget();
}
}