23 extern volatile unsigned char *uart3;
26 : m_pHeader(0), m_pSymbolTable(0), m_pStringTable(0), m_pShstrtab(0),
27 m_pGotTable(0), m_pRelTable(0), m_pSectionHeaders(0), m_pBuffer(0)
29 StringCopyN(m_pId, name, 127);
36 bool Elf32::load(uint8_t *pBuffer,
unsigned int nBufferLength)
42 if ((m_pHeader->ident[1] !=
'E') || (m_pHeader->ident[2] !=
'L') ||
43 (m_pHeader->ident[3] !=
'F') || (m_pHeader->ident[0] != 127))
54 m_pStringTable = &m_pSectionHeaders[m_pHeader->shstrndx];
58 reinterpret_cast<const char *
>(&pBuffer[m_pStringTable->offset]);
61 for (
int i = 0; i < m_pHeader->shnum; i++)
63 const char *pStr = pStrtab + m_pSectionHeaders[i].name;
64 if (!StringCompare(pStr,
".symtab"))
66 m_pSymbolTable = &m_pSectionHeaders[i];
68 if (!StringCompare(pStr,
".strtab"))
69 m_pStringTable = &m_pSectionHeaders[i];
121 for (
int i = 0; i < m_pHeader->shnum; i++)
123 if (m_pSectionHeaders[i].flags & SHF_ALLOC)
125 if (m_pSectionHeaders[i].type != SHT_NOBITS)
129 (uint8_t *) m_pSectionHeaders[i].addr,
131 m_pSectionHeaders[i].size);
136 (uint8_t *) m_pSectionHeaders[i].addr, 0,
137 m_pSectionHeaders[i].size);
154 if (!m_pSymbolTable || !m_pStringTable)
160 const char *pStrtab =
161 reinterpret_cast<const char *
>(&
m_pBuffer[m_pStringTable->offset]);
163 for (
size_t i = 0; i < m_pSymbolTable->size /
sizeof(
Elf32Symbol_t); i++)
166 if (ELF32_ST_TYPE(pSymbol->info) != 0x2 &&
167 ELF32_ST_TYPE(pSymbol->info) != 0x0 )
175 uint32_t size = pSymbol->size;
178 if ((addr >= pSymbol->value) && (addr < (pSymbol->value + size)))
180 const char *pStr = pStrtab + pSymbol->name;
182 *startAddr = pSymbol->value;
187 return (
const char *) 3;
207 return m_pHeader->entry;
unsigned int getLastAddress()
uint32_t getGlobalOffsetTable()
const char * lookupSymbol(unsigned int addr, unsigned int *startAddr=0)
char * lookupDynamicSymbolName(uint32_t off)
uint32_t lookupDynamicSymbolAddress(uint32_t off)
uint8_t * m_pBuffer
Offset of the file in memory.
bool load(uint8_t *pBuffer, unsigned int nBufferLength)