@@ -211,8 +211,9 @@ template <class ELFT> class ELFObjectFile : public ELFObjectFileBase {
211
211
using Elf_Dyn = typename ELFFile<ELFT>::Elf_Dyn;
212
212
213
213
private:
214
- ELFObjectFile (MemoryBufferRef Object, const Elf_Shdr *DotDynSymSec,
215
- const Elf_Shdr *DotSymtabSec, ArrayRef<Elf_Word> ShndxTable);
214
+ ELFObjectFile (MemoryBufferRef Object, ELFFile<ELFT> EF,
215
+ const Elf_Shdr *DotDynSymSec, const Elf_Shdr *DotSymtabSec,
216
+ ArrayRef<Elf_Word> ShndxTable);
216
217
217
218
protected:
218
219
ELFFile<ELFT> EF;
@@ -851,7 +852,10 @@ ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
851
852
template <class ELFT >
852
853
Expected<ELFObjectFile<ELFT>>
853
854
ELFObjectFile<ELFT>::create(MemoryBufferRef Object) {
854
- ELFFile<ELFT> EF (Object.getBuffer ());
855
+ auto EFOrErr = ELFFile<ELFT>::create (Object.getBuffer ());
856
+ if (Error E = EFOrErr.takeError ())
857
+ return std::move (E);
858
+ auto EF = std::move (*EFOrErr);
855
859
856
860
auto SectionsOrErr = EF.sections ();
857
861
if (!SectionsOrErr)
@@ -883,24 +887,25 @@ ELFObjectFile<ELFT>::create(MemoryBufferRef Object) {
883
887
}
884
888
}
885
889
}
886
- return ELFObjectFile<ELFT>(Object, DotDynSymSec, DotSymtabSec, ShndxTable);
890
+ return ELFObjectFile<ELFT>(Object, EF, DotDynSymSec, DotSymtabSec,
891
+ ShndxTable);
887
892
}
888
893
889
894
template <class ELFT >
890
- ELFObjectFile<ELFT>::ELFObjectFile(MemoryBufferRef Object,
895
+ ELFObjectFile<ELFT>::ELFObjectFile(MemoryBufferRef Object, ELFFile<ELFT> EF,
891
896
const Elf_Shdr *DotDynSymSec,
892
897
const Elf_Shdr *DotSymtabSec,
893
898
ArrayRef<Elf_Word> ShndxTable)
894
899
: ELFObjectFileBase(
895
900
getELFType (ELFT::TargetEndianness == support::little, ELFT::Is64Bits),
896
901
Object),
897
- EF(Data.getBuffer()) , DotDynSymSec(DotDynSymSec),
898
- DotSymtabSec(DotSymtabSec), ShndxTable(ShndxTable) {}
902
+ EF(EF) , DotDynSymSec(DotDynSymSec), DotSymtabSec(DotSymtabSec ),
903
+ ShndxTable(ShndxTable) {}
899
904
900
905
template <class ELFT >
901
906
ELFObjectFile<ELFT>::ELFObjectFile(ELFObjectFile<ELFT> &&Other)
902
- : ELFObjectFile(Other.Data, Other.DotDynSymSec , Other.DotSymtabSec ,
903
- Other.ShndxTable) {}
907
+ : ELFObjectFile(Other.Data, Other.EF , Other.DotDynSymSec ,
908
+ Other.DotSymtabSec, Other. ShndxTable) {}
904
909
905
910
template <class ELFT >
906
911
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin() const {
0 commit comments