diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index cf3672c60b9c..3bf9a39b0e20 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -1014,7 +1014,7 @@ template std::vector LazyObjFile::getElfSymbols() { typedef typename ELFT::Sym Elf_Sym; typedef typename ELFT::SymRange Elf_Sym_Range; - const ELFFile Obj(this->MB.getBuffer()); + ELFFile Obj = check(ELFFile::create(this->MB.getBuffer())); ArrayRef Sections = check(Obj.sections(), toString(this)); for (const Elf_Shdr &Sec : Sections) { if (Sec.sh_type != SHT_SYMTAB) diff --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h index 39856de9cd62..00c8ee936aa7 100644 --- a/lld/ELF/InputFiles.h +++ b/lld/ELF/InputFiles.h @@ -128,7 +128,7 @@ public: } llvm::object::ELFFile getObj() const { - return llvm::object::ELFFile(MB.getBuffer()); + return check(llvm::object::ELFFile::create(MB.getBuffer())); } StringRef getStringTable() const { return StringTable; }