From 710f7bab59b9bb02f1cd46fa2db14e2b4b0a806a Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 3 Jun 1996 04:46:40 +0000 Subject: Mon Jun 3 00:30:35 1996 Roland McGrath * elf/dl-lookup.c (_dl_lookup_symbol): Take new arg RELOC_ADDR and don't allow a defn resolving to that address. * elf/link.h: Update prototype and comment. * elf/dl-runtime.c (fixup): Define local `resolve' function and pass it to elf_machine_relplt. * elf/dl-reloc.c (_dl_relocate_object: resolve): Take new arg RELOC_ADDR and pass it through to _dl_lookup_symbol. * elf/do-rel.h (elf_dynamic_do_rel): Pass RESOLVE to elf_machine_rel instead of calling it ourselves and passing its results. (elf_dynamic_do_rel): RESOLVE fn takes new arg RELOC_ADDR. * elf/rtld.c (dl_main): Pass 0 for RELOC_ADDR to _dl_lookup_symbol. * sysdeps/i386/dl-machine.h (elf_machine_rel): Remove SYM_LOADADDR arg. Add RESOLVE function ptr arg. Call *RESOLVE as necessary. * sysdeps/m68k/dl-machine.h (elf_machine_rela): Likewise. * sysdeps/stub/dl-machine.h: Likewise. * csu/initfini.c (_fini): Add extern decl for i_am_not_a_leaf. * elf/dlfcn.h (dl_open_mode): Enumerated type removed. (RTLD_LAZY, RTLD_NOW): Define these as macros instead. (RTLD_GLOBAL): New macro. (dlopen): Take arg of type int instead of dl_open_mode. * elf/dlopen.c: Likewise. * math/math.h (_Mldbl): New macro, either produces L suffix or not. (M_*): Use it for these constants. --- sysdeps/m68k/dl-machine.h | 46 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 11 deletions(-) (limited to 'sysdeps/m68k') 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; -- cgit 1.4.1