Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3154 → Rev 3155

/branches/dynload/uspace/app/iloader/main.c
78,7 → 78,6
size_t len;
char *name_buf;
 
printf("iloader_set_pathname\n");
if (!ipc_data_write_receive(&callid, &len)) {
ipc_answer_0(callid, EINVAL);
ipc_answer_0(rid, EINVAL);
85,8 → 84,6
return;
}
 
printf("alloc %d bytes\n", len+1);
 
name_buf = malloc(len + 1);
if (!name_buf) {
ipc_answer_0(callid, ENOMEM);
94,9 → 91,7
return;
}
 
printf("write_finalize\n");
ipc_data_write_finalize(callid, name_buf, len);
printf("answer\n");
ipc_answer_0(rid, EOK);
 
if (pathname != NULL) {
122,20 → 117,27
elf_info_t prog_info;
elf_info_t interp_info;
 
printf("Load program '%s'\n", pathname);
// printf("Load program '%s'\n", pathname);
 
rc = elf_load_file(pathname, 0, &prog_info);
if (rc < 0) {
printf("failed to load program\n");
ipc_answer_0(rid, EINVAL);
return 1;
}
 
printf("Create PCB\n");
if (elf_create_pcb(&prog_info) < 0) return 1;
// printf("Create PCB\n");
if (elf_create_pcb(&prog_info) < 0) {
ipc_answer_0(rid, ENOMEM);
return 1;
}
 
if (prog_info.interp == NULL) {
/* Statically linked program */
printf("Run statically linked program\n");
// printf("Run statically linked program\n");
// printf("entry point: 0x%llx\n", prog_info.entry);
ipc_answer_0(rid, EOK);
close_console();
elf_run(&prog_info);
return 0;
}
144,6 → 146,7
rc = elf_load_file("/rtld.so", RTLD_BIAS, &interp_info);
if (rc < 0) {
printf("failed to load dynamic linker\n");
ipc_answer_0(rid, EINVAL);
return 1;
}
 
155,8 → 158,13
pcb->rtld_bias = RTLD_BIAS;
 
printf("run dynamic linker\n");
printf("entry point: 0x%llx\n", interp_info.entry);
close_console();
 
ipc_answer_0(rid, EOK);
elf_run(&interp_info);
 
/* Not reached(?) */
return 0;
}
 
176,8 → 184,8
 
while (1) {
callid = async_get_call(&call);
printf("received call from phone %d, method=%d\n",
call.in_phone_hash, IPC_GET_METHOD(call));
// printf("received call from phone %d, method=%d\n",
// call.in_phone_hash, IPC_GET_METHOD(call));
switch (IPC_GET_METHOD(call)) {
case LOADER_SET_PATHNAME:
iloader_set_pathname(callid, &call);
/branches/dynload/uspace/app/iloader/elf_load.c
92,7 → 92,7
int fd;
int rc;
 
printf("open and read '%s'...\n", file_name);
// printf("open and read '%s'...\n", file_name);
 
fd = open(file_name, O_RDONLY);
if (fd < 0) {
104,7 → 104,6
elf.info = info;
 
rc = elf_load(&elf, so_bias);
printf("elf_load() -> %d\n", rc);
 
close(fd);
 
120,8 → 119,6
*/
void elf_run(elf_info_t *info)
{
printf("entry point: 0x%llx\n", info->entry);
//(*info->entry)();
program_run(info->entry);
 
/* not reached */
179,7 → 176,7
 
elf->header = header;
 
printf("ELF-load:");
// printf("ELF-load:");
/* Identify ELF */
if (header->e_ident[EI_MAG0] != ELFMAG0 ||
header->e_ident[EI_MAG1] != ELFMAG1 ||
218,17 → 215,17
}
 
/* Shared objects can be loaded with a bias */
printf("Object type: %d\n", header->e_type);
// printf("Object type: %d\n", header->e_type);
if (header->e_type == ET_DYN)
elf->bias = so_bias;
else
elf->bias = 0;
 
printf("Bias set to 0x%x\n", elf->bias);
// printf("Bias set to 0x%x\n", elf->bias);
elf->info->interp = NULL;
elf->info->dynamic = NULL;
 
printf("parse segments\n");
// printf("parse segments\n");
 
/* Walk through all segment headers and process them. */
for (i = 0; i < header->e_phnum; i++) {
246,7 → 243,7
return rc;
}
 
printf("parse sections\n");
// printf("parse sections\n");
 
/* Inspect all section headers and proccess them. */
for (i = 0; i < header->e_shnum; i++) {
267,7 → 264,7
elf->info->entry =
(entry_point_t)((uint8_t *)header->e_entry + elf->bias);
 
printf("done\n");
// printf("done\n");
 
return EE_OK;
}
333,8 → 330,8
size_t mem_sz;
int rc;
 
printf("load segment at addr 0x%x, size 0x%x\n", entry->p_vaddr,
entry->p_memsz);
// printf("load segment at addr 0x%x, size 0x%x\n", entry->p_vaddr,
// entry->p_memsz);
bias = elf->bias;
 
362,8 → 359,8
base = ALIGN_DOWN(entry->p_vaddr, PAGE_SIZE);
mem_sz = entry->p_memsz + (entry->p_vaddr - base);
 
printf("map to p_vaddr=0x%x-0x%x...\n", entry->p_vaddr + bias,
entry->p_vaddr + bias + ALIGN_UP(entry->p_memsz, PAGE_SIZE));
// printf("map to p_vaddr=0x%x-0x%x...\n", entry->p_vaddr + bias,
// entry->p_vaddr + bias + ALIGN_UP(entry->p_memsz, PAGE_SIZE));
 
/*
* For the course of loading, the area needs to be readable
376,17 → 373,17
return EE_MEMORY;
}
 
printf("as_area_create(0x%lx, 0x%x, %d) -> 0x%lx\n",
entry->p_vaddr+bias, entry->p_memsz, flags, (uintptr_t)a);
// printf("as_area_create(0x%lx, 0x%x, %d) -> 0x%lx\n",
// entry->p_vaddr+bias, entry->p_memsz, flags, (uintptr_t)a);
 
/*
* Load segment data
*/
printf("seek to %d\n", entry->p_offset);
// printf("seek to %d\n", entry->p_offset);
rc = lseek(elf->fd, entry->p_offset, SEEK_SET);
if (rc < 0) { printf("seek error\n"); return EE_INVALID; }
 
printf("read 0x%x bytes to address 0x%x\n", entry->p_filesz, entry->p_vaddr+bias);
// printf("read 0x%x bytes to address 0x%x\n", entry->p_filesz, entry->p_vaddr+bias);
/* rc = read(fd, (void *)(entry->p_vaddr + bias), entry->p_filesz);
if (rc < 0) { printf("read error\n"); return EE_INVALID; }*/
 
402,9 → 399,9
now = 16384;
if (now > left) now = left;
 
printf("read %d...", now);
// printf("read %d...", now);
rc = read(elf->fd, dp, now);
printf("->%d\n", rc);
// printf("->%d\n", rc);
 
if (rc < 0) { printf("read error\n"); return EE_INVALID; }
 
412,7 → 409,7
dp += now;
}
 
printf("set area flags to %d\n", flags);
// printf("set area flags to %d\n", flags);
rc = as_area_change_flags((uint8_t *)entry->p_vaddr + bias, flags);
if (rc != 0) {
printf("failed to set memory area flags\n");
/branches/dynload/uspace/app/init/init.c
83,6 → 83,12
static void spawn(char *fname)
{
printf(NAME ": Spawning %s\n", fname);
 
if (task_spawn_ex(fname, NULL) != 0) {
/* Success */
sleep(1);
}
return;
int fd = open(fname, O_RDONLY);
if (fd >= 0) {