Rev 3597 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3597 | Rev 3684 | ||
---|---|---|---|
Line 57... | Line 57... | ||
57 | #include <as.h> |
57 | #include <as.h> |
58 | 58 | ||
59 | #include <elf.h> |
59 | #include <elf.h> |
60 | #include <elf_load.h> |
60 | #include <elf_load.h> |
61 | 61 | ||
62 | /** |
- | |
63 | * Bias used for loading the dynamic linker. This will be soon replaced |
- | |
64 | * by automatic placement. |
- | |
65 | */ |
- | |
66 | #define RTLD_BIAS 0x80000 |
- | |
67 | - | ||
68 | /** Pathname of the file that will be loaded */ |
62 | /** Pathname of the file that will be loaded */ |
69 | static char *pathname = NULL; |
63 | static char *pathname = NULL; |
70 | 64 | ||
71 | /** The Program control block */ |
65 | /** The Program control block */ |
72 | static pcb_t pcb; |
66 | static pcb_t pcb; |
Line 227... | Line 221... | ||
227 | */ |
221 | */ |
228 | static int loader_load(ipc_callid_t rid, ipc_call_t *request) |
222 | static int loader_load(ipc_callid_t rid, ipc_call_t *request) |
229 | { |
223 | { |
230 | int rc; |
224 | int rc; |
231 | 225 | ||
232 | // printf("Load program '%s'\n", pathname); |
- | |
233 | - | ||
234 | rc = elf_load_file(pathname, 0, &prog_info); |
226 | rc = elf_load_file(pathname, 0, &prog_info); |
235 | if (rc < 0) { |
227 | if (rc < 0) { |
236 | printf("failed to load program\n"); |
228 | printf("Failed to load executable '%s'.\n", pathname); |
237 | ipc_answer_0(rid, EINVAL); |
229 | ipc_answer_0(rid, EINVAL); |
238 | return 1; |
230 | return 1; |
239 | } |
231 | } |
240 | 232 | ||
241 | // printf("Create PCB\n"); |
- | |
242 | elf_create_pcb(&prog_info, &pcb); |
233 | elf_create_pcb(&prog_info, &pcb); |
243 | 234 | ||
244 | pcb.argc = argc; |
235 | pcb.argc = argc; |
245 | pcb.argv = argv; |
236 | pcb.argv = argv; |
246 | 237 | ||
247 | if (prog_info.interp == NULL) { |
238 | if (prog_info.interp == NULL) { |
248 | /* Statically linked program */ |
239 | /* Statically linked program */ |
249 | // printf("Run statically linked program\n"); |
- | |
250 | // printf("entry point: 0x%lx\n", prog_info.entry); |
- | |
251 | is_dyn_linked = false; |
240 | is_dyn_linked = false; |
252 | ipc_answer_0(rid, EOK); |
241 | ipc_answer_0(rid, EOK); |
253 | return 0; |
242 | return 0; |
254 | } |
243 | } |
255 | 244 | ||
256 | printf("Load dynamic linker '%s'\n", prog_info.interp); |
- | |
257 | rc = elf_load_file("/rtld.so", RTLD_BIAS, &interp_info); |
245 | rc = elf_load_file(prog_info.interp, 0, &interp_info); |
258 | if (rc < 0) { |
246 | if (rc < 0) { |
259 | printf("failed to load dynamic linker\n"); |
247 | printf("Failed to load interpreter '%s.'\n", prog_info.interp); |
260 | ipc_answer_0(rid, EINVAL); |
248 | ipc_answer_0(rid, EINVAL); |
261 | return 1; |
249 | return 1; |
262 | } |
250 | } |
263 | 251 | ||
264 | /* |
- | |
265 | * Provide dynamic linker with some useful data |
- | |
266 | */ |
- | |
267 | pcb.rtld_dynamic = interp_info.dynamic; |
- | |
268 | pcb.rtld_bias = RTLD_BIAS; |
- | |
269 | - | ||
270 | is_dyn_linked = true; |
252 | is_dyn_linked = true; |
271 | ipc_answer_0(rid, EOK); |
253 | ipc_answer_0(rid, EOK); |
272 | 254 | ||
273 | return 0; |
255 | return 0; |
274 | } |
256 | } |