Hi, Thanks for your code, these days, I have a project to need load the elf file for my arm product, it is base the MTK sdk without MMU.
but when I read your code, somewhere I can't understand. Like this function:
char name[33] = "<unnamed>";
int symEntry = ELF32_R_SYM(rel.r_info);
int relType = ELF32_R_TYPE(rel.r_info);
Elf32_Addr relAddr = ((Elf32_Addr) s->data) + rel.r_offset;
readSymbol(e, symEntry, &sym, name, sizeof(name));
DBG(" %08X %08X %-16s %s\n", rel.r_offset, rel.r_info, typeStr(relType),
name);
symAddr = addressOf(e, &sym, name);
if (symAddr != 0xffffffff) {
DBG(" symAddr=%08X relAddr=%08X\n", symAddr, relAddr);
if (relocateSymbol(relAddr, relType, symAddr) == -1)
return -1;
} else {
DBG(" No symbol address of %s\n", name);
return -1;
}
}
}
return 0;
it is like the text. data. bass section is all the same struct with the struct below.
typedef struct
{
Elf32_Addr r_offset;
Elf32_Word r_info;
} Elf32_Rel;
I read my elf file,
data like this picture, it is ER_RO section, so ,how I relocate this ? I can't understand this format!
thank you!