llvm.org GIT mirror llvm / db8cb22
This only needs a StringRef. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212371 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 5 years ago
3 changed file(s) with 13 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
3939
4040 // Subclasses of ELFFile may need this for template instantiation
4141 inline std::pair
42 getElfArchType(MemoryBuffer *Object) {
43 if (Object->getBufferSize() < ELF::EI_NIDENT)
42 getElfArchType(StringRef Object) {
43 if (Object.size() < ELF::EI_NIDENT)
4444 return std::make_pair((uint8_t)ELF::ELFCLASSNONE,(uint8_t)ELF::ELFDATANONE);
45 return std::make_pair((uint8_t) Object->getBufferStart()[ELF::EI_CLASS],
46 (uint8_t) Object->getBufferStart()[ELF::EI_DATA]);
45 return std::make_pair((uint8_t)Object.begin()[ELF::EI_CLASS],
46 (uint8_t)Object.begin()[ELF::EI_DATA]);
4747 }
4848
4949 template
229229 typedef SmallVector Sections_t;
230230 typedef DenseMap IndexMap_t;
231231
232 MemoryBuffer *Buf;
232 StringRef Buf;
233233
234234 const uint8_t *base() const {
235 return reinterpret_cast(Buf->getBufferStart());
235 return reinterpret_cast(Buf.begin());
236236 }
237237
238238 const Elf_Ehdr *Header;
316316 std::pair
317317 getRelocationSymbol(const Elf_Shdr *RelSec, const RelT *Rel) const;
318318
319 ELFFile(MemoryBuffer *Object, std::error_code &ec);
319 ELFFile(StringRef Object, std::error_code &ec);
320320
321321 bool isMipsELF64() const {
322322 return Header->e_machine == ELF::EM_MIPS &&
535535 template
536536 ErrorOr >
537537 ELFFile::getSectionContents(const Elf_Shdr *Sec) const {
538 if (Sec->sh_offset + Sec->sh_size > Buf->getBufferSize())
538 if (Sec->sh_offset + Sec->sh_size > Buf.size())
539539 return object_error::parse_failed;
540540 const uint8_t *Start = base() + Sec->sh_offset;
541541 return ArrayRef(Start, Sec->sh_size);
620620 }
621621
622622 template
623 ELFFile::ELFFile(MemoryBuffer *Object, std::error_code &ec)
623 ELFFile::ELFFile(StringRef Object, std::error_code &ec)
624624 : Buf(Object), SectionHeaderTable(nullptr), dot_shstrtab_sec(nullptr),
625625 dot_strtab_sec(nullptr), dot_symtab_sec(nullptr),
626626 SymbolTableSectionHeaderIndex(nullptr), dot_gnu_version_sec(nullptr),
627627 dot_gnu_version_r_sec(nullptr), dot_gnu_version_d_sec(nullptr),
628628 dt_soname(nullptr) {
629 const uint64_t FileSize = Buf->getBufferSize();
629 const uint64_t FileSize = Buf.size();
630630
631631 if (sizeof(Elf_Ehdr) > FileSize)
632632 // FIXME: Proper error handling.
778778 support::little,
779779 ELFT::Is64Bits),
780780 std::move(Object)),
781 EF(Data.get(), EC) {}
781 EF(Data->getBuffer(), EC) {}
782782
783783 template
784784 basic_symbol_iterator ELFObjectFile::symbol_begin_impl() const {
1818
1919 ErrorOr
2020 ObjectFile::createELFObjectFile(std::unique_ptr &Obj) {
21 std::pair Ident = getElfArchType(Obj.get());
21 std::pair Ident =
22 getElfArchType(Obj->getBuffer());
2223 std::size_t MaxAlignment =
2324 1ULL << countTrailingZeros(uintptr_t(Obj->getBufferStart()));
2425