159,16 → 159,16 |
_plt_ent = plt+ 18; |
_plt_table = plt + 18 + plt_n; |
|
printf("parse relocation table\n"); |
DPRINTF("parse relocation table\n"); |
|
sym_table = m->dyn.sym_tab; |
rt_entries = rt_size / sizeof(elf_rela_t); |
str_tab = m->dyn.str_tab; |
|
printf("address: 0x%x, entries: %d\n", (uintptr_t)rt, rt_entries); |
DPRINTF("address: 0x%x, entries: %d\n", (uintptr_t)rt, rt_entries); |
|
for (i = 0; i < rt_entries; ++i) { |
printf("symbol %d: ", i); |
DPRINTF("symbol %d: ", i); |
r_offset = rt[i].r_offset; |
r_info = rt[i].r_info; |
r_addend = rt[i].r_addend; |
176,7 → 176,7 |
sym_idx = ELF32_R_SYM(r_info); |
sym = &sym_table[sym_idx]; |
|
printf("name '%s', value 0x%x, size 0x%x\n", |
DPRINTF("name '%s', value 0x%x, size 0x%x\n", |
str_tab + sym->st_name, |
sym->st_value, |
sym->st_size); |
185,16 → 185,16 |
r_ptr = (uint32_t *)(r_offset + m->bias); |
|
if (sym->st_name != 0) { |
printf("rel_type: %x, rel_offset: 0x%x\n", rel_type, r_offset); |
DPRINTF("rel_type: %x, rel_offset: 0x%x\n", rel_type, r_offset); |
sym_def = symbol_def_find(str_tab + sym->st_name, |
m, &dest); |
printf("dest name: '%s'\n", dest->dyn.soname); |
printf("dest bias: 0x%x\n", dest->bias); |
DPRINTF("dest name: '%s'\n", dest->dyn.soname); |
DPRINTF("dest bias: 0x%x\n", dest->bias); |
if (sym_def) { |
sym_addr = symbol_get_addr(sym_def, dest); |
printf("symbol definition found, addr=0x%x\n", sym_addr); |
DPRINTF("symbol definition found, addr=0x%x\n", sym_addr); |
} else { |
printf("symbol definition not found\n"); |
DPRINTF("symbol definition not found\n"); |
continue; |
} |
} |
201,10 → 201,10 |
|
switch (rel_type) { |
case R_PPC_JMP_SLOT: |
printf("fixup R_PPC_JMP_SLOT (b+v)\n"); |
DPRINTF("fixup R_PPC_JMP_SLOT (b+v)\n"); |
pidx = (r_ptr - _plt_ent) / 2; |
if (pidx >= plt_n) { |
printf("error: proc index out of range\n"); |
DPRINTF("error: proc index out of range\n"); |
//kputint(0xee00ee0ee00); |
while(1); |
} |
213,18 → 213,23 |
break; |
|
case R_PPC_ADDR32: |
printf("fixup R_PPC_ADDR32 (b+v+a)\n"); |
DPRINTF("fixup R_PPC_ADDR32 (b+v+a)\n"); |
*r_ptr = r_addend + sym_addr; |
break; |
|
case R_PPC_RELATIVE: |
printf("fixup R_PPC_RELATIVE (b+a)\n"); |
DPRINTF("fixup R_PPC_RELATIVE (b+a)\n"); |
*r_ptr = r_addend + m->bias; |
break; |
case R_PPC_REL24: |
printf("ignore R_PPC_REL24\n"); |
// printf("ignore R_PPC_REL24 at 0x%04x\n", (uintptr_t) r_ptr); |
*r_ptr = (sym_addr + r_addend - (uint32_t)r_ptr) >> 2; |
DPRINTF("fixup R_PPC_REL24 (s+a-p)>>2\n"); |
/*TODO*/ |
break; |
default: |
printf("unknown relocation type\n"); |
break; |
} |
} |
|