Exemplo n.º 1
0
static Bool elf_load_sec_rel(Elf32_Ehdr *hdr) {
	Elf32_Shdr *shdr = elf_sheader(hdr);

	unsigned int i, idx;

	for(i = 0; i < hdr->e_shnum; i++) {
		Elf32_Shdr *section = &shdr[i];

		if(section->sh_type == SHT_REL) {
			printf("Relocation entries\n");
			for(idx = 0; idx < section->sh_size / section->sh_entsize; idx++) {
				Elf32_Rel *reltab = &((Elf32_Rel *)((int)hdr + section->sh_offset))[idx];
					printf("%#X   %#X\n",reltab->r_offset,reltab->r_info);
					//@TODO Process each entry in relocation table
				}
			}
		}
	return true;
}
Exemplo n.º 2
0
static Bool elf_load_sec(Elf32_Ehdr *elf32_hdr)
{
	Elf32_Shdr *shdr = elf_sheader(elf32_hdr);
	unsigned int i;
	for(i=0; i < elf32_hdr->e_shnum; i++){
		Elf32_Shdr *section = &shdr[i];
		if(section->sh_type == SHT_NOBITS){

			if(!section->sh_size) continue;

			if(section->sh_flags & SHF_ALLOC){
				void *mem = malloc(section->sh_size);
				memset(mem,0,section->sh_size);
				section->sh_offset = (int)mem - (int)elf32_hdr;
				log_I("Allocated memory for section");
				}
			}
		}
	return true;
}
Exemplo n.º 3
0
static inline Elf64_Shdr *elf_section(Elf64_Ehdr *hdr, int idx) {
	kernel_assert(idx < hdr->e_shnum);
	return &elf_sheader(hdr)[idx];
}
Exemplo n.º 4
0
static inline Elf32_Shdr *elf_section(Elf32_Ehdr *hdr, int idx) {
  return &elf_sheader(hdr)[idx];
}