47,7 → 47,7 |
|
static void kputint(unsigned i) |
{ |
asm volatile ( |
/* asm volatile ( |
"mr %%r3, %0\n" |
"li %%r9, 31\n" |
"sc\n" |
54,7 → 54,7 |
: |
: "r" (i) |
: "%r3","%r9" |
) ; |
) ;*/ |
} |
|
#define __L(ptr) ((uint32_t)(ptr) & 0x0000ffff) |
142,7 → 142,7 |
rel_entries = 0; |
jmp_rel_table = 0; |
jmp_rel_entries = 0; |
|
/* |
i = 0; |
while (dynamic[i].d_tag != 0) { |
// kputint((uintptr_t)&dynamic[i]); |
154,25 → 154,25 |
|
// kputint(0x10); |
register unsigned tag = dynamic[i].d_tag; |
|
*/ |
/* |
* Note that switches only work because we are using |
* -fno-jump-tables. |
*/ |
switch (tag) { |
/* switch (tag) { |
case DT_PLTRELSZ: jmp_rel_entries = dval/sizeof(elf_rela_t); break; |
case DT_JMPREL: jmp_rel_table = dptr; break; |
case DT_PLTGOT: |
case DT_PLTGOT:*/ |
/* PLT address */ |
plt = dptr; break; |
/* plt = dptr; break; |
case DT_SYMTAB: sym_table = dptr; break; |
case DT_RELA: rel_table = dptr; break; |
case DT_RELASZ: rel_entries = dval / sizeof(elf_rela_t); break; |
default: break; |
} |
|
*/ |
// kputint(0x20); |
|
/* |
++i; |
} |
|
181,16 → 181,16 |
kputint((unsigned)rel_table); |
kputint((unsigned)rel_entries); |
|
/* Now relocate all our dynsyms */ |
*/ /* Now relocate all our dynsyms */ |
kputint(-1); |
|
// PLT entries start here. However, each occupies 2 words |
_plt_ent = plt + 18; |
// _plt_ent = plt + 18; |
|
// By definition of the ppc ABI, there's 1:1 correspondence |
// between JMPREL entries and PLT entries |
unsigned plt_n = jmp_rel_entries; |
|
// unsigned plt_n = jmp_rel_entries; |
/* |
uint32_t *_plt_table; |
uint32_t *_plt_call; |
uint32_t *_plt_resolve; |
237,7 → 237,7 |
// kputint(plt[18]); |
// while(1); |
// while(1); |
//*r_ptr = sym_addr; |
// *r_ptr = sym_addr; |
|
break; |
|
264,9 → 264,9 |
kputint(sym_addr); |
res = (sym_addr - (uint32_t)r_ptr + a) >> 2; |
kputint(res); |
if (res & 0xff000000) { |
if (res & 0xff000000) {*/ |
/* out of range?? */ |
kputint(0xeeeeeeee); |
/* kputint(0xeeeeeeee); |
//while(1); |
} |
*r_ptr = (*r_ptr & ~0x00ffffff) | (res & 0x00ffffff); |
274,15 → 274,15 |
break; |
} |
} |
|
*/ |
kputint(-3); |
if (plt != 0) { |
// if (plt != 0) { |
|
/* .PLTcall: */ |
plt[6] = _ldis(11, __HA(_plt_table)); // ldis r11, .PLTtable@ha |
plt[7] = _lwz(11, __L(_plt_table), 11); // lwz r11, .PLTtable@l(r11) |
plt[8] = _mtctr(11); // mtctr r11 |
plt[9] = _bctr(); |
// plt[6] = _ldis(11, __HA(_plt_table)); // ldis r11, .PLTtable@ha |
// plt[7] = _lwz(11, __L(_plt_table), 11); // lwz r11, .PLTtable@l(r11) |
// plt[8] = _mtctr(11); // mtctr r11 |
// plt[9] = _bctr(); |
|
/* .PLTi, i = 0..N-1 */ |
/* kputint(-4); |
291,14 → 291,14 |
plt[18+i] = _b(_plt_call, &plt[18+i]); // b .PLTcall |
} |
*/ |
kputint(-5); |
kputint(_plt_table[0]); |
} |
// kputint(-5); |
// kputint(_plt_table[0]); |
// } |
|
kputint(-6); |
// kputint(-6); |
/* This will come in handy */ |
runtime_env.rtld_dynamic = dynamic; |
runtime_env.rtld.bias = bias; |
// runtime_env.rtld_dynamic = dynamic; |
// runtime_env.rtld.bias = bias; |
|
// volatile int ff=1; |
// while(ff); |