45,6 → 45,7 |
#include "elf.h" |
|
#define RTLD_BIAS 0x80000 |
//#define RTLD_BIAS 0 |
|
static char *error_codes[] = { |
"no error", |
229,7 → 230,8 |
flags |= AS_AREA_CACHEABLE; |
*/ |
/* FIXME: Kernel won't normally allow this, unless you "patch" it */ |
flags = AS_AREA_READ | AS_AREA_WRITE | AS_AREA_EXEC | AS_AREA_CACHEABLE; |
// flags = AS_AREA_READ | AS_AREA_WRITE | AS_AREA_EXEC | AS_AREA_CACHEABLE; |
flags = AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE; |
|
/* |
* Check if the virtual address starts on page boundary. |
251,17 → 253,36 |
return EE_MEMORY; |
} |
|
printf("as_area_create() -> 0x%x\n", (unsigned)a); |
printf("as_area_create(0x%x, 0x%x, %d) -> 0x%x\n", |
entry->p_vaddr+bias, entry->p_memsz, flags, (unsigned)a); |
|
/* |
* Load segment data |
*/ |
printf("seek to %d\n", entry->p_offset); |
rc = lseek(fd, entry->p_offset, SEEK_SET); |
if (rc < 0) { printf("seek error\n"); return EE_INVALID; } |
|
rc = read(fd, (void *)(entry->p_vaddr + bias), entry->p_filesz); |
if (rc < 0) { printf("read error\n"); return EE_INVALID; } |
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; }*/ |
unsigned left, now; |
uint8_t *dp; |
|
left = entry->p_filesz; |
dp = (uint8_t *)(entry->p_vaddr + bias); |
|
while (left > 0) { |
now = 4096; |
if (now > left) now=left; |
printf("read %d...", now); |
rc = read(fd, dp, now); |
if (rc < 0) { printf("read error\n"); return EE_INVALID; } |
printf("->%d\n", rc); |
left -= now; |
dp += now; |
} |
|
return EE_OK; |
} |
|