42,24 → 42,13 |
#include <dynamic.h> |
#include <pcb.h> |
#include <elf_load.h> |
#include <arch.h> |
|
static void kputint(unsigned i) |
{ |
unsigned dummy; |
asm volatile ( |
"movl $30, %%eax;" |
"int $0x30" |
: "=d" (dummy) /* output - %edx clobbered */ |
: "d" (i) /* input */ |
: "%eax","%ecx" /* all scratch registers clobbered */ |
); |
} |
|
void _rtld_main(void) |
{ |
pcb_t *pcb; |
static dyn_info_t dyn_info; |
elf_info_t lib_info; |
static module_t prog; |
int rc; |
|
printf("Hello, world! (from rtld)\n"); |
67,9 → 56,9 |
|
printf("Parse .dynamic section\n"); |
pcb = (pcb_t *)PCB_ADDRESS; |
dynamic_parse(pcb->dynamic, 0, &dyn_info); |
dynamic_parse(pcb->dynamic, 0, &prog.dyn); |
|
printf("Program requested library '%s'\n", dyn_info.needed); |
printf("Program requested library '%s'\n", prog.dyn.needed); |
|
rc = elf_load_file("/libtest.so.0", 0x20000, &lib_info); |
if (rc < 0) { |
77,6 → 66,10 |
return; |
} |
|
/* Parse program's relocation tables */ |
rel_table_process(&prog, prog.dyn.rel, prog.dyn.rel_sz); |
rel_table_process(&prog, prog.dyn.jmp_rel, prog.dyn.plt_rel_sz); |
|
printf("Run program..\n"); |
pcb->entry(); |
} |