/branches/dynload/uspace/app/iloader/include/pcb.h |
---|
33,6 → 33,7 |
#ifndef ILOADER_PCB_H_ |
#define ILOADER_PCB_H_ |
#include <sys/types.h> |
#include <arch/pcb.h> |
typedef void (*entry_point_t)(void); |
46,8 → 47,15 |
/** Program entry point */ |
entry_point_t entry; |
/* |
* ELF-specific data |
*/ |
/** Pointer to ELF dynamic section of the program */ |
void *dynamic; |
void *dynamic; |
/** Pointer to dynamic section of the runtime linker */ |
void *rtld_dynamic; |
/** Runtime-linker load bias */ |
uintptr_t rtld_bias; |
} pcb_t; |
#endif |
/branches/dynload/uspace/app/iloader/main.c |
---|
42,6 → 42,7 |
#include <elf.h> |
#include <elf_load.h> |
#include <pcb.h> |
#define RTLD_BIAS 0x80000 |
50,6 → 51,7 |
elf_info_t prog_info; |
elf_info_t interp_info; |
char *file_name; |
pcb_t *pcb; |
int rc; |
printf("This is loader\n"); |
57,8 → 59,8 |
printf("Load program\n"); |
// rc = elf_load_file("/dltest", 0, &prog_info); |
rc = elf_load_file("/tetris", 0, &prog_info); |
rc = elf_load_file("/dltest", 0, &prog_info); |
// rc = elf_load_file("/tetris", 0, &prog_info); |
if (rc < 0) { |
printf("failed to load program\n"); |
return 1; |
71,7 → 73,7 |
// getchar(); |
/* printf("Load dynamic linker\n"); |
printf("Load dynamic linker\n"); |
file_name = "/rtld.so"; |
printf("open and read '%s'...\n", file_name); |
rc = elf_load_file(file_name, RTLD_BIAS, &interp_info); |
80,9 → 82,16 |
return 1; |
} |
/* |
* Provide rtld with some useful data |
*/ |
pcb = (pcb_t *)PCB_ADDRESS; |
pcb->rtld_dynamic = interp_info.dynamic; |
pcb->rtld_bias = RTLD_BIAS; |
printf("run dynamic linker\n"); |
elf_run(&interp_info); |
*/ |
/* not reached */ |
return 0; |
} |
/branches/dynload/uspace/lib/rtld/arch/ia32/src/bootstrap.c |
---|
36,6 → 36,7 |
#include <elf_dyn.h> |
#include <rtld.h> |
#include <pcb.h> |
void __main(void); |
void __io_init(void); |
73,22 → 74,29 |
elf_rel_t *rel_table; |
elf_rel_t *jmp_rel_table; |
size_t jmp_rel_entries; |
pcb_t *pcb; |
pcb = (pcb_t *)PCB_ADDRESS; |
/* The program loader (iloader) kindly provided us with these */ |
dynamic = pcb->rtld_dynamic; |
bias = pcb->rtld_bias; |
/* |
asm volatile ( |
/* Calculate the bias into %0 */ |
/* Generates "fake" R_386_RELATIVE run-time relocation */ |
// Calculate the bias into %0 |
// Generates "fake" R_386_RELATIVE run-time relocation |
" call .L0;" |
".L0: pop %0;" |
" subl $.L0, %0;" |
/* Calculate run-time address of _DYNAMIC into %1 */ |
/* Generates "fake" R_386_RELATIVE run-time relocation */ |
" movl $_DYNAMIC, %1;" /* Again, at link time 0-based VMA gets in */ |
" addl %0, %1;" /* Add bias to compute run-time address */ |
// Calculate run-time address of _DYNAMIC into %1 |
// Generates "fake" R_386_RELATIVE run-time relocation |
" movl $_DYNAMIC, %1;" // Again, at link time 0-based VMA gets in |
" addl %0, %1;" // Add bias to compute run-time address |
: "=r" (bias), "=r" (dynamic) |
); |
*/ |
kputint(bias); |
kputint((unsigned)dynamic); |
/branches/dynload/uspace/Makefile |
---|
36,6 → 36,7 |
lib/libfs \ |
lib/softint \ |
lib/softfloat \ |
app/iloader \ |
lib/rtld \ |
lib/libc-shared \ |
lib/libtest \ |
52,7 → 53,6 |
app/tester \ |
app/dltest \ |
app/iramfs \ |
app/iloader \ |
app/klog \ |
app/init |