Rev 3773 | Rev 4343 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3773 | Rev 4338 | ||
|---|---|---|---|
| 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 | #define DPRINTF(...) |
|
| - | 63 | ||
| 62 | void program_run(void *entry, pcb_t *pcb); |
64 | void program_run(void *entry, pcb_t *pcb); |
| 63 | 65 | ||
| 64 | /** Pathname of the file that will be loaded */ |
66 | /** Pathname of the file that will be loaded */ |
| 65 | static char *pathname = NULL; |
67 | static char *pathname = NULL; |
| 66 | 68 | ||
| Line 225... | Line 227... | ||
| 225 | { |
227 | { |
| 226 | int rc; |
228 | int rc; |
| 227 | 229 | ||
| 228 | rc = elf_load_file(pathname, 0, 0, &prog_info); |
230 | rc = elf_load_file(pathname, 0, 0, &prog_info); |
| 229 | if (rc < 0) { |
231 | if (rc < 0) { |
| 230 | printf("Failed to load executable '%s'.\n", pathname); |
232 | DPRINTF("Failed to load executable '%s'.\n", pathname); |
| 231 | ipc_answer_0(rid, EINVAL); |
233 | ipc_answer_0(rid, EINVAL); |
| 232 | return 1; |
234 | return 1; |
| 233 | } |
235 | } |
| 234 | 236 | ||
| 235 | elf_create_pcb(&prog_info, &pcb); |
237 | elf_create_pcb(&prog_info, &pcb); |
| Line 245... | Line 247... | ||
| 245 | } |
247 | } |
| 246 | 248 | ||
| 247 | printf("Load ELF interpreter '%s'\n", prog_info.interp); |
249 | printf("Load ELF interpreter '%s'\n", prog_info.interp); |
| 248 | rc = elf_load_file(prog_info.interp, 0, 0, &interp_info); |
250 | rc = elf_load_file(prog_info.interp, 0, 0, &interp_info); |
| 249 | if (rc < 0) { |
251 | if (rc < 0) { |
| 250 | printf("Failed to load interpreter '%s.'\n", prog_info.interp); |
252 | DPRINTF("Failed to load interpreter '%s.'\n", |
| - | 253 | prog_info.interp); |
|
| 251 | ipc_answer_0(rid, EINVAL); |
254 | ipc_answer_0(rid, EINVAL); |
| 252 | return 1; |
255 | return 1; |
| 253 | } |
256 | } |
| 254 | 257 | ||
| 255 | printf("Run interpreter.\n"); |
258 | printf("Run interpreter.\n"); |
| Line 272... | Line 275... | ||
| 272 | */ |
275 | */ |
| 273 | static void loader_run(ipc_callid_t rid, ipc_call_t *request) |
276 | static void loader_run(ipc_callid_t rid, ipc_call_t *request) |
| 274 | { |
277 | { |
| 275 | if (is_dyn_linked == true) { |
278 | if (is_dyn_linked == true) { |
| 276 | /* Dynamically linked program */ |
279 | /* Dynamically linked program */ |
| 277 | printf("run dynamic linker\n"); |
280 | DPRINTF("Run ELF interpreter.\n"); |
| 278 | printf("entry point: 0x%lx\n", interp_info.entry); |
281 | DPRINTF("Entry point: 0x%lx\n", interp_info.entry); |
| 279 | close_console(); |
282 | close_console(); |
| 280 | 283 | ||
| 281 | ipc_answer_0(rid, EOK); |
284 | ipc_answer_0(rid, EOK); |
| 282 | program_run(interp_info.entry, &pcb); |
285 | program_run(interp_info.entry, &pcb); |
| 283 | 286 | ||
| Line 330... | Line 333... | ||
| 330 | retval = ENOENT; |
333 | retval = ENOENT; |
| 331 | break; |
334 | break; |
| 332 | } |
335 | } |
| 333 | if ((callid & IPC_CALLID_NOTIFICATION) == 0 && |
336 | if ((callid & IPC_CALLID_NOTIFICATION) == 0 && |
| 334 | IPC_GET_METHOD(call) != IPC_M_PHONE_HUNGUP) { |
337 | IPC_GET_METHOD(call) != IPC_M_PHONE_HUNGUP) { |
| 335 | printf("responding EINVAL to method %d\n", |
338 | DPRINTF("Responding EINVAL to method %d.\n", |
| 336 | IPC_GET_METHOD(call)); |
339 | IPC_GET_METHOD(call)); |
| 337 | ipc_answer_0(callid, EINVAL); |
340 | ipc_answer_0(callid, EINVAL); |
| 338 | } |
341 | } |
| 339 | } |
342 | } |
| 340 | } |
343 | } |