Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2971 → Rev 2972

/branches/dynload/uspace/app/iloader/include/elf_load.h
69,7 → 69,7
elf_info_t *info;
} elf_ld_t;
 
int elf_load_file(char *file_name, elf_info_t *info);
int elf_load_file(char *file_name, size_t so_bias, elf_info_t *info);
void elf_run(elf_info_t *info);
int elf_create_pcb(elf_info_t *info);
 
/branches/dynload/uspace/app/iloader/main.c
43,6 → 43,8
#include <elf.h>
#include <elf_load.h>
 
#define RTLD_BIAS 0x80000
 
int main(int argc, char *argv[])
{
elf_info_t prog_info;
55,7 → 57,7
 
printf("Load program\n");
 
rc = elf_load_file("/dltest", &prog_info);
rc = elf_load_file("/dltest", 0, &prog_info);
if (rc < 0) {
printf("failed to load program\n");
return 1;
69,7 → 71,7
printf("Load dynamic linker\n");
file_name = "/rtld.so";
printf("open and read '%s'...\n", file_name);
rc = elf_load_file(file_name, &interp_info);
rc = elf_load_file(file_name, RTLD_BIAS, &interp_info);
if (rc < 0) {
printf("failed to load dynamic linker\n");
return 1;
/branches/dynload/uspace/app/iloader/elf_load.c
49,9 → 49,6
#include "pcb.h"
#include "elf_load.h"
 
#define RTLD_BIAS 0x80000
//#define RTLD_BIAS 0
 
static char *error_codes[] = {
"no error",
"invalid image",
61,12 → 58,12
"irrecoverable error"
};
 
static unsigned int elf_load(elf_ld_t *elf);
static unsigned int elf_load(elf_ld_t *elf, size_t so_bias);
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, elf_info_t *info)
int elf_load_file(char *file_name, size_t so_bias, elf_info_t *info)
{
elf_ld_t elf;
 
84,7 → 81,7
elf.fd = fd;
elf.info = info;
 
rc = elf_load(&elf);
rc = elf_load(&elf, so_bias);
printf("elf_load() -> %d\n", rc);
 
close(fd);
124,7 → 121,7
* @param header Pointer to ELF header in memory
* @return EE_OK on success
*/
static unsigned int elf_load(elf_ld_t *elf)
static unsigned int elf_load(elf_ld_t *elf, size_t so_bias)
{
elf_header_t header_buf;
elf_header_t *header = &header_buf;
170,14 → 167,14
return EE_UNSUPPORTED;
}
 
/* The run-time dynamic linker is loaded with a bias */
/* Shared objects can be loaded with a bias */
printf("Object type: %d\n", header->e_type);
if (header->e_type == ET_DYN)
elf->bias = RTLD_BIAS;
elf->bias = so_bias;
else
elf->bias = 0;
 
printf("Bias set to 0x%d\n", elf->bias);
printf("Bias set to 0x%x\n", elf->bias);
 
printf("parse segments\n");
 
/branches/dynload/uspace/lib/rtld/rtld.c
71,7 → 71,7
 
printf("Program requested library '%s'\n", dyn_info.needed);
rc = elf_load_file("/libtest.so.0", &lib_info);
rc = elf_load_file("/libtest.so.0", 0x20000, &lib_info);
if (rc < 0) {
printf("failed to load library\n");
return;