ELFSection.hxx revision 74f7a939f44d926babd52f59978e6b093e4bb2d0
1#ifndef ELF_SECTION_HXX 2#define ELF_SECTION_HXX 3 4#include "utils/raw_ostream.h" 5 6#include <llvm/Support/raw_ostream.h> 7 8#include "ELFSectionHeader.h" 9#include "ELFSectionStrTab.h" 10#include "ELFSectionSymTab.h" 11#include "ELFSectionProgBits.h" 12#include "ELFSectionNoBits.h" 13#include "ELFSectionRelTable.h" 14 15template <unsigned Bitwidth> 16template <typename Archiver> 17inline ELFSection<Bitwidth> * 18ELFSection<Bitwidth>::read(Archiver &AR, 19 ELFObjectTy *owner, 20 ELFSectionHeaderTy const *sh) { 21 using namespace std; 22 23 switch (sh->getType()) { 24 default: 25 // Uknown type of ELF section. Return NULL. 26 llvm::errs() << "WARNING: Unknown section type.\n"; 27 return 0; 28 29 case SHT_STRTAB: 30 return ELFSectionStrTabTy::read(AR, sh); 31 32 case SHT_SYMTAB: 33 return ELFSectionSymTabTy::read(AR, owner, sh); 34 35 case SHT_PROGBITS: 36 { 37#ifdef __arm__ 38 owner->getStubLayout(); 39#endif 40 return ELFSectionProgBitsTy::read(AR, owner, sh); 41 } 42 43 case SHT_NOBITS: 44 return ELFSectionNoBitsTy::read(AR, sh); 45 46 case SHT_REL: 47 case SHT_RELA: 48 return ELFSectionRelTableTy::read(AR, sh); 49 50 case SHT_NULL: 51 // TODO: Not Yet Implemented 52 return 0; 53 }; 54} 55 56#endif // ELF_SECTION_HXX 57