]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Replace ebl_reloc_simple_type with ebl_reloc_simple_types.
authorRoland McGrath <roland@redhat.com>
Mon, 21 Jun 2010 02:46:58 +0000 (19:46 -0700)
committerRoland McGrath <roland@redhat.com>
Mon, 21 Jun 2010 09:57:49 +0000 (02:57 -0700)
32 files changed:
backends/ChangeLog
backends/alpha_init.c
backends/alpha_symbol.c
backends/arm_init.c
backends/arm_symbol.c
backends/i386_init.c
backends/i386_symbol.c
backends/ia64_init.c
backends/ia64_symbol.c
backends/ppc64_init.c
backends/ppc64_symbol.c
backends/ppc_init.c
backends/ppc_symbol.c
backends/s390_init.c
backends/s390_symbol.c
backends/sh_init.c
backends/sh_symbol.c
backends/sparc_init.c
backends/sparc_symbol.c
backends/x86_64_init.c
backends/x86_64_symbol.c
libdw/ChangeLog
libdw/cfi.h
libdw/memory-access.h
libdwfl/ChangeLog
libdwfl/relocate.c
libebl/ChangeLog
libebl/Makefile.am
libebl/ebl-hooks.h
libebl/eblopenbackend.c
libebl/eblrelocsimpletypes.c [moved from libebl/eblrelocsimpletype.c with 92% similarity]
libebl/libebl.h

index 9fd9745d0e4699b00fcd34f2527ecf21da87ac20..7031ba34e1b24a7d101aa81aa45a0e3f0d19c2a0 100644 (file)
@@ -1,3 +1,26 @@
+2010-06-20  Roland McGrath  <roland@redhat.com>
+
+       * 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  <matt@console-pimps.org>
 
        * sh_corenote.c: New file.
index 1ca99abc52e723414c94f4e58d2082246eea6d18..2983982fb762f8fb6a08b2fc1fbbb9e44cefadef 100644 (file)
@@ -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);
index aa45c61ee576d975db8bba0f648b3004e24634a4..0e85f497579c0dce8c9ba8dd4544ebff4fc92817 100644 (file)
@@ -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 <drepper@redhat.com>, 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;
 }
 
 
index 15c0ee673978dd8a79103ba9f7dd9be2d057f5bc..c8122e657b1cdc8181130d8c0eb2af29242339d8 100644 (file)
@@ -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);
index e08874bbab8f08e446b2719506e7835e2c82205a..0cb1054aa3cf7c634f04e0dfbfa1d651736ce9e9 100644 (file)
@@ -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;
 }
index be9bbf90ac2fff399ce419d007d45337bd9bc468..f7a3f3cb6c6752eea2dd9699258188c47bf61261 100644 (file)
@@ -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;
index 5d6c0efd80ffaacca85854b188efc611f80a1b1e..de14103252515b14c6f3395f841984abd35c24d9 100644 (file)
@@ -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 <drepper@redhat.com>, 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.  */
index 290c192c882b2b7ae4b9f8f851310c1781082cbe..0e60b19845473f113f369e01ccf2d995adbb1792 100644 (file)
@@ -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);
index 1edef8b568eef4fd243cf7c12840923fcc3a72e3..3bcd90907760789e0dcfe61188cf0a915170541d 100644 (file)
@@ -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 <drepper@redhat.com>, 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;
 }
