Rev 3681 | Rev 3689 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3681 | Rev 3686 | ||
|---|---|---|---|
| Line 45... | Line 45... | ||
| 45 | #include <elf_load.h> |
45 | #include <elf_load.h> |
| 46 | #include <module.h> |
46 | #include <module.h> |
| 47 | 47 | ||
| 48 | void program_run(void *entry, pcb_t *pcb); |
48 | void program_run(void *entry, pcb_t *pcb); |
| 49 | 49 | ||
| - | 50 | runtime_env_t dload_re; |
|
| - | 51 | ||
| 50 | int main(int argc, char *argv[]) |
52 | int main(int argc, char *argv[]) |
| 51 | { |
53 | { |
| 52 | static module_t prog; |
54 | static module_t prog; |
| 53 | 55 | ||
| - | 56 | runtime_env = &dload_re; |
|
| - | 57 | ||
| 54 | DPRINTF("Hello, world! (from dload)\n"); |
58 | DPRINTF("Hello, world! (from dload)\n"); |
| 55 | if (__pcb->dynamic == NULL) { |
59 | if (__pcb->dynamic == NULL) { |
| 56 | printf("This is the dynamic loader. It is not supposed " |
60 | printf("This is the dynamic loader. It is not supposed " |
| 57 | "to be executed directly.\n"); |
61 | "to be executed directly.\n"); |
| 58 | return -1; |
62 | return -1; |
| Line 67... | Line 71... | ||
| 67 | dynamic_parse(__pcb->dynamic, 0, &prog.dyn); |
71 | dynamic_parse(__pcb->dynamic, 0, &prog.dyn); |
| 68 | prog.bias = 0; |
72 | prog.bias = 0; |
| 69 | prog.dyn.soname = "[program]"; |
73 | prog.dyn.soname = "[program]"; |
| 70 | 74 | ||
| 71 | /* Initialize list of loaded modules */ |
75 | /* Initialize list of loaded modules */ |
| 72 | list_initialize(&runtime_env.modules_head); |
76 | list_initialize(&runtime_env->modules_head); |
| 73 | list_append(&prog.modules_link, &runtime_env.modules_head); |
77 | list_append(&prog.modules_link, &runtime_env->modules_head); |
| 74 | 78 | ||
| 75 | /* Pointer to program module. Used as root of the module graph. */ |
79 | /* Pointer to program module. Used as root of the module graph. */ |
| 76 | runtime_env.program = &prog; |
80 | runtime_env->program = &prog; |
| 77 | 81 | ||
| 78 | /* |
82 | /* |
| 79 | * Now we can continue with loading all other modules. |
83 | * Now we can continue with loading all other modules. |
| 80 | */ |
84 | */ |
| 81 | 85 | ||
| Line 88... | Line 92... | ||
| 88 | 92 | ||
| 89 | /* Process relocations in all modules */ |
93 | /* Process relocations in all modules */ |
| 90 | DPRINTF("Relocate all modules\n"); |
94 | DPRINTF("Relocate all modules\n"); |
| 91 | modules_process_relocs(); |
95 | modules_process_relocs(); |
| 92 | 96 | ||
| - | 97 | /* Pass runtime evironment pointer through PCB. */ |
|
| - | 98 | __pcb->rtld_runtime = (void *) runtime_env; |
|
| - | 99 | ||
| 93 | /* |
100 | /* |
| 94 | * Finally, run the main program. |
101 | * Finally, run the main program. |
| 95 | */ |
102 | */ |
| 96 | DPRINTF("Run program.. (at 0x%lx)\n", (uintptr_t)__pcb->entry); |
103 | DPRINTF("Run program.. (at 0x%lx)\n", (uintptr_t)__pcb->entry); |
| 97 | 104 | ||