7 #if !defined(_StELFFile_h_) 45 typedef std::vector<Elf32_Shdr>::const_iterator const_section_iterator;
46 typedef std::vector<Elf32_Phdr>::const_iterator const_segment_iterator;
65 virtual void setName(
const std::string &inName) {
m_name = inName; }
66 virtual std::string getName()
const {
return m_name; }
83 inline const_section_iterator getSectionBegin()
const {
return m_sectionHeaders.begin(); }
84 inline const_section_iterator getSectionEnd()
const {
return m_sectionHeaders.end(); }
103 inline const_segment_iterator getSegmentBegin()
const {
return m_programHeaders.begin(); }
104 inline const_segment_iterator getSegmentEnd()
const {
return m_programHeaders.end(); }
119 std::string
getStringAtIndex(
unsigned inStringTableSectionIndex,
unsigned inStringIndex);
140 ARMSymbolType_t getTypeOfSymbolAtIndex(
unsigned symbolIndex);
146 void dumpSymbolTable();
167 typedef std::map<unsigned, SectionDataInfo> SectionDataMap;
191 :
std::runtime_error(inMessage)
196 #endif // _StELFFile_h_ Elf32_Ehdr m_header
The ELF file header.
Definition: apps/elftosb/common/StELFFile.h:153
ELF section header.
Definition: apps/elftosb/common/ELF.h:135
uint8_t * getSectionDataAtIndex(unsigned inIndex)
Returns the data for the section.
Definition: apps/elftosb/common/StELFFile.cpp:182
Definition: apps/elftosb/common/StELFFile.h:161
SectionDataMap m_sectionDataCache
Cached data of sections.
Definition: apps/elftosb/common/StELFFile.h:168
ELFVariant_t m_elfVariant
Variant of the ARM ELF format specification.
Definition: apps/elftosb/common/StELFFile.h:151
unsigned getSymbolCount()
Returns the number of symbols in the default ".symtab" symbol table.
Definition: apps/elftosb/common/StELFFile.cpp:348
unsigned getIndexOfSectionWithName(const std::string &inName)
Returns the index of the section with the name inName.
Definition: apps/elftosb/common/StELFFile.cpp:154
SectionDataInfo & getCachedSectionData(unsigned inSectionIndex)
Reads a section's data either from cache or from disk.
Definition: apps/elftosb/common/StELFFile.cpp:326
void byteSwapSymbolTable(const Elf32_Shdr &header, SectionDataInfo &info)
Byte swaps the symbol table data into host endianness.
Definition: apps/elftosb/common/StELFFile.cpp:381
void readFileHeaders()
Reads the file, section, and program headers into memory.
Definition: apps/elftosb/common/StELFFile.cpp:38
std::vector< Elf32_Shdr > m_sectionHeaders
All of the section headers.
Definition: apps/elftosb/common/StELFFile.h:154
uint8_t * getSectionData(const_section_iterator inSection)
Returns the data for the section.
Definition: apps/elftosb/common/StELFFile.cpp:196
const Elf32_Phdr & getSegmentAtIndex(unsigned inIndex) const
Returns a reference to the given segment.
Definition: apps/elftosb/common/StELFFile.cpp:230
uint8_t * readSectionData(const Elf32_Shdr &inHeader)
Definition: apps/elftosb/common/StELFFile.cpp:203
virtual void setELFVariant(ELFVariant_t variant)
Set the ELF format variation to either #eARMVariant or #eGHSVariant.
Definition: apps/elftosb/common/StELFFile.h:60
virtual ELFVariant_t ELFVariant()
Return the ELF format variant to which this file is set.
Definition: apps/elftosb/common/StELFFile.h:58
unsigned getSymbolNameStringTableIndex() const
Returns the section index of the string table containing symbol names.
Definition: apps/elftosb/common/StELFFile.cpp:400
std::istream & m_stream
The source stream for the ELF file.
Definition: apps/elftosb/common/StELFFile.h:150
ELF program header.
Definition: apps/elftosb/common/ELF.h:223
unsigned m_symbolTableIndex
Index of ".symtab" section, or #SHN_UNDEF if not present.
Definition: apps/elftosb/common/StELFFile.h:156
ELF symbol table entry.
Definition: apps/elftosb/common/ELF.h:277
StELFFile(std::istream &inStream)
Constructor.
Definition: apps/elftosb/common/StELFFile.cpp:16
uint8_t * getSegmentData(const_segment_iterator inSegment)
Returns the data of the specified segment.
Definition: apps/elftosb/common/StELFFile.cpp:261
virtual ~StELFFile()
Destructor.
Definition: apps/elftosb/common/StELFFile.cpp:23
uint8_t * readSegmentData(const Elf32_Phdr &inHeader)
Definition: apps/elftosb/common/StELFFile.cpp:268
const Elf32_Ehdr & getFileHeader() const
Returns the ELF file header.
Definition: apps/elftosb/common/StELFFile.h:72
const Elf32_Shdr & getSectionAtIndex(unsigned inIndex) const
Returns a reference to section number inIndex.
Definition: apps/elftosb/common/StELFFile.cpp:144
bool m_swapped
Has this section been byte swapped yet? Used for symbol table.
Definition: apps/elftosb/common/StELFFile.h:165
uint8_t * getSegmentDataAtIndex(unsigned inIndex)
Returns the data of the specified segment.
Definition: apps/elftosb/common/StELFFile.cpp:247
ELF file header.
Definition: apps/elftosb/common/ELF.h:61
std::string getSectionNameAtIndex(unsigned inIndex)
Returns a string from the file's section name string table.
Definition: apps/elftosb/common/StELFFile.cpp:299
unsigned getSectionCount() const
Returns the number of sections in the file.
Definition: apps/elftosb/common/StELFFile.h:79
Simple exception thrown to indicate an error in the input ELF file format.
Definition: apps/elftosb/common/StELFFile.h:186
std::string m_name
File name. (optional)
Definition: apps/elftosb/common/StELFFile.h:152
Parser for Executable and Linking Format (ELF) files.
Definition: apps/elftosb/common/StELFFile.h:42
std::string getStringAtIndex(unsigned inStringTableSectionIndex, unsigned inStringIndex)
Returns a string from any string table in the object file.
Definition: apps/elftosb/common/StELFFile.cpp:311
StELFFileException(const std::string &inMessage)
Default constructor.
Definition: apps/elftosb/common/StELFFile.h:190
unsigned m_size
Section data size in bytes.
Definition: apps/elftosb/common/StELFFile.h:164
unsigned getIndexOfSymbolAtAddress(uint32_t symbolAddress, bool strict=true)
Returns STN_UNDEF if it cannot find a symbol at the given symbolAddress.
Definition: apps/elftosb/common/StELFFile.cpp:413
std::vector< Elf32_Phdr > m_programHeaders
All of the program headers.
Definition: apps/elftosb/common/StELFFile.h:155
unsigned getSegmentCount() const
Returns the number of segments, or program headers, in the file.
Definition: apps/elftosb/common/StELFFile.h:99
const Elf32_Sym & getSymbolAtIndex(unsigned inIndex)
Returns the symbol with index inIndex.
Definition: apps/elftosb/common/StELFFile.cpp:359
std::string getSymbolName(const Elf32_Sym &inSymbol)
Returns the name of the symbol described by inSymbol.
Definition: apps/elftosb/common/StELFFile.cpp:406
uint8_t * m_data
Pointer to section data.
Definition: apps/elftosb/common/StELFFile.h:163