From: Roland McGrath Date: Mon, 21 Jun 2010 02:46:58 +0000 (-0700) Subject: Replace ebl_reloc_simple_type with ebl_reloc_simple_types. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=82e5e725e248d7d5bf42bb07482828a56cea33aa;p=thirdparty%2Felfutils.git Replace ebl_reloc_simple_type with ebl_reloc_simple_types. --- diff --git a/backends/ChangeLog b/backends/ChangeLog index 9fd9745d0..7031ba34e 100644 --- a/backends/ChangeLog +++ b/backends/ChangeLog @@ -1,3 +1,26 @@ +2010-06-20 Roland McGrath + + * alpha_init.c: Replace reloc_simple_type with reloc_simple_types. + * arm_init.c: Likewise. + * i386_init.c: Likewise. + * ia64_init.c: Likewise. + * PPC64_init.c: Likewise. + * ppc_init.c: Likewise. + * s390_init.c: Likewise. + * sh_init.c: Likewise. + * sparc_init.c: Likewise. + * x86_64_init.c: Likewise. + * alpha_symbol.c: Likewise. + * arm_symbol.c: Likewise. + * i386_symbol.c: Likewise. + * ia64_symbol.c: Likewise. + * ppc64_symbol.c: Likewise. + * ppc_symbol.c: Likewise. + * s390_symbol.c: Likewise. + * sh_symbol.c: Likewise. + * sparc_symbol.c: Likewise. + * x86_64_symbol.c: Likewise. + 2010-04-10 Matt Fleming * sh_corenote.c: New file. diff --git a/backends/alpha_init.c b/backends/alpha_init.c index 1ca99abc5..2983982fb 100644 --- a/backends/alpha_init.c +++ b/backends/alpha_init.c @@ -52,7 +52,7 @@ alpha_init (elf, machine, eh, ehlen) alpha_init_reloc (eh); HOOK (eh, dynamic_tag_name); HOOK (eh, dynamic_tag_check); - HOOK (eh, reloc_simple_type); + HOOK (eh, reloc_simple_types); HOOK (eh, return_value_location); HOOK (eh, machine_section_flag_check); HOOK (eh, check_special_section); diff --git a/backends/alpha_symbol.c b/backends/alpha_symbol.c index aa45c61ee..0e85f4975 100644 --- a/backends/alpha_symbol.c +++ b/backends/alpha_symbol.c @@ -1,5 +1,5 @@ /* Alpha specific symbolic name handling. - Copyright (C) 2002,2005,2007,2008 Red Hat, Inc. + Copyright (C) 2002-2010 Red Hat, Inc. This file is part of Red Hat elfutils. Written by Ulrich Drepper , 2002. @@ -56,18 +56,15 @@ alpha_dynamic_tag_check (int64_t tag) } /* Check for the simple reloc types. */ -Elf_Type -alpha_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type) +int +alpha_reloc_simple_types (Ebl *ebl __attribute__ ((unused)), + const int **rel8_types, const int **rel4_types) { - switch (type) - { - case R_ALPHA_REFLONG: - return ELF_T_WORD; - case R_ALPHA_REFQUAD: - return ELF_T_XWORD; - default: - return ELF_T_NUM; - } + static const int rel8[] = { R_ALPHA_REFQUAD, 0 }; + static const int rel4[] = { R_ALPHA_REFLONG, 0 }; + *rel8_types = rel8; + *rel4_types = rel4; + return 0; } diff --git a/backends/arm_init.c b/backends/arm_init.c index 15c0ee673..c8122e657 100644 --- a/backends/arm_init.c +++ b/backends/arm_init.c @@ -53,7 +53,7 @@ arm_init (elf, machine, eh, ehlen) HOOK (eh, segment_type_name); HOOK (eh, section_type_name); HOOK (eh, machine_flag_check); - HOOK (eh, reloc_simple_type); + HOOK (eh, reloc_simple_types); HOOK (eh, register_info); HOOK (eh, core_note); HOOK (eh, auxv_info); diff --git a/backends/arm_symbol.c b/backends/arm_symbol.c index e08874bba..0cb1054aa 100644 --- a/backends/arm_symbol.c +++ b/backends/arm_symbol.c @@ -1,5 +1,5 @@ /* Arm specific symbolic name handling. - Copyright (C) 2002-2009 Red Hat, Inc. + Copyright (C) 2002-2010 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -104,18 +104,13 @@ arm_machine_flag_check (GElf_Word flags) } /* Check for the simple reloc types. */ -Elf_Type -arm_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type) +int +arm_reloc_simple_types (Ebl *ebl __attribute__ ((unused)), + const int **rel8_types, const int **rel4_types) { - switch (type) - { - case R_ARM_ABS32: - return ELF_T_WORD; - case R_ARM_ABS16: - return ELF_T_HALF; - case R_ARM_ABS8: - return ELF_T_BYTE; - default: - return ELF_T_NUM; - } + static const int rel8[] = { 0 }; + static const int rel4[] = { R_ARM_ABS32, 0 }; + *rel8_types = rel8; + *rel4_types = rel4; + return 0; } diff --git a/backends/i386_init.c b/backends/i386_init.c index be9bbf90a..f7a3f3cb6 100644 --- a/backends/i386_init.c +++ b/backends/i386_init.c @@ -49,7 +49,7 @@ i386_init (elf, machine, eh, ehlen) /* We handle it. */ eh->name = "Intel 80386"; i386_init_reloc (eh); - HOOK (eh, reloc_simple_type); + HOOK (eh, reloc_simple_types); HOOK (eh, gotpc_reloc_check); HOOK (eh, core_note); generic_debugscn_p = eh->debugscn_p; diff --git a/backends/i386_symbol.c b/backends/i386_symbol.c index 5d6c0efd8..de1410325 100644 --- a/backends/i386_symbol.c +++ b/backends/i386_symbol.c @@ -1,5 +1,5 @@ /* i386 specific symbolic name handling. - Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc. + Copyright (C) 2000-2010 Red Hat, Inc. This file is part of Red Hat elfutils. Written by Ulrich Drepper , 2000. @@ -45,20 +45,15 @@ i386_gotpc_reloc_check (Elf *elf __attribute__ ((unused)), int type) } /* Check for the simple reloc types. */ -Elf_Type -i386_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type) +int +i386_reloc_simple_types (Ebl *ebl __attribute__ ((unused)), + const int **rel8_types, const int **rel4_types) { - switch (type) - { - case R_386_32: - return ELF_T_SWORD; - case R_386_16: - return ELF_T_HALF; - case R_386_8: - return ELF_T_BYTE; - default: - return ELF_T_NUM; - } + static const int rel8[] = { 0 }; + static const int rel4[] = { R_386_32, 0 }; + *rel8_types = rel8; + *rel4_types = rel4; + return 0; } /* Check section name for being that of a debug information section. */ diff --git a/backends/ia64_init.c b/backends/ia64_init.c index 290c192c8..0e60b1984 100644 --- a/backends/ia64_init.c +++ b/backends/ia64_init.c @@ -49,7 +49,7 @@ ia64_init (elf, machine, eh, ehlen) /* We handle it. */ eh->name = "Intel IA-64"; ia64_init_reloc (eh); - HOOK (eh, reloc_simple_type); + HOOK (eh, reloc_simple_types); HOOK (eh, segment_type_name); HOOK (eh, section_type_name); HOOK (eh, dynamic_tag_name); diff --git a/backends/ia64_symbol.c b/backends/ia64_symbol.c index 1edef8b56..3bcd90907 100644 --- a/backends/ia64_symbol.c +++ b/backends/ia64_symbol.c @@ -1,5 +1,5 @@ /* IA-64 specific symbolic name handling. - Copyright (C) 2002-2009 Red Hat, Inc. + Copyright (C) 2002-2010 Red Hat, Inc. This file is part of Red Hat elfutils. Written by Ulrich Drepper , 2002. @@ -110,38 +110,30 @@ ia64_section_type_name (int type, return NULL; } + /* Check for the simple reloc types. */ -Elf_Type -ia64_reloc_simple_type (Ebl *ebl, int type) +int +ia64_reloc_simple_types (Ebl *ebl, + const int **rel8_types, const int **rel4_types) { - switch (type) + /* The SECREL types when used with non-allocated sections + like .debug_* are the same as direct absolute relocs + applied to those sections, since a 0 section address is assumed. + So we treat them the same here. */ + + if (ebl->data == ELFDATA2MSB) { - /* The SECREL types when used with non-allocated sections - like .debug_* are the same as direct absolute relocs - applied to those sections, since a 0 section address is assumed. - So we treat them the same here. */ - - case R_IA64_SECREL32MSB: - case R_IA64_DIR32MSB: - if (ebl->data == ELFDATA2MSB) - return ELF_T_WORD; - break; - case R_IA64_SECREL32LSB: - case R_IA64_DIR32LSB: - if (ebl->data == ELFDATA2LSB) - return ELF_T_WORD; - break; - case R_IA64_DIR64MSB: - case R_IA64_SECREL64MSB: - if (ebl->data == ELFDATA2MSB) - return ELF_T_XWORD; - break; - case R_IA64_SECREL64LSB: - case R_IA64_DIR64LSB: - if (ebl->data == ELFDATA2LSB) - return ELF_T_XWORD; - break; + static const int rel8msb[] = { R_IA64_DIR64MSB, R_IA64_SECREL64MSB, 0 }; + static const int rel4msb[] = { R_IA64_DIR32MSB, R_IA64_SECREL32MSB, 0 }; + *rel8_types = rel8msb; + *rel4_types = rel4msb; } - - return ELF_T_NUM; + else + { + static const int rel8lsb[] = { R_IA64_DIR64LSB, R_IA64_SECREL64LSB, 0 }; + static const int rel4lsb[] = { R_IA64_DIR32LSB, R_IA64_SECREL32LSB, 0 }; + *rel8_types = rel8lsb; + *rel4_types = rel4lsb; + } + return 0; } diff --git a/backends/ppc64_init.c b/backends/ppc64_init.c index 3060a6055..ab6df8370 100644 --- a/backends/ppc64_init.c +++ b/backends/ppc64_init.c @@ -50,7 +50,7 @@ ppc64_init (elf, machine, eh, ehlen) /* We handle it. */ eh->name = "PowerPC 64-bit"; ppc64_init_reloc (eh); - HOOK (eh, reloc_simple_type); + HOOK (eh, reloc_simple_types); HOOK (eh, dynamic_tag_name); HOOK (eh, dynamic_tag_check); HOOK (eh, copy_reloc_p); diff --git a/backends/ppc64_symbol.c b/backends/ppc64_symbol.c index 49fde0ca7..d841c1ad5 100644 --- a/backends/ppc64_symbol.c +++ b/backends/ppc64_symbol.c @@ -1,5 +1,5 @@ /* PPC64 specific symbolic name handling. - Copyright (C) 2004, 2005 Red Hat, Inc. + Copyright (C) 2004-2010 Red Hat, Inc. This file is part of Red Hat elfutils. Written by Ulrich Drepper , 2004. @@ -38,25 +38,17 @@ /* Check for the simple reloc types. */ -Elf_Type -ppc64_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type) +int +ppc64_reloc_simple_types (Ebl *ebl __attribute__ ((unused)), + const int **rel8_types, const int **rel4_types) { - switch (type) - { - case R_PPC64_ADDR64: - case R_PPC64_UADDR64: - return ELF_T_XWORD; - case R_PPC64_ADDR32: - case R_PPC64_UADDR32: - return ELF_T_WORD; - case R_PPC64_UADDR16: - return ELF_T_HALF; - default: - return ELF_T_NUM; - } + static const int rel8[] = { R_PPC64_ADDR64, R_PPC64_UADDR64, 0 }; + static const int rel4[] = { R_PPC64_ADDR32, R_PPC64_UADDR32, 0 }; + *rel8_types = rel8; + *rel4_types = rel4; + return 0; } - const char * ppc64_dynamic_tag_name (int64_t tag, char *buf __attribute__ ((unused)), size_t len __attribute__ ((unused))) diff --git a/backends/ppc_init.c b/backends/ppc_init.c index 523c65839..2d5e163aa 100644 --- a/backends/ppc_init.c +++ b/backends/ppc_init.c @@ -50,7 +50,7 @@ ppc_init (elf, machine, eh, ehlen) /* We handle it. */ eh->name = "PowerPC"; ppc_init_reloc (eh); - HOOK (eh, reloc_simple_type); + HOOK (eh, reloc_simple_types); HOOK (eh, dynamic_tag_name); HOOK (eh, dynamic_tag_check); HOOK (eh, check_special_symbol); diff --git a/backends/ppc_symbol.c b/backends/ppc_symbol.c index 9540a3e9c..9110ae75b 100644 --- a/backends/ppc_symbol.c +++ b/backends/ppc_symbol.c @@ -1,5 +1,5 @@ /* PPC specific symbolic name handling. - Copyright (C) 2004, 2005, 2007 Red Hat, Inc. + Copyright (C) 2004-2010 Red Hat, Inc. This file is part of Red Hat elfutils. Written by Ulrich Drepper , 2004. @@ -38,22 +38,19 @@ /* Check for the simple reloc types. */ -Elf_Type -ppc_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type) +int +ppc_reloc_simple_types (Ebl *ebl __attribute__ ((unused)), + const int **rel8_types, const int **rel4_types) { - switch (type) - { - case R_PPC_ADDR32: - case R_PPC_UADDR32: - return ELF_T_WORD; - case R_PPC_UADDR16: - return ELF_T_HALF; - default: - return ELF_T_NUM; - } + static const int rel8[] = { 0 }; + static const int rel4[] = { R_PPC_ADDR32, R_PPC_UADDR32, 0 }; + *rel8_types = rel8; + *rel4_types = rel4; + return 0; } + const char * ppc_dynamic_tag_name (int64_t tag, char *buf __attribute__ ((unused)), size_t len __attribute__ ((unused))) diff --git a/backends/s390_init.c b/backends/s390_init.c index 05ffce606..641e6a6ba 100644 --- a/backends/s390_init.c +++ b/backends/s390_init.c @@ -49,7 +49,7 @@ s390_init (elf, machine, eh, ehlen) /* We handle it. */ eh->name = "IBM S/390"; s390_init_reloc (eh); - HOOK (eh, reloc_simple_type); + HOOK (eh, reloc_simple_types); HOOK (eh, register_info); HOOK (eh, return_value_location); diff --git a/backends/s390_symbol.c b/backends/s390_symbol.c index 98c76530d..e93b4412e 100644 --- a/backends/s390_symbol.c +++ b/backends/s390_symbol.c @@ -1,5 +1,5 @@ /* S/390-specific symbolic name handling. - Copyright (C) 2005 Red Hat, Inc. + Copyright (C) 2005-2010 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -34,20 +34,13 @@ #include "libebl_CPU.h" /* Check for the simple reloc types. */ -Elf_Type -s390_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type) +int +s390_reloc_simple_types (Ebl *ebl __attribute__ ((unused)), + const int **rel8_types, const int **rel4_types) { - switch (type) - { - case R_390_64: - return ELF_T_SXWORD; - case R_390_32: - return ELF_T_SWORD; - case R_390_16: - return ELF_T_HALF; - case R_390_8: - return ELF_T_BYTE; - default: - return ELF_T_NUM; - } + static const int rel8[] = { R_390_64, 0 }; + static const int rel4[] = { R_390_32, 0 }; + *rel8_types = rel8; + *rel4_types = rel4; + return 0; } diff --git a/backends/sh_init.c b/backends/sh_init.c index 7b36e7a34..a1bf5d124 100644 --- a/backends/sh_init.c +++ b/backends/sh_init.c @@ -50,7 +50,7 @@ sh_init (elf, machine, eh, ehlen) /* We handle it. */ eh->name = "Hitachi SH"; sh_init_reloc (eh); - HOOK (eh, reloc_simple_type); + HOOK (eh, reloc_simple_types); HOOK (eh, gotpc_reloc_check); HOOK (eh, machine_flag_check); HOOK (eh, core_note); diff --git a/backends/sh_symbol.c b/backends/sh_symbol.c index 9fb5db44b..48e629b8e 100644 --- a/backends/sh_symbol.c +++ b/backends/sh_symbol.c @@ -1,5 +1,5 @@ /* SH specific relocation handling. - Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc. + Copyright (C) 2000-2010 Red Hat, Inc. This file is part of Red Hat elfutils. Written by Ulrich Drepper , 2000. @@ -43,16 +43,15 @@ sh_gotpc_reloc_check (Elf *elf __attribute__ ((unused)), int type) } /* Check for the simple reloc types. */ -Elf_Type -sh_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type) +int +sh_reloc_simple_types (Ebl *ebl __attribute__ ((unused)), + const int **rel8_types, const int **rel4_types) { - switch (type) - { - case R_SH_DIR32: - return ELF_T_WORD; - default: - return ELF_T_NUM; - } + static const int rel8[] = { 0 }; + static const int rel4[] = { R_SH_DIR32, 0 }; + *rel8_types = rel8; + *rel4_types = rel4; + return 0; } /* Check whether machine flags are valid. */ diff --git a/backends/sparc_init.c b/backends/sparc_init.c index 856bd48cb..2fbfefe68 100644 --- a/backends/sparc_init.c +++ b/backends/sparc_init.c @@ -55,7 +55,7 @@ sparc_init (elf, machine, eh, ehlen) else eh->name = "SPARC"; sparc_init_reloc (eh); - HOOK (eh, reloc_simple_type); + HOOK (eh, reloc_simple_types); HOOK (eh, machine_flag_check); HOOK (eh, check_special_section); HOOK (eh, symbol_type_name); diff --git a/backends/sparc_symbol.c b/backends/sparc_symbol.c index 7896e9f46..713817fdc 100644 --- a/backends/sparc_symbol.c +++ b/backends/sparc_symbol.c @@ -1,5 +1,5 @@ /* SPARC specific symbolic name handling. - Copyright (C) 2002, 2003, 2005, 2007, 2008 Red Hat, Inc. + Copyright (C) 2002-2010 Red Hat, Inc. This file is part of Red Hat elfutils. Written by Jakub Jelinek , 2002. @@ -35,25 +35,15 @@ #include "libebl_CPU.h" /* Check for the simple reloc types. */ -Elf_Type -sparc_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type) +int +sparc_reloc_simple_types (Ebl *ebl __attribute__ ((unused)), + const int **rel8_types, const int **rel4_types) { - switch (type) - { - case R_SPARC_8: - return ELF_T_BYTE; - case R_SPARC_16: - case R_SPARC_UA16: - return ELF_T_HALF; - case R_SPARC_32: - case R_SPARC_UA32: - return ELF_T_WORD; - case R_SPARC_64: - case R_SPARC_UA64: - return ELF_T_XWORD; - default: - return ELF_T_NUM; - } + static const int rel8[] = { R_SPARC_64, R_SPARC_UA64, 0 }; + static const int rel4[] = { R_SPARC_32, R_SPARC_UA32, 0 }; + *rel8_types = rel8; + *rel4_types = rel4; + return 0; } /* Check whether machine flags are valid. */ diff --git a/backends/x86_64_init.c b/backends/x86_64_init.c index 32f32e023..556104322 100644 --- a/backends/x86_64_init.c +++ b/backends/x86_64_init.c @@ -49,7 +49,7 @@ x86_64_init (elf, machine, eh, ehlen) /* We handle it. */ eh->name = "AMD x86-64"; x86_64_init_reloc (eh); - HOOK (eh, reloc_simple_type); + HOOK (eh, reloc_simple_types); HOOK (eh, core_note); HOOK (eh, return_value_location); HOOK (eh, register_info); diff --git a/backends/x86_64_symbol.c b/backends/x86_64_symbol.c index 97fd15b39..a31fbeabe 100644 --- a/backends/x86_64_symbol.c +++ b/backends/x86_64_symbol.c @@ -1,7 +1,6 @@ /* x86_64 specific symbolic name handling. - Copyright (C) 2002, 2005 Red Hat, Inc. + Copyright (C) 2002-2010 Red Hat, Inc. This file is part of Red Hat elfutils. - Written by Ulrich Drepper , 2002. Red Hat elfutils is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -35,23 +34,15 @@ #define BACKEND x86_64_ #include "libebl_CPU.h" + /* Check for the simple reloc types. */ -Elf_Type -x86_64_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type) +int +x86_64_reloc_simple_types (Ebl *ebl __attribute__ ((unused)), + const int **rel8_types, const int **rel4_types) { - switch (type) - { - case R_X86_64_64: - return ELF_T_XWORD; - case R_X86_64_32: - return ELF_T_WORD; - case R_X86_64_32S: - return ELF_T_SWORD; - case R_X86_64_16: - return ELF_T_HALF; - case R_X86_64_8: - return ELF_T_BYTE; - default: - return ELF_T_NUM; - } + static const int rel8[] = { R_X86_64_64, 0 }; + static const int rel4[] = { R_X86_64_32, R_X86_64_32S, 0 }; + *rel8_types = rel8; + *rel4_types = rel4; + return 0; } diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 34c7ba314..021996d94 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,5 +1,8 @@ 2010-06-20 Roland McGrath + * cfi.h (BYTE_ORDER_DUMMY): Macro moved ... + * memory-access.h: ... here. + * libdw_findcu.c (__libdw_findcu): Take new flag argument, to search TUs instead of CUs. * libdwP.h: Update decl. diff --git a/libdw/cfi.h b/libdw/cfi.h index ef9cd7e1b..b0d496394 100644 --- a/libdw/cfi.h +++ b/libdw/cfi.h @@ -240,13 +240,6 @@ extern int __libdw_frame_at_address (Dwarf_CFI *cache, struct dwarf_fde *fde, __nonnull_attribute__ (1, 2, 4) internal_function; -/* Dummy struct for memory-access.h macros. */ -#define BYTE_ORDER_DUMMY(var, e_ident) \ - const struct { bool other_byte_order; } var = \ - { ((BYTE_ORDER == LITTLE_ENDIAN && e_ident[EI_DATA] == ELFDATA2MSB) \ - || (BYTE_ORDER == BIG_ENDIAN && e_ident[EI_DATA] == ELFDATA2LSB)) } - - INTDECL (dwarf_next_cfi) INTDECL (dwarf_getcfi) INTDECL (dwarf_getcfi_elf) diff --git a/libdw/memory-access.h b/libdw/memory-access.h index 13f79ec2a..202119343 100644 --- a/libdw/memory-access.h +++ b/libdw/memory-access.h @@ -1,5 +1,5 @@ /* Unaligned memory access functionality. - Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2009 Red Hat, Inc. + Copyright (C) 2000-2010 Red Hat, Inc. This file is part of Red Hat elfutils. Written by Ulrich Drepper , 2001. @@ -308,4 +308,10 @@ read_8sbyte_unaligned_1 (bool other_byte_order, const void *p) : (Nbytes) == 4 ? read_4sbyte_unaligned_inc (Dbg, Addr) \ : read_8sbyte_unaligned_inc (Dbg, Addr)) +/* Dummy struct for memory-access.h macros. */ +#define BYTE_ORDER_DUMMY(var, e_ident) \ + const struct { bool other_byte_order; } var = \ + { ((BYTE_ORDER == LITTLE_ENDIAN && e_ident[EI_DATA] == ELFDATA2MSB) \ + || (BYTE_ORDER == BIG_ENDIAN && e_ident[EI_DATA] == ELFDATA2LSB)) } + #endif /* memory-access.h */ diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index ff850ebff..f1887aed5 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,11 @@ +2010-06-20 Roland McGrath + + * relocate.c (struct reloc_symtab_cache): New members + rel8_types and rel4_types. + (relocate_section): Use ebl_reloc_simple_types instead of old + ebl_reloc_simple_type. Handle only 4 and 8 byte quantities, + and don't use gelf_xlatetom. + 2010-06-16 Roland McGrath * cu.c (cudie_offset): Use DIE_OFFSET_FROM_CU_OFFSET macro. diff --git a/libdwfl/relocate.c b/libdwfl/relocate.c index 0075c7f90..cb64fa26e 100644 --- a/libdwfl/relocate.c +++ b/libdwfl/relocate.c @@ -108,6 +108,8 @@ __libdwfl_relocate_value (Dwfl_Module *mod, Elf *elf, size_t *shstrndx, /* Cache used by relocate_getsym. */ struct reloc_symtab_cache { + const int *rel8_types; + const int *rel4_types; Elf *symelf; Elf_Data *symdata; Elf_Data *symxndxdata; @@ -117,7 +119,7 @@ struct reloc_symtab_cache }; #define RELOC_SYMTAB_CACHE(cache) \ struct reloc_symtab_cache cache = \ - { NULL, NULL, NULL, NULL, SHN_UNDEF, SHN_UNDEF } + { NULL, NULL, NULL, NULL, NULL, NULL, SHN_UNDEF, SHN_UNDEF } /* This is just doing dwfl_module_getsym, except that we must always use the symbol table in RELOCATED itself when it has one, not MOD->symfile. */ @@ -319,6 +321,15 @@ relocate_section (Dwfl_Module *mod, Elf *relocated, const GElf_Ehdr *ehdr, if (tdata == NULL) return DWFL_E_LIBELF; + if (reloc_symtab->rel8_types == NULL) + { + ebl_reloc_simple_types (mod->ebl, + &reloc_symtab->rel8_types, + &reloc_symtab->rel4_types); + assert (reloc_symtab->rel8_types != NULL); + assert (reloc_symtab->rel4_types != NULL); + } + /* Apply one relocation. Returns true for any invalid data. */ Dwfl_Error relocate (GElf_Addr offset, const GElf_Sxword *addend, int rtype, int symndx) @@ -334,10 +345,6 @@ relocate_section (Dwfl_Module *mod, Elf *relocated, const GElf_Ehdr *ehdr, So we just pretend it's OK without further relocation. */ return DWFL_E_NOERROR; - Elf_Type type = ebl_reloc_simple_type (mod->ebl, rtype); - if (unlikely (type == ELF_T_NUM)) - return DWFL_E_BADRELTYPE; - /* First, resolve the symbol to an absolute value. */ GElf_Addr value; @@ -371,90 +378,47 @@ relocate_section (Dwfl_Module *mod, Elf *relocated, const GElf_Ehdr *ehdr, } /* These are the types we can relocate. */ -#define TYPES DO_TYPE (BYTE, Byte); DO_TYPE (HALF, Half); \ - DO_TYPE (WORD, Word); DO_TYPE (SWORD, Sword); \ - DO_TYPE (XWORD, Xword); DO_TYPE (SXWORD, Sxword) - size_t size; - switch (type) + size_t size = 4; + for (const int *tp = reloc_symtab->rel8_types; *tp != 0; ++tp) + if (*tp == rtype) + { + size = 8; + break; + } + if (size == 4) { -#define DO_TYPE(NAME, Name) \ - case ELF_T_##NAME: \ - size = sizeof (GElf_##Name); \ - break - TYPES; -#undef DO_TYPE - default: - return DWFL_E_BADRELTYPE; + const int *tp = reloc_symtab->rel4_types; + while (*tp != 0 && *tp != rtype) + ++tp; + if (unlikely (*tp == 0)) + return DWFL_E_BADRELTYPE; } if (offset + size > tdata->d_size) return DWFL_E_BADRELOFF; -#define DO_TYPE(NAME, Name) GElf_##Name Name; - union { TYPES; } tmpbuf; -#undef DO_TYPE - Elf_Data tmpdata = - { - .d_type = type, - .d_buf = &tmpbuf, - .d_size = size, - .d_version = EV_CURRENT, - }; - Elf_Data rdata = - { - .d_type = type, - .d_buf = tdata->d_buf + offset, - .d_size = size, - .d_version = EV_CURRENT, - }; + BYTE_ORDER_DUMMY (bo, ehdr->e_ident); /* XXX check for overflow? */ if (addend) + /* For the addend form, we have the value already. */ + value += *addend; + else if (size == 8) + value += read_8ubyte_unaligned (&bo, tdata->d_buf + offset); + else + value += read_4ubyte_unaligned (&bo, tdata->d_buf + offset); + + if (size == 8) { - /* For the addend form, we have the value already. */ - value += *addend; - switch (type) - { -#define DO_TYPE(NAME, Name) \ - case ELF_T_##NAME: \ - tmpbuf.Name = value; \ - break - TYPES; -#undef DO_TYPE - default: - abort (); - } + uint64_t v = bo.other_byte_order ? bswap_64 (value) : value; + memcpy (tdata->d_buf + offset, &v, sizeof v); } else { - /* Extract the original value and apply the reloc. */ - Elf_Data *d = gelf_xlatetom (relocated, &tmpdata, &rdata, - ehdr->e_ident[EI_DATA]); - if (d == NULL) - return DWFL_E_LIBELF; - assert (d == &tmpdata); - switch (type) - { -#define DO_TYPE(NAME, Name) \ - case ELF_T_##NAME: \ - tmpbuf.Name += (GElf_##Name) value; \ - break - TYPES; -#undef DO_TYPE - default: - abort (); - } + uint32_t v = bo.other_byte_order ? bswap_32 (value) : value; + memcpy (tdata->d_buf + offset, &v, sizeof v); } - /* Now convert the relocated datum back to the target - format. This will write into rdata.d_buf, which - points into the raw section data being relocated. */ - Elf_Data *s = gelf_xlatetof (relocated, &rdata, &tmpdata, - ehdr->e_ident[EI_DATA]); - if (s == NULL) - return DWFL_E_LIBELF; - assert (s == &rdata); - /* We have applied this relocation! */ return DWFL_E_NOERROR; } diff --git a/libebl/ChangeLog b/libebl/ChangeLog index ed9361c1f..c8afad76b 100644 --- a/libebl/ChangeLog +++ b/libebl/ChangeLog @@ -1,3 +1,14 @@ +2010-06-20 Roland McGrath + + * ebl-hooks.h: Replace reloc_simple_type with reloc_simple_types. + * libebl.h: Likewise. + * eblrelocsimpletypes.c: New file. + * eblrelocsimpletype.c: File removed. + * Makefile.am (gen_SOURCES): Updated. + * eblopenbackend.c (default_reloc_simple_types): New function. + (default_reloc_simple_type): Removed. + (fill_defaults): Update initializer. + 2010-02-15 Roland McGrath * Makefile.am: Use config/eu.am for common stuff. diff --git a/libebl/Makefile.am b/libebl/Makefile.am index d157195ef..2e86515f8 100644 --- a/libebl/Makefile.am +++ b/libebl/Makefile.am @@ -42,7 +42,7 @@ gen_SOURCES = eblopenbackend.c eblclosebackend.c eblstrtab.c \ eblbackendname.c eblshflagscombine.c eblwstrtab.c \ eblgstrtab.c eblosabiname.c \ eblmachineflagcheck.c eblmachinesectionflagcheck.c \ - eblreloctypecheck.c eblrelocvaliduse.c eblrelocsimpletype.c \ + eblreloctypecheck.c eblrelocvaliduse.c eblrelocsimpletypes.c \ ebldynamictagcheck.c eblcorenotetypename.c eblobjnotetypename.c \ eblcorenote.c eblobjnote.c ebldebugscnp.c \ eblgotpcreloccheck.c eblcopyrelocp.c eblsectionstripp.c \ diff --git a/libebl/ebl-hooks.h b/libebl/ebl-hooks.h index 59e73c54e..cb6555929 100644 --- a/libebl/ebl-hooks.h +++ b/libebl/ebl-hooks.h @@ -56,8 +56,9 @@ const char *EBLHOOK(reloc_type_name) (int, char *, size_t); /* Check relocation type. */ bool EBLHOOK(reloc_type_check) (int); -/* Check if relocation type is for simple absolute relocations. */ -Elf_Type EBLHOOK(reloc_simple_type) (Ebl *, int); +/* Return list of relocation types for simple absolute relocations. */ +int EBLHOOK(reloc_simple_types) (Ebl *, const int **rel8_types, + const int **rel4_types); /* Check relocation type use. */ bool EBLHOOK(reloc_valid_use) (Elf *, int); diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c index edd8c4a75..7b1215f1d 100644 --- a/libebl/eblopenbackend.c +++ b/libebl/eblopenbackend.c @@ -161,7 +161,9 @@ static const char *default_object_type_name (int ignore, char *buf, static const char *default_reloc_type_name (int ignore, char *buf, size_t len); static bool default_reloc_type_check (int ignore); static bool default_reloc_valid_use (Elf *elf, int ignore); -static Elf_Type default_reloc_simple_type (Ebl *ebl, int ignore); +static int default_reloc_simple_types (Ebl *ebl, + const int **rel8_types, + const int **rel4_types); static bool default_gotpc_reloc_check (Elf *elf, int ignore); static const char *default_segment_type_name (int ignore, char *buf, size_t len); @@ -228,7 +230,7 @@ fill_defaults (Ebl *result) result->reloc_type_name = default_reloc_type_name; result->reloc_type_check = default_reloc_type_check; result->reloc_valid_use = default_reloc_valid_use; - result->reloc_simple_type = default_reloc_simple_type; + result->reloc_simple_types = default_reloc_simple_types; result->gotpc_reloc_check = default_gotpc_reloc_check; result->segment_type_name = default_segment_type_name; result->section_type_name = default_section_type_name; @@ -472,11 +474,13 @@ default_reloc_valid_use (Elf *elf __attribute__ ((unused)), return false; } -static Elf_Type -default_reloc_simple_type (Ebl *eh __attribute__ ((unused)), - int ignore __attribute__ ((unused))) +static int +default_reloc_simple_types (Ebl *ebl __attribute__ ((unused)), + const int **rel8_types, const int **rel4_types) { - return ELF_T_NUM; + static const int norel[] = { 0 }; + *rel8_types = *rel4_types = norel; + return 0; } static bool diff --git a/libebl/eblrelocsimpletype.c b/libebl/eblrelocsimpletypes.c similarity index 92% rename from libebl/eblrelocsimpletype.c rename to libebl/eblrelocsimpletypes.c index 87eb5a892..f9f7164ac 100644 --- a/libebl/eblrelocsimpletype.c +++ b/libebl/eblrelocsimpletypes.c @@ -1,5 +1,5 @@ /* Check relocation type for simple types. - Copyright (C) 2005 Red Hat, Inc. + Copyright (C) 2010 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -54,10 +54,12 @@ #include -Elf_Type -ebl_reloc_simple_type (ebl, reloc) +int +ebl_reloc_simple_types (ebl, rel8_types, rel4_types) Ebl *ebl; - int reloc; + const int **rel8_types; + const int **rel4_types; { - return ebl != NULL ? ebl->reloc_simple_type (ebl, reloc) : ELF_T_NUM; + return ebl == NULL ? -1 + : ebl->reloc_simple_types (ebl, rel8_types, rel4_types); } diff --git a/libebl/libebl.h b/libebl/libebl.h index c94ad78f2..f32dd5acf 100644 --- a/libebl/libebl.h +++ b/libebl/libebl.h @@ -110,9 +110,12 @@ extern bool ebl_reloc_type_check (Ebl *ebl, int reloc); /* Check relocation type use. */ extern bool ebl_reloc_valid_use (Ebl *ebl, int reloc); -/* Check if relocation type is for simple absolute relocations. - Return ELF_T_{BYTE,HALF,SWORD,SXWORD} for a simple type, else ELF_T_NUM. */ -extern Elf_Type ebl_reloc_simple_type (Ebl *ebl, int reloc); +/* Return lists of the relocation types for simple absolute relocations. + Each list is terminated by a 0 element. */ +extern int ebl_reloc_simple_types (Ebl *ebl, + const int **rel8_types, + const int **rel4_types) + __nonnull_attribute__ (2, 3); /* Return true if the symbol type is that referencing the GOT. E.g., R_386_GOTPC. */