uint64_t elf_getSectionSize(void *elfFile, int i) { return ISELF32 (elfFile) ? elf32_getSectionSize(elfFile, i) : elf64_getSectionSize(elfFile, i); }
void *elf32_getSymbolNamed(struct Elf32_Header *elfFile, char *str) { int symTableIdx = elf32_getSymbolTableIdx(elfFile, ".symtab"); char *strTable = (symTableIdx != -1) ? (char *)((uintptr_t)elfFile + (uintptr_t)elf32_getSymbolStrTable(elfFile, symTableIdx)) : NULL; struct Elf32_Sym *symTable = (symTableIdx != -1) ? (struct Elf32_Sym *)((uintptr_t)elfFile + (uintptr_t)elf32_getSectionOffset(elfFile, symTableIdx)) : NULL; if(strTable != NULL && symTable != NULL) { unsigned int nbSym = elf32_getSectionSize(elfFile, symTableIdx) / elf32_getSectionEntsize(elfFile, symTableIdx); for(int i = 0; i < nbSym; i++) { if(strcmp(str, (char *)((uintptr_t)strTable + (uintptr_t)symTable[i].st_name)) == 0) return &(symTable[i]); } } return NULL; }