40,7 → 40,8 |
|
#include <rtld.h> |
#include <dynamic.h> |
#include "../../app/iloader/pcb.h" |
#include <pcb.h> |
#include <elf_load.h> |
|
static void kputint(unsigned i) |
{ |
54,46 → 55,29 |
); |
} |
|
int z = 42; |
|
void _putint(int i); |
|
void test_func(void); |
void test_func(void) |
{ |
int fd, rc; |
char buf[5]; |
|
printf("Hello, world! (from rtld)\n"); |
|
fd = open("/tetris", O_RDONLY); |
if (fd < 0) { printf("fd<0 ("); _putint(fd); printf(")\n"); } |
fd = 0; |
|
rc = read(fd, &buf, 4); |
//printf(" ->%d\n", rc); |
buf[4]='\0'; |
printf(buf); |
getchar(); |
|
printf("x\n"); |
while(1); |
} |
|
|
void _rtld_main(void) |
{ |
// test_func(); |
|
pcb_t *pcb; |
static dyn_info_t dyn_info; |
elf_info_t lib_info; |
int rc; |
|
printf("Hello, world! (from rtld)\n"); |
getchar(); |
printf("Run program..\n"); |
|
printf("Parse .dynamic section\n"); |
pcb = (pcb_t *)PCB_ADDRESS; |
dynamic_parse(pcb->dynamic, 0, &dyn_info); |
|
printf("Program requested library '%s'\n", dyn_info.needed); |
|
rc = elf_load_file("/libtest.so.0", &lib_info); |
if (rc < 0) { |
printf("failed to load library\n"); |
return; |
} |
|
printf("Run program..\n"); |
pcb->entry(); |
} |
|