index 3060a605538964756d29e45c5f0c802c45b8a393..ab6df837064cfea79ccaad3444af84dd93197d9b 100644 (file)
@@ -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);
index 49fde0ca75f158471fd69605216a1e165d8d328c..d841c1ad54da011f574c4009807abf52d67889d3 100644 (file)
@@ -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 <drepper@redhat.com>, 2004.
 
 
 
 /* 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)))
index 523c658394c295acd53099866e6f6f3762f92429..2d5e163aa461028840c19a37c53f982e2318dd7e 100644 (file)
@@ -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);
index 9540a3e9cf52d71e3227e663c3da553b30805107..9110ae75b7f3f3184a1c7228474db4791c84d65c 100644 (file)
@@ -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 <drepper@redhat.com>, 2004.
 
 
 
 /* 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)))
index 05ffce606eca7715d3d2ccedb955cd0ae956ec3b..641e6a6ba768d1aa76570f78f7af75c7dfdcafea 100644 (file)
@@ -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);
 
index 98c76530d04db7a47bdbb4f153c27845c4526952..e93b4412eb5fcc258282d036826dc4fba5261da9 100644 (file)
@@ -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
 #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;
 }
index 7b36e7a34d5f4996cd838774abaaadf08f48d54c..a1bf5d12473a0019f86699bc50dc0fde1a75cdf2 100644 (file)
@@ -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);
index 9fb5db44b7b22fbad5f9f7843c475384de9c7d65..48e629b8e474f8b2c0e8b8a9854aee9d59bd7197 100644 (file)
@@ -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 <drepper@redhat.com>, 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.  */
index 856bd48cb4c092f25d1d70eac9deefe930ae23e6..2fbfefe689018cc4d8f0e300e094fbfd2c18665e 100644 (file)
@@ -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);
index 7896e9f469f9ef48522e95750c117817bab2a204..713817fdc7e625113702d9fa551d5c162466e7d8 100644 (file)
@@ -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 <jakub@redhat.com>, 2002.
 
 #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.  */
index 32f32e023d0253240f90219be312965a1c6afc6a..55610432201736bc3b2da352ab0904198e5b82f3 100644 (file)
@@ -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);
index 97fd15b398835eb60a9092f71c8784a96e230fa7..a31fbeabe995f1ab4859ec1fdc47a1bce37df808 100644 (file)
@@ -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 <drepper@redhat.com>, 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
 #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;
 }
index 34c7ba314f1e9ce57faf9a0558311ee40f3bfe9e..021996d9447c5f83fd1c2e610cdcfe5e19c6f37a 100644 (file)
@@ -1,5 +1,8 @@
 2010-06-20  Roland McGrath  <roland@redhat.com>
 
+       * 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.
index ef9cd7e1b37f9aaa090fa113f7ffaafaf54621b1..b0d4963947f7118716511de2b82887d9da448941 100644 (file)
@@ -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)
index 13f79ec2a78d5cbf67848b16804d3739040617da..20211934399e99ceed94671f4cb1d02b2571775c 100644 (file)
@@ -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 <drepper@redhat.com>, 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 */
index ff850ebff26c20f0dff1f3c774bbc6607415944b..f1887aed5cff5dc1032e2df7957dfeab1c86857f 100644 (file)
@@ -1,3 +1,11 @@
+2010-06-20  Roland McGrath  <roland@redhat.com>
+
+       * 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  <roland@redhat.com>
 
        * cu.c (cudie_offset): Use DIE_OFFSET_FROM_CU_OFFSET macro.
index 0075c7f90291b82d98389837712908dfa5197278..cb64fa26e36404767aa72973c8151cddcbb6221b 100644 (file)
@@ -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;
   }
index ed9361c1f26104dc5cb5d4ef2f143fde52ae18bb..c8afad76bf2ddb1198f0180a4b346d11d38d7a90 100644 (file)
@@ -1,3 +1,14 @@
+2010-06-20  Roland McGrath  <roland@redhat.com>
+
+       * 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  <roland@redhat.com>
 
        * Makefile.am: Use config/eu.am for common stuff.
index d157195ef5f0034a5269c5bb32d4cdae1db4b812..2e86515f8b593f516dc7f52c100a9736aca16e2e 100644 (file)
@@ -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 \
index 59e73c54e52400d3be8a648af8b043bb908a77fc..cb6555929d63063d17ed5070fa291b62541acda7 100644 (file)
@@ -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);
index edd8c4a756f4bc89d8cd894caaa8d4aff14c223f..7b1215f1dfb7cfb56f02f3541fa21bbcfaa3f466 100644 (file)
@@ -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
similarity index 92%
rename from libebl/eblrelocsimpletype.c
rename to libebl/eblrelocsimpletypes.c
index 87eb5a8928312d70c9108e97eca93c228603ed37..f9f7164ac4aef2f64c04995812c4b24b2b24d86d 100644 (file)
@@ -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
 #include <libeblP.h>
 
 
-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);
 }
index c94ad78f2079fc93be750ea2c08293c2ebb8cda4..f32dd5acfd406ccf812057a47bfd7e2d9adcf0e1 100644 (file)
@@ -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.  */