OLD | NEW |
1 //===- ELF.h - ELF object file implementation -------------------*- C++ -*-===// | 1 //===- ELF.h - ELF object file implementation -------------------*- C++ -*-===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This file declares the ELFObjectFile template class. | 10 // This file declares the ELFObjectFile template class. |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 virtual StringRef getLoadName() const; | 477 virtual StringRef getLoadName() const; |
478 | 478 |
479 uint64_t getNumSections() const; | 479 uint64_t getNumSections() const; |
480 uint64_t getStringTableIndex() const; | 480 uint64_t getStringTableIndex() const; |
481 ELF::Elf64_Word getSymbolTableIndex(const Elf_Sym *symb) const; | 481 ELF::Elf64_Word getSymbolTableIndex(const Elf_Sym *symb) const; |
482 const Elf_Shdr *getSection(const Elf_Sym *symb) const; | 482 const Elf_Shdr *getSection(const Elf_Sym *symb) const; |
483 | 483 |
484 // Methods for type inquiry through isa, cast, and dyn_cast | 484 // Methods for type inquiry through isa, cast, and dyn_cast |
485 bool isDyldType() const { return isDyldELFObject; } | 485 bool isDyldType() const { return isDyldELFObject; } |
486 static inline bool classof(const Binary *v) { | 486 static inline bool classof(const Binary *v) { |
487 return v->getType() == Binary::isELF; | 487 return v->getType() == getELFType(target_endianness == support::little, |
| 488 is64Bits); |
488 } | 489 } |
489 static inline bool classof(const ELFObjectFile *v) { return true; } | 490 static inline bool classof(const ELFObjectFile *v) { return true; } |
490 }; | 491 }; |
491 | 492 |
492 template<support::endianness target_endianness, bool is64Bits> | 493 template<support::endianness target_endianness, bool is64Bits> |
493 void ELFObjectFile<target_endianness, is64Bits> | 494 void ELFObjectFile<target_endianness, is64Bits> |
494 ::validateSymbol(DataRefImpl Symb) const { | 495 ::validateSymbol(DataRefImpl Symb) const { |
495 const Elf_Sym *symb = getSymbol(Symb); | 496 const Elf_Sym *symb = getSymbol(Symb); |
496 const Elf_Shdr *SymbolTableSection = SymbolTableSections[Symb.d.b]; | 497 const Elf_Shdr *SymbolTableSection = SymbolTableSections[Symb.d.b]; |
497 // FIXME: We really need to do proper error handling in the case of an invalid | 498 // FIXME: We really need to do proper error handling in the case of an invalid |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 ::VerifyStrTab(const Elf_Shdr *sh) const { | 1251 ::VerifyStrTab(const Elf_Shdr *sh) const { |
1251 const char *strtab = (const char*)base() + sh->sh_offset; | 1252 const char *strtab = (const char*)base() + sh->sh_offset; |
1252 if (strtab[sh->sh_size - 1] != 0) | 1253 if (strtab[sh->sh_size - 1] != 0) |
1253 // FIXME: Proper error handling. | 1254 // FIXME: Proper error handling. |
1254 report_fatal_error("String table must end with a null terminator!"); | 1255 report_fatal_error("String table must end with a null terminator!"); |
1255 } | 1256 } |
1256 | 1257 |
1257 template<support::endianness target_endianness, bool is64Bits> | 1258 template<support::endianness target_endianness, bool is64Bits> |
1258 ELFObjectFile<target_endianness, is64Bits>::ELFObjectFile(MemoryBuffer *Object | 1259 ELFObjectFile<target_endianness, is64Bits>::ELFObjectFile(MemoryBuffer *Object |
1259 , error_code &ec) | 1260 , error_code &ec) |
1260 : ObjectFile(Binary::isELF, Object, ec) | 1261 : ObjectFile(getELFType(target_endianness == support::little, is64Bits), |
| 1262 Object, ec) |
1261 , isDyldELFObject(false) | 1263 , isDyldELFObject(false) |
1262 , SectionHeaderTable(0) | 1264 , SectionHeaderTable(0) |
1263 , dot_shstrtab_sec(0) | 1265 , dot_shstrtab_sec(0) |
1264 , dot_strtab_sec(0) | 1266 , dot_strtab_sec(0) |
1265 , dot_dynstr_sec(0) | 1267 , dot_dynstr_sec(0) |
1266 , dot_dynamic_sec(0) | 1268 , dot_dynamic_sec(0) |
1267 , dt_soname(0) { | 1269 , dt_soname(0) { |
1268 | 1270 |
1269 const uint64_t FileSize = Data->getBufferSize(); | 1271 const uint64_t FileSize = Data->getBufferSize(); |
1270 | 1272 |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1818 template<support::endianness target_endianness, bool is64Bits> | 1820 template<support::endianness target_endianness, bool is64Bits> |
1819 inline DataRefImpl DynRefImpl<target_endianness, is64Bits> | 1821 inline DataRefImpl DynRefImpl<target_endianness, is64Bits> |
1820 ::getRawDataRefImpl() const { | 1822 ::getRawDataRefImpl() const { |
1821 return DynPimpl; | 1823 return DynPimpl; |
1822 } | 1824 } |
1823 | 1825 |
1824 } | 1826 } |
1825 } | 1827 } |
1826 | 1828 |
1827 #endif | 1829 #endif |
OLD | NEW |