Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2975 → Rev 2978

/branches/dynload/uspace/lib/rtld/arch/ia32/src/reloc.c
38,14 → 38,15
 
#include <arch.h>
#include <elf_dyn.h>
#include <symbol.h>
#include <rtld.h>
 
/**
* Process (fixup) all relocations in a relocation table.
*/
void rel_table_process(module_t *m, elf_rel_t *rt, size_t rt_size)
void rel_table_process(module_t *m, elf_rel_t *rt, size_t rt_size,
module_t *dest)
{
unsigned bias;
int i;
 
size_t rt_entries;
53,17 → 54,18
elf_word r_info;
unsigned rel_type;
elf_word sym_idx;
// uintptr_t sym_addr;
uintptr_t sym_addr;
elf_symbol_t *sym_table;
elf_symbol_t *sym;
uint32_t *r_ptr;
char *str_tab;
elf_symbol_t *sym_def;
 
printf("parse relocation table\n");
 
sym_table = m->dyn.sym_tab;
bias = m->bias;
rt_entries = rt_size / sizeof(elf_rel_t);
str_tab = m->dyn.str_tab;
 
83,32 → 85,35
sym->st_size);
 
rel_type = ELF32_R_TYPE(r_info);
r_ptr = (uint32_t *)(r_offset + bias);
r_ptr = (uint32_t *)(r_offset + m->bias);
 
printf("rel_type: %x, rel_offset: 0x%x\n", rel_type, r_offset);
/*
sym_def = symbol_def_find(dest, str_tab + sym->st_name);
if (sym_def) {
sym_addr = sym_def->st_value + dest->bias;
printf("symbol definition found, addr=0x%x\n", sym_addr);
} else {
printf("symbol definition not found\n");
continue;
}
 
switch (rel_type) {
case R_386_GLOB_DAT:
case R_386_JUMP_SLOT:
sym_addr = sym_table[sym_idx].st_value + bias;
kputint(sym_idx);
kputint(sym_addr);
 
printf("fixup R_386_GLOB_DAT/JUMP_SLOT (b+v)\n");
*r_ptr = sym_addr;
break;
 
case R_386_32:
sym_addr = sym_table[sym_idx].st_value + bias;
kputint(sym_idx);
kputint(sym_addr);
 
printf("fixup R_386_32 (b+v+a)\n");
*r_ptr += sym_addr;
break;
case R_386_RELATIVE:
*r_ptr += bias;
printf("fixup R_386_RELATIVE (b+a)\n");
*r_ptr += dest->bias;
break;
}*/
}
}
 
}