Exemple #1
0
uint64_t
elf_getSectionOffset(void *elfFile, int i)
{
	return ISELF32 (elfFile)
		? elf32_getSectionOffset(elfFile, i)
		: elf64_getSectionOffset(elfFile, i);
}
Exemple #2
0
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;
}
Exemple #3
0
void * elf32_getSectionOffsetNamed(struct Elf32_Header *elfFile, char *str)
{
	for (uint16_t i = 0; i < elf32_getNumSections(elfFile); i++)
	{
		if (strcmp(str, elf32_getSectionName(elfFile, i)) == 0)
			return (void *)(uintptr_t)elf32_getSectionOffset(elfFile, i);
	}

	return NULL;
}
Exemple #4
0
char * elf32_getSectionStringTable(struct Elf32_Header *elfFile)
{
	return (elf32_getStringTableIdx(elfFile) == SHN_UNDEF)
		? NULL
		: (char *)(uintptr_t)elf32_getSectionOffset(elfFile, elf32_getStringTableIdx(elfFile));
}