Rev 2972 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2972 | Rev 2973 | ||
---|---|---|---|
Line 40... | Line 40... | ||
40 | 40 | ||
41 | #include <rtld.h> |
41 | #include <rtld.h> |
42 | #include <dynamic.h> |
42 | #include <dynamic.h> |
43 | #include <pcb.h> |
43 | #include <pcb.h> |
44 | #include <elf_load.h> |
44 | #include <elf_load.h> |
45 | - | ||
46 | static void kputint(unsigned i) |
- | |
47 | { |
- | |
48 | unsigned dummy; |
45 | #include <arch.h> |
49 | asm volatile ( |
- | |
50 | "movl $30, %%eax;" |
- | |
51 | "int $0x30" |
- | |
52 | : "=d" (dummy) /* output - %edx clobbered */ |
- | |
53 | : "d" (i) /* input */ |
- | |
54 | : "%eax","%ecx" /* all scratch registers clobbered */ |
- | |
55 | ); |
- | |
56 | } |
- | |
57 | 46 | ||
58 | void _rtld_main(void) |
47 | void _rtld_main(void) |
59 | { |
48 | { |
60 | pcb_t *pcb; |
49 | pcb_t *pcb; |
61 | static dyn_info_t dyn_info; |
- | |
62 | elf_info_t lib_info; |
50 | elf_info_t lib_info; |
- | 51 | static module_t prog; |
|
63 | int rc; |
52 | int rc; |
64 | 53 | ||
65 | printf("Hello, world! (from rtld)\n"); |
54 | printf("Hello, world! (from rtld)\n"); |
66 | getchar(); |
55 | getchar(); |
67 | 56 | ||
68 | printf("Parse .dynamic section\n"); |
57 | printf("Parse .dynamic section\n"); |
69 | pcb = (pcb_t *)PCB_ADDRESS; |
58 | pcb = (pcb_t *)PCB_ADDRESS; |
70 | dynamic_parse(pcb->dynamic, 0, &dyn_info); |
59 | dynamic_parse(pcb->dynamic, 0, &prog.dyn); |
71 | 60 | ||
72 | printf("Program requested library '%s'\n", dyn_info.needed); |
61 | printf("Program requested library '%s'\n", prog.dyn.needed); |
73 | 62 | ||
74 | rc = elf_load_file("/libtest.so.0", 0x20000, &lib_info); |
63 | rc = elf_load_file("/libtest.so.0", 0x20000, &lib_info); |
75 | if (rc < 0) { |
64 | if (rc < 0) { |
76 | printf("failed to load library\n"); |
65 | printf("failed to load library\n"); |
77 | return; |
66 | return; |
78 | } |
67 | } |
79 | 68 | ||
- | 69 | /* Parse program's relocation tables */ |
|
- | 70 | rel_table_process(&prog, prog.dyn.rel, prog.dyn.rel_sz); |
|
- | 71 | rel_table_process(&prog, prog.dyn.jmp_rel, prog.dyn.plt_rel_sz); |
|
- | 72 | ||
80 | printf("Run program..\n"); |
73 | printf("Run program..\n"); |
81 | pcb->entry(); |
74 | pcb->entry(); |
82 | } |
75 | } |
83 | 76 | ||
84 | /** @} |
77 | /** @} |