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); |
} |
|
} |