/branches/dynload/uspace/lib/rtld/module.c |
---|
83,9 → 83,6 |
module_t *m; |
char *p, *soname; |
printf("got head ptr\n"); |
printf(" = 0x%lx\n", (long) head); |
/* |
* If name contains slashes, treat it as a pathname and |
* construct soname by chopping off the path. Otherwise |
94,11 → 91,8 |
p = strrchr(name, '/'); |
soname = p ? (p + 1) : name; |
printf("did strrchr. soname='%s'\n", soname); |
/* Traverse list of all modules. Not extremely fast, but simple */ |
for (cur = head->next; cur != head; cur = cur->next) { |
printf("get_instance...\n"); |
m = list_get_instance(cur, module_t, modules_link); |
if (strcmp(m->dyn.soname, soname) == 0) { |
return m; /* Found */ |
/branches/dynload/uspace/lib/rtld/Makefile |
---|
41,7 → 41,7 |
CFLAGS += -Iinclude -I../../srv/loader/include -O0 -ggdb |
LFLAGS += |
PIC_CFLAGS := $(CFLAGS) -fPIC -D__PIC__ |
PIC_CFLAGS := $(CFLAGS) -fPIC |
DEFS += -DRELEASE=\"$(RELEASE)\" |
/branches/dynload/uspace/lib/rtld/arch/ppc32/include/elf_dyn.h |
---|
48,6 → 48,8 |
#define R_PPC_JMP_SLOT 21 |
#define R_PPC_RELATIVE 22 |
#define R_PPC_DTPMOD32 68 |
#endif |
/** @} |
/branches/dynload/uspace/lib/rtld/arch/ppc32/src/reloc.c |
---|
35,6 → 35,7 |
*/ |
#include <stdio.h> |
#include <stdlib.h> |
#include <arch.h> |
#include <elf_dyn.h> |
226,10 → 227,8 |
pidx = (r_ptr - _plt_ent) / 2; |
if (pidx >= plt_n) { |
DPRINTF("error: proc index out of range\n"); |
//kputint(0xee00ee0ee00); |
while(1); |
exit(1); |
} |
//_plt_table[pidx] = sym_addr; |
plt[18+2*pidx] = _b((void *)sym_addr, &plt[18+2*pidx]); |
break; |
258,14 → 257,24 |
DPRINTF("fixup R_PPC_RELATIVE (b+a)\n"); |
*r_ptr = r_addend + m->bias; |
break; |
case R_PPC_REL24: |
// printf("ignore R_PPC_REL24 at 0x%04x\n", (uintptr_t) r_ptr); |
DPRINTF("fixup R_PPC_REL24 (s+a-p)>>2\n"); |
*r_ptr = (sym_addr + r_addend - (uint32_t)r_ptr) >> 2; |
DPRINTF("fixup R_PPC_REL24 (s+a-p)>>2\n"); |
/*TODO*/ |
break; |
case R_PPC_DTPMOD32: |
/* |
* We can ignore this as long as the only module |
* with TLS variables is libc.so. |
*/ |
DPRINTF("Ignoring R_PPC_DTPMOD32\n"); |
break; |
default: |
printf("unknown relocation type %d\n", rel_type); |
printf("Error: Unknown relocation type %d.\n", |
rel_type); |
exit(1); |
break; |
} |
} |
/branches/dynload/uspace/lib/rtld/arch/ia32/include/elf_dyn.h |
---|
41,10 → 41,13 |
#define R_386_32 1 |
#define R_386_PC32 2 |
#define R_386_COPY 5 |
#define R_386_GLOB_DAT 6 |
#define R_386_JUMP_SLOT 7 |
#define R_386_RELATIVE 8 |
#define R_386_TLS_DTPMOD32 35 |
#endif |
/** @} |
/branches/dynload/uspace/lib/rtld/arch/ia32/src/reloc.c |
---|
35,12 → 35,14 |
*/ |
#include <stdio.h> |
#include <stdlib.h> |
#include <arch.h> |
#include <elf_dyn.h> |
#include <symbol.h> |
#include <rtld.h> |
#include <rtld_arch.h> |
void module_process_pre_arch(module_t *m) |
{ |
/* Unused */ |
64,6 → 66,7 |
elf_symbol_t *sym_table; |
elf_symbol_t *sym; |
uint32_t *r_ptr; |
uint32_t sym_size; |
char *str_tab; |
elf_symbol_t *sym_def; |
111,28 → 114,53 |
switch (rel_type) { |
case R_386_GLOB_DAT: |
case R_386_JUMP_SLOT: |
// DPRINTF("fixup R_386_GLOB_DAT/JUMP_SLOT (b+v)\n"); |
DPRINTF("fixup R_386_GLOB_DAT/JUMP_SLOT (b+v)\n"); |
*r_ptr = sym_addr; |
break; |
case R_386_32: |
// DPRINTF("fixup R_386_32 (b+v+a)\n"); |
DPRINTF("fixup R_386_32 (b+v+a)\n"); |
*r_ptr += sym_addr; |
break; |
case R_386_PC32: |
// DPRINTF("fixup R_386_PC32 (b+v+a)\n"); |
DPRINTF("fixup R_386_PC32 (b+v+a)\n"); |
*r_ptr += sym_addr - (uint32_t) r_ptr; |
break; |
case R_386_COPY: |
/* |
* Copy symbol data from shared object to specified |
* location. |
*/ |
DPRINTF("fixup R_386_COPY (s)\n"); |
sym_size = sym->st_size; |
if (sym_size != sym_def->st_size) { |
printf("Warning: Mismatched symbol sizes.\n"); |
/* Take the lower value. */ |
if (sym_size > sym_def->st_size) |
sym_size = sym_def->st_size; |
} |
memcpy(r_ptr, (const void *)sym_addr, sym_size); |
break; |
case R_386_RELATIVE: |
// DPRINTF("fixup R_386_RELATIVE (b+a)\n"); |
DPRINTF("fixup R_386_RELATIVE (b+a)\n"); |
*r_ptr += m->bias; |
break; |
case R_386_TLS_DTPMOD32: |
/* |
* We can ignore this as long as the only module |
* with TLS variables is libc.so. |
*/ |
DPRINTF("Ignoring R_386_TLS_DTPMOD32\n"); |
break; |
default: |
printf("Unknown relocation type %d\n", rel_type); |
break; |
printf("Error: Unknown relocation type %d\n", |
rel_type); |
exit(1); |
} |
} |