Subversion Repositories HelenOS

Rev

Rev 3676 | Rev 3896 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3676 Rev 3787
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
/** Pathname of the file that will be loaded */
64
/** Pathname of the file that will be loaded */
63
static char *pathname = NULL;
65
static char *pathname = NULL;
64
 
66
 
65
/** The Program control block */
67
/** The Program control block */
66
static pcb_t pcb;
68
static pcb_t pcb;
Line 223... Line 225...
223
{
225
{
224
    int rc;
226
    int rc;
225
 
227
 
226
    rc = elf_load_file(pathname, 0, &prog_info);
228
    rc = elf_load_file(pathname, 0, &prog_info);
227
    if (rc < 0) {
229
    if (rc < 0) {
228
        printf("Failed to load executable '%s'.\n", pathname);
230
        DPRINTF("Failed to load executable '%s'.\n", pathname);
229
        ipc_answer_0(rid, EINVAL);
231
        ipc_answer_0(rid, EINVAL);
230
        return 1;
232
        return 1;
231
    }
233
    }
232
 
234
 
233
    elf_create_pcb(&prog_info, &pcb);
235
    elf_create_pcb(&prog_info, &pcb);
Line 242... Line 244...
242
        return 0;
244
        return 0;
243
    }
245
    }
244
 
246
 
245
    rc = elf_load_file(prog_info.interp, 0, &interp_info);
247
    rc = elf_load_file(prog_info.interp, 0, &interp_info);
246
    if (rc < 0) {
248
    if (rc < 0) {
247
        printf("Failed to load interpreter '%s.'\n", prog_info.interp);
249
        DPRINTF("Failed to load interpreter '%s.'\n",
-
 
250
            prog_info.interp);
248
        ipc_answer_0(rid, EINVAL);
251
        ipc_answer_0(rid, EINVAL);
249
        return 1;
252
        return 1;
250
    }
253
    }
251
 
254
 
252
    is_dyn_linked = true;
255
    is_dyn_linked = true;
Line 264... Line 267...
264
 */
267
 */
265
static void loader_run(ipc_callid_t rid, ipc_call_t *request)
268
static void loader_run(ipc_callid_t rid, ipc_call_t *request)
266
{
269
{
267
    if (is_dyn_linked == true) {
270
    if (is_dyn_linked == true) {
268
        /* Dynamically linked program */
271
        /* Dynamically linked program */
269
        printf("run dynamic linker\n");
272
        DPRINTF("Run ELF interpreter.\n");
270
        printf("entry point: 0x%lx\n", interp_info.entry);
273
        DPRINTF("Entry point: 0x%lx\n", interp_info.entry);
271
        close_console();
274
        close_console();
272
 
275
 
273
        ipc_answer_0(rid, EOK);
276
        ipc_answer_0(rid, EOK);
274
        elf_run(&interp_info, &pcb);
277
        elf_run(&interp_info, &pcb);
275
 
278
 
Line 322... Line 325...
322
            retval = ENOENT;
325
            retval = ENOENT;
323
            break;
326
            break;
324
        }
327
        }
325
        if ((callid & IPC_CALLID_NOTIFICATION) == 0 &&
328
        if ((callid & IPC_CALLID_NOTIFICATION) == 0 &&
326
            IPC_GET_METHOD(call) != IPC_M_PHONE_HUNGUP) {
329
            IPC_GET_METHOD(call) != IPC_M_PHONE_HUNGUP) {
327
            printf("responding EINVAL to method %d\n",
330
            DPRINTF("Responding EINVAL to method %d.\n",
328
                IPC_GET_METHOD(call));
331
                IPC_GET_METHOD(call));
329
            ipc_answer_0(callid, EINVAL);
332
            ipc_answer_0(callid, EINVAL);
330
        }
333
        }
331
    }
334
    }
332
}
335
}