diff options
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/i386/dl-machine.h | 28 | ||||
-rw-r--r-- | sysdeps/m68k/dl-machine.h | 46 | ||||
-rw-r--r-- | sysdeps/stub/dl-machine.h | 17 |
3 files changed, 67 insertions, 24 deletions
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h index 4e0806fd48..e53c779ec3 100644 --- a/sysdeps/i386/dl-machine.h +++ b/sysdeps/i386/dl-machine.h @@ -73,20 +73,31 @@ elf_machine_load_address (void) static inline void elf_machine_rel (struct link_map *map, - const Elf32_Rel *reloc, - Elf32_Addr sym_loadaddr, const Elf32_Sym *sym) + const Elf32_Rel *reloc, const Elf32_Sym *sym, + Elf32_Addr (*resolve) (const Elf32_Sym **ref, + Elf32_Addr reloc_addr, + int noplt)) { Elf32_Addr *const reloc_addr = (void *) (map->l_addr + reloc->r_offset); - const Elf32_Addr sym_value = sym ? sym_loadaddr + sym->st_value : 0; + Elf32_Addr loadbase; switch (ELF32_R_TYPE (reloc->r_info)) { case R_386_COPY: - memcpy (reloc_addr, (void *) sym_value, sym->st_size); + loadbase = (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0); + memcpy (reloc_addr, (void *) (loadbase + sym->st_value), sym->st_size); break; case R_386_GLOB_DAT: + loadbase = (resolve ? (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0) : + /* RESOLVE is null during bootstrap relocation. */ + map->l_addr); + *reloc_addr = sym ? (loadbase + sym->st_value) : 0; + break; case R_386_JMP_SLOT: - *reloc_addr = sym_value; + loadbase = (resolve ? (*resolve) (&sym, (Elf32_Addr) reloc_addr, 1) : + /* RESOLVE is null during bootstrap relocation. */ + map->l_addr); + *reloc_addr = sym ? (loadbase + sym->st_value) : 0; break; case R_386_32: if (map->l_type == lt_interpreter) @@ -100,14 +111,17 @@ elf_machine_rel (struct link_map *map, *reloc_addr -= (map->l_addr + dlsymtab[ELF32_R_SYM (reloc->r_info)].st_value); } - *reloc_addr += sym_value; + loadbase = (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0); + *reloc_addr += sym ? (loadbase + sym->st_value) : 0; break; case R_386_RELATIVE: if (map->l_type != lt_interpreter) /* Already done in dynamic linker. */ *reloc_addr += map->l_addr; break; case R_386_PC32: - *reloc_addr += sym_value - (Elf32_Addr) reloc_addr; + loadbase = (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0); + *reloc_addr += ((sym ? (loadbase + sym->st_value) : 0) - + (Elf32_Addr) reloc_addr); break; case R_386_NONE: /* Alright, Wilbur. */ break; diff --git a/sysdeps/m68k/dl-machine.h b/sysdeps/m68k/dl-machine.h index aa1f19eacb..760bf9662d 100644 --- a/sysdeps/m68k/dl-machine.h +++ b/sysdeps/m68k/dl-machine.h @@ -73,43 +73,67 @@ elf_machine_load_address (void) static inline void elf_machine_rela (struct link_map *map, - const Elf32_Rela *reloc, - Elf32_Addr sym_loadaddr, const Elf32_Sym *sym) + const Elf32_Rel *reloc, const Elf32_Sym *sym, + Elf32_Addr (*resolve) (const Elf32_Sym **ref, + Elf32_Addr reloc_addr, + int noplt)) { Elf32_Addr *const reloc_addr = (void *) (map->l_addr + reloc->r_offset); - const Elf32_Addr sym_value = sym ? sym_loadaddr + sym->st_value : 0; + Elf32_Addr loadbase; switch (ELF32_R_TYPE (reloc->r_info)) { case R_68K_COPY: - memcpy (reloc_addr, (void *) sym_value, sym->st_size); + loadbase = (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0); + memcpy (reloc_addr, (void *) (loadbase + sym->st_value), sym->st_size); break; case R_68K_GLOB_DAT: + loadbase = (resolve ? (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0) : + /* RESOLVE is null during bootstrap relocation. */ + map->l_addr); + *reloc_addr = sym ? (loadbase + sym->st_value) : 0; + break; case R_68K_JMP_SLOT: - *reloc_addr = sym_value; + loadbase = (resolve ? (*resolve) (&sym, (Elf32_Addr) reloc_addr, 1) : + /* RESOLVE is null during bootstrap relocation. */ + map->l_addr); + *reloc_addr = sym ? (loadbase + sym->st_value) : 0; break; case R_68K_8: - *(char *) reloc_addr = sym_value + reloc->r_addend; + loadbase = (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0); + *(char *) reloc_addr = ((sym ? (loadbase + sym->st_value) : 0) + + reloc->r_addend); break; case R_68K_16: - *(short *) reloc_addr = sym_value + reloc->r_addend; + loadbase = (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0); + *(short *) reloc_addr = ((sym ? (loadbase + sym->st_value) : 0) + + reloc->r_addend); break; case R_68K_32: - *reloc_addr = sym_value + reloc->r_addend; + loadbase = (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0); + *reloc_addr = ((sym ? (loadbase + sym->st_value) : 0) + + reloc->r_addend); break; case R_68K_RELATIVE: *reloc_addr = map->l_addr + reloc->r_addend; break; case R_68K_PC8: - *(char *) reloc_addr = (sym_value + reloc->r_addend + loadbase = (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0); + *(char *) reloc_addr = ((sym ? (loadbase + sym->st_value) : 0) + + reloc->r_addend - (Elf32_Addr) reloc_addr); break; case R_68K_PC16: - *(short *) reloc_addr = (sym_value + reloc->r_addend + loadbase = (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0); + *(short *) reloc_addr = ((sym ? (loadbase + sym->st_value) : 0) + + reloc->r_addend - (Elf32_Addr) reloc_addr); break; case R_68K_PC32: - *reloc_addr = sym_value + reloc->r_addend - (Elf32_Addr) reloc_addr; + loadbase = (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0); + *reloc_addr = ((sym ? (loadbase + sym->st_value) : 0) + + reloc->r_addend + - (Elf32_Addr) reloc_addr); break; case R_68K_NONE: /* Alright, Wilbur. */ break; diff --git a/sysdeps/stub/dl-machine.h b/sysdeps/stub/dl-machine.h index 73943f1558..1fdb461da7 100644 --- a/sysdeps/stub/dl-machine.h +++ b/sysdeps/stub/dl-machine.h @@ -61,16 +61,19 @@ elf_machine_load_address (void) static inline void elf_machine_rel (Elf32_Addr loadaddr, Elf32_Dyn *info[DT_NUM], - const Elf32_Rel *reloc, - Elf32_Addr sym_loadaddr, const Elf32_Sym *sym) + const Elf32_Rel *reloc, const Elf32_Sym *sym, + Elf32_Addr (*resolve) (const Elf32_Sym **ref, + Elf32_Addr reloc_addr, + int noplt)) { Elf32_Addr *const reloc_addr = (Elf32_Addr *) reloc->r_offset; - const Elf32_Addr sym_value = sym_loadaddr + sym->st_value; + Elf32_Addr loadbase; switch (ELF32_R_TYPE (reloc->r_info)) { case R_MACHINE_COPY: - memcpy (reloc_addr, (void *) sym_value, sym->st_size); + loadbase = (*resolve) (&sym, (Elf32_Addr) reloc_addr, 0); + memcpy (reloc_addr, (void *) (loadbase + sym->st_value), sym->st_size); break; default: assert (! "unexpected dynamic reloc type"); @@ -81,8 +84,10 @@ elf_machine_rel (Elf32_Addr loadaddr, Elf32_Dyn *info[DT_NUM], static inline void elf_machine_rela (Elf32_Addr loadaddr, Elf32_Dyn *info[DT_NUM], - const Elf32_Rela *reloc, - Elf32_Addr sym_loadaddr, const Elf32_Sym *sym) + const Elf32_Rel *reloc, const Elf32_Sym *sym, + Elf32_Addr (*resolve) (const Elf32_Sym **ref, + Elf32_Addr reloc_addr, + int noplt)) { _dl_signal_error (0, "Elf32_Rela relocation requested -- unused on " ELF_MACHINE_NAME); |