From: Alexandre Oliva Date: Thu, 31 Jul 2003 06:33:52 +0000 (+0000) Subject: * elf/dynamic-link.h (elf_machine_rel, elf_machine_rela, X-Git-Tag: upstream/2.30~10627^2~1313 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5027ae109a7168f340ba83781f14d68df162f868;p=external%2Fglibc.git * elf/dynamic-link.h (elf_machine_rel, elf_machine_rela, elf_machine_rel_relative, elf_machine_rela_relative): Don't assume reloc_addr is aligned. * sysdeps/alpha/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): Adjust. * sysdeps/arm/dl-machine.h (elf_machine_rel, elf_machine_rela, elf_machine_rel_relative, elf_machine_rela_relative): Adjust. * sysdeps/cris/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): Adjust. * sysdeps/hppa/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): Adjust. * sysdeps/i386/dl-machine.h (elf_machine_rel, elf_machine_rela, elf_machine_rel_relative, elf_machine_rela_relative): Adjust. * sysdeps/ia64/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): Adjust. * sysdeps/m68k/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): Adjust. * sysdeps/mips/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): Adjust. * sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): Adjust. * sysdeps/powerpc/powerpc64/dl-machine.h (elf_machine_rela_relative, elf_machine_rela): Adjust. * sysdeps/s390/s390-32/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): Adjust. * sysdeps/s390/s390-64/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): * sysdeps/sh/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): Adjust. * sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): Adjust. * sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): Adjust. * sysdeps/x86_64/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): Adjust. --- diff --git a/sysdeps/alpha/dl-machine.h b/sysdeps/alpha/dl-machine.h index 0101ba4..b3c1eac 100644 --- a/sysdeps/alpha/dl-machine.h +++ b/sysdeps/alpha/dl-machine.h @@ -512,8 +512,9 @@ elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc, const Elf64_Sym *sym, const struct r_found_version *version, - Elf64_Addr *const reloc_addr) + void *const reloc_addr_arg) { + Elf64_Addr *const reloc_addr = reloc_addr_arg; unsigned long int const r_type = ELF64_R_TYPE (reloc->r_info); #if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC && !defined SHARED @@ -538,15 +539,14 @@ elf_machine_rela (struct link_map *map, { /* XXX Make some timings. Maybe it's preferable to test for unaligned access and only do it the complex way if necessary. */ - void *reloc_addr_1 = reloc_addr; Elf64_Addr reloc_addr_val; /* Load value without causing unaligned trap. */ - memcpy (&reloc_addr_val, reloc_addr_1, 8); + memcpy (&reloc_addr_val, reloc_addr_arg, 8); reloc_addr_val += map->l_addr; /* Store value without causing unaligned trap. */ - memcpy (reloc_addr_1, &reloc_addr_val, 8); + memcpy (reloc_addr_arg, &reloc_addr_val, 8); } } else @@ -598,10 +598,8 @@ elf_machine_rela (struct link_map *map, #ifndef RTLD_BOOTSTRAP else if (r_type == R_ALPHA_REFQUAD) { - void *reloc_addr_1 = reloc_addr; - /* Store value without causing unaligned trap. */ - memcpy (reloc_addr_1, &sym_value, 8); + memcpy (reloc_addr_arg, &sym_value, 8); } #endif #if defined USE_TLS && (!defined RTLD_BOOTSTRAP || USE___THREAD) @@ -649,19 +647,18 @@ elf_machine_rela (struct link_map *map, static inline void elf_machine_rela_relative (Elf64_Addr l_addr, const Elf64_Rela *reloc, - Elf64_Addr *const reloc_addr) + void *const reloc_addr_arg) { - /* XXX Make some timings. Maybe it's preverable to test for + /* XXX Make some timings. Maybe it's preferable to test for unaligned access and only do it the complex way if necessary. */ - void *reloc_addr_1 = reloc_addr; Elf64_Addr reloc_addr_val; /* Load value without causing unaligned trap. */ - memcpy (&reloc_addr_val, reloc_addr_1, 8); + memcpy (&reloc_addr_val, reloc_addr_arg, 8); reloc_addr_val += l_addr; /* Store value without causing unaligned trap. */ - memcpy (reloc_addr_1, &reloc_addr_val, 8); + memcpy (reloc_addr_arg, &reloc_addr_val, 8); } static inline void diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h index 074762e..9c11f0b 100644 --- a/sysdeps/arm/dl-machine.h +++ b/sysdeps/arm/dl-machine.h @@ -1,5 +1,6 @@ /* Machine-dependent ELF dynamic relocation inline functions. ARM version. - Copyright (C) 1995,96,97,98,99,2000,2001,2002 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -419,8 +420,9 @@ fix_bad_pc24 (Elf32_Addr *const reloc_addr, Elf32_Addr value) static inline void elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, const Elf32_Sym *sym, const struct r_found_version *version, - Elf32_Addr *const reloc_addr) + void *const reloc_addr_arg) { + Elf32_Addr *const reloc_addr = reloc_addr_arg; const unsigned int r_type = ELF32_R_TYPE (reloc->r_info); #if !defined RTLD_BOOTSTRAP || !defined HAVE_Z_COMBRELOC @@ -470,8 +472,8 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, rtld_progname ?: "", strtab + refsym->st_name); } - memcpy (reloc_addr, (void *) value, MIN (sym->st_size, - refsym->st_size)); + memcpy (reloc_addr_arg, (void *) value, + MIN (sym->st_size, refsym->st_size)); break; case R_ARM_GLOB_DAT: case R_ARM_JUMP_SLOT: @@ -544,8 +546,9 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, static inline void elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, const Elf32_Sym *sym, const struct r_found_version *version, - Elf32_Addr *const reloc_addr) + void *const reloc_addr_arg) { + Elf32_Addr *const reloc_addr = reloc_addr_arg; const unsigned int r_type = ELF32_R_TYPE (reloc->r_info); if (__builtin_expect (r_type == R_ARM_RELATIVE, 0)) @@ -581,8 +584,8 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, rtld_progname ?: "", strtab + refsym->st_name); } - memcpy (reloc_addr, (void *) value, MIN (sym->st_size, - refsym->st_size)); + memcpy (reloc_addr_arg, (void *) value, + MIN (sym->st_size, refsym->st_size)); break; # endif /* !RESOLVE_CONFLICT_FIND_MAP */ case R_ARM_GLOB_DAT: @@ -623,16 +626,18 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, static inline void elf_machine_rel_relative (Elf32_Addr l_addr, const Elf32_Rel *reloc, - Elf32_Addr *const reloc_addr) + void *const reloc_addr_arg) { + Elf32_Addr *const reloc_addr = reloc_addr_arg; *reloc_addr += l_addr; } # ifndef RTLD_BOOTSTRAP static inline void elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc, - Elf32_Addr *const reloc_addr) + void *const reloc_addr_arg) { + Elf32_Addr *const reloc_addr = reloc_addr_arg; *reloc_addr = l_addr + reloc->r_addend; } # endif diff --git a/sysdeps/cris/dl-machine.h b/sysdeps/cris/dl-machine.h index 0fa13a7..7354c49 100644 --- a/sysdeps/cris/dl-machine.h +++ b/sysdeps/cris/dl-machine.h @@ -1,5 +1,5 @@ /* Machine-dependent ELF dynamic relocation inline functions. CRIS version. - Copyright (C) 1996-2001, 2002 Free Software Foundation, Inc. + Copyright (C) 1996-2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -280,8 +280,9 @@ elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc, static inline void elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, const Elf32_Sym *sym, const struct r_found_version *version, - Elf32_Addr *const reloc_addr) + void *const reloc_addr_arg) { + Elf32_Addr *const reloc_addr = reloc_addr_arg; const unsigned int r_type = ELF32_R_TYPE (reloc->r_info); if (__builtin_expect (r_type == R_CRIS_RELATIVE, 0)) @@ -322,8 +323,8 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, rtld_progname ?: "", strtab + refsym->st_name); } - memcpy (reloc_addr, (void *) value, MIN (sym->st_size, - refsym->st_size)); + memcpy (reloc_addr_arg, (void *) value, + MIN (sym->st_size, refsym->st_size)); break; case R_CRIS_32: @@ -364,8 +365,9 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, static inline void elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc, - Elf32_Addr *const reloc_addr) + void *const reloc_addr_arg) { + Elf32_Addr *const reloc_addr = reloc_addr_arg; *reloc_addr = l_addr + reloc->r_addend; } diff --git a/sysdeps/hppa/dl-machine.h b/sysdeps/hppa/dl-machine.h index 9cc10c4..cd180e7 100644 --- a/sysdeps/hppa/dl-machine.h +++ b/sysdeps/hppa/dl-machine.h @@ -1,5 +1,6 @@ /* Machine-dependent ELF dynamic relocation inline functions. PA-RISC version. - Copyright (C) 1995-1997,1999,2000,2001,2002 Free Software Foundation, Inc. + Copyright (C) 1995-1997,1999,2000,2001,2002, 2003 + Free Software Foundation, Inc. Contributed by David Huggins-Daines This file is part of the GNU C Library. @@ -481,8 +482,9 @@ asm ( \ static inline void elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, const Elf32_Sym *sym, const struct r_found_version *version, - Elf32_Addr *const reloc_addr) + void *const reloc_addr_arg) { + Elf32_Addr *const reloc_addr = reloc_addr_arg; const Elf32_Sym *const refsym = sym; unsigned long const r_type = ELF32_R_TYPE (reloc->r_info); struct link_map *sym_map; @@ -531,9 +533,9 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, return; #endif /* .eh_frame can have unaligned relocs. */ - if ((unsigned long) reloc_addr & 3) + if ((unsigned long) reloc_addr_arg & 3) { - char *rel_addr = (char *) reloc_addr; + char *rel_addr = (char *) reloc_addr_arg; rel_addr[0] = value >> 24; rel_addr[1] = value >> 16; rel_addr[2] = value >> 8; @@ -614,7 +616,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, rtld_progname ?: "", strtab + refsym->st_name); } - memcpy (reloc_addr, (void *) value, + memcpy (reloc_addr_arg, (void *) value, MIN (sym->st_size, refsym->st_size)); return; @@ -637,8 +639,9 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, static inline void elf_machine_rela_relative (struct link_map *map, Elf32_Addr l_addr, const Elf32_Rela *reloc, - Elf32_Addr *const reloc_addr) + void *const reloc_addr_arg) { + Elf32_Addr *const reloc_addr = reloc_addr_arg; unsigned long const r_type = ELF32_R_TYPE (reloc->r_info); Elf32_Addr value; @@ -651,9 +654,9 @@ elf_machine_rela_relative (struct link_map *map, Elf32_Addr l_addr, { case R_PARISC_DIR32: /* .eh_frame can have unaligned relocs. */ - if ((unsigned long) reloc_addr & 3) + if ((unsigned long) reloc_addr_arg & 3) { - char *rel_addr = (char *) reloc_addr; + char *rel_addr = (char *) reloc_addr_arg; rel_addr[0] = value >> 24; rel_addr[1] = value >> 16; rel_addr[2] = value >> 8; diff --git a/sysdeps/m68k/dl-machine.h b/sysdeps/m68k/dl-machine.h index a09f611..5ae53a4 100644 --- a/sysdeps/m68k/dl-machine.h +++ b/sysdeps/m68k/dl-machine.h @@ -229,8 +229,9 @@ elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc, static inline void __attribute__ ((always_inline)) elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, const Elf32_Sym *sym, const struct r_found_version *version, - Elf32_Addr *const reloc_addr) + void *const reloc_addr_arg) { + Elf32_Addr *const reloc_addr = reloc_addr_arg; const unsigned int r_type = ELF32_R_TYPE (reloc->r_info); if (__builtin_expect (r_type == R_68K_RELATIVE, 0)) @@ -260,8 +261,8 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, rtld_progname ?: "", strtab + refsym->st_name); } - memcpy (reloc_addr, (void *) value, MIN (sym->st_size, - refsym->st_size)); + memcpy (reloc_addr_arg, (void *) value, + MIN (sym->st_size, refsym->st_size)); break; case R_68K_GLOB_DAT: case R_68K_JMP_SLOT: @@ -298,8 +299,9 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, static inline void elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc, - Elf32_Addr *const reloc_addr) + void *const reloc_addr_arg) { + Elf32_Addr *const reloc_addr = reloc_addr_arg; *reloc_addr = l_addr + reloc->r_addend; } diff --git a/sysdeps/mips/dl-machine.h b/sysdeps/mips/dl-machine.h index f644441..a402b39 100644 --- a/sysdeps/mips/dl-machine.h +++ b/sysdeps/mips/dl-machine.h @@ -534,10 +534,7 @@ static inline void #endif elf_machine_rel (struct link_map *map, const ElfW(Rel) *reloc, const ElfW(Sym) *sym, const struct r_found_version *version, - /* We use void* because the location to be relocated - is not required to be properly aligned for a - ELFW(Addr). */ - void /* ElfW(Addr) */ *const reloc_addr) + void *const reloc_addr) { const unsigned long int r_type = ELFW(R_TYPE) (reloc->r_info); @@ -640,7 +637,7 @@ elf_machine_rel (struct link_map *map, const ElfW(Rel) *reloc, static inline void elf_machine_rel_relative (ElfW(Addr) l_addr, const ElfW(Rel) *reloc, - void /* ElfW(Addr) */ *const reloc_addr) + void *const reloc_addr) { /* XXX Nothing to do. There is no relative relocation, right? */ }