From 5f2c46d62e49aa6950639b35c8af2b005e91aa45 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 23 Dec 2015 01:06:39 +0000 Subject: [PATCH] Fix two asan found bugs: We were leaking InputFile subclasses data. UndefinedElf was missing a classof. llvm-svn: 256309 --- lld/ELF/InputFiles.cpp | 2 ++ lld/ELF/InputFiles.h | 1 + lld/ELF/Symbols.h | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 62d9e671ef83..909f69ee2bc2 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -31,6 +31,8 @@ public: }; } +InputFile::~InputFile() {} + template ELFFileBase::ELFFileBase(Kind K, MemoryBufferRef M) : InputFile(K, M), ELFObj(MB.getBuffer(), ECRAII().getEC()) {} diff --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h index 95c8f0f5128b..ba7d51ba00b0 100644 --- a/lld/ELF/InputFiles.h +++ b/lld/ELF/InputFiles.h @@ -35,6 +35,7 @@ class InputFile { public: enum Kind { ObjectKind, SharedKind, ArchiveKind }; Kind kind() const { return FileKind; } + virtual ~InputFile(); StringRef getName() const { return MB.getBufferIdentifier(); } diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h index b60e4a29f631..88991924a698 100644 --- a/lld/ELF/Symbols.h +++ b/lld/ELF/Symbols.h @@ -270,6 +270,10 @@ template class UndefinedElf : public Undefined { public: UndefinedElf(StringRef N, const Elf_Sym &Sym); const Elf_Sym &Sym; + + static bool classof(const SymbolBody *S) { + return S->kind() == SymbolBody::UndefinedElfKind; + } }; template class SharedSymbol : public Defined {