Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3154 → Rev 3155

/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");