49,6 → 49,9 |
#include "pcb.h" |
#include "elf_load.h" |
|
#define RTLD_BIAS 0x80000 |
//#define RTLD_BIAS 0 |
|
static char *error_codes[] = { |
"no error", |
"invalid image", |
58,12 → 61,12 |
"irrecoverable error" |
}; |
|
static unsigned int elf_load(elf_ld_t *elf, size_t so_bias); |
static unsigned int elf_load(elf_ld_t *elf); |
static int segment_header(elf_ld_t *elf, elf_segment_header_t *entry); |
static int section_header(elf_ld_t *elf, elf_section_header_t *entry); |
static int load_segment(elf_ld_t *elf, elf_segment_header_t *entry); |
|
int elf_load_file(char *file_name, size_t so_bias, elf_info_t *info) |
int elf_load_file(char *file_name, elf_info_t *info) |
{ |
elf_ld_t elf; |
|
81,7 → 84,7 |
elf.fd = fd; |
elf.info = info; |
|
rc = elf_load(&elf, so_bias); |
rc = elf_load(&elf); |
printf("elf_load() -> %d\n", rc); |
|
close(fd); |
121,7 → 124,7 |
* @param header Pointer to ELF header in memory |
* @return EE_OK on success |
*/ |
static unsigned int elf_load(elf_ld_t *elf, size_t so_bias) |
static unsigned int elf_load(elf_ld_t *elf) |
{ |
elf_header_t header_buf; |
elf_header_t *header = &header_buf; |
167,14 → 170,14 |
return EE_UNSUPPORTED; |
} |
|
/* Shared objects can be loaded with a bias */ |
/* The run-time dynamic linker is loaded with a bias */ |
printf("Object type: %d\n", header->e_type); |
if (header->e_type == ET_DYN) |
elf->bias = so_bias; |
elf->bias = RTLD_BIAS; |
else |
elf->bias = 0; |
|
printf("Bias set to 0x%x\n", elf->bias); |
printf("Bias set to 0x%d\n", elf->bias); |
|
printf("parse segments\n"); |
|