Reloc macros tidied up. i386 and v850 reloc macros added.
authorNick Clifton <nickc@redhat.com>
Wed, 22 Jul 1998 23:27:31 +0000 (23:27 +0000)
committerNick Clifton <nickc@redhat.com>
Wed, 22 Jul 1998 23:27:31 +0000 (23:27 +0000)
New file created to contain reloc macros: reloc-macros.h

include/elf/ChangeLog
include/elf/arm.h
include/elf/mips.h
include/elf/mn10300.h
include/elf/ppc.h
include/elf/reloc-macros.h [new file with mode: 0644]
include/elf/sparc.h

index 3c217d4..4b63478 100644 (file)
@@ -1,3 +1,28 @@
+Wed Jul 22 16:22:11 1998  Nick Clifton  <nickc@cygnus.com>
+
+       * reloc-macros.h: New file.  Provides relocation macros:
+       START_RELOC_NUMBERS, RELOC_NUMBER, FAKE_RELOC, EMPTY_RELOC and
+       END_RELOC_NUMBERS used by other elf header files.
+       
+       * alpha.h: Use reloc-macros.h.
+       * arc.h: Use reloc-macros.h.
+       * arm.h: Use reloc-macros.h.
+       * d10v.h: Use reloc-macros.h.
+start-sanitize-d30v
+       * d30v.h: Use reloc-macros.h.
+end-sanitize-d30v
+       * hppa.h: Use reloc-macros.h.
+       * i386.h: Use reloc-macros.h.
+       * m32r.h: Use reloc-macros.h.
+       * m68k.h: Use reloc-macros.h.
+       * mips.h: Use reloc-macros.h.
+       * mn10200.h: Use reloc-macros.h.
+       * mn10300.h: Use reloc-macros.h.
+       * ppc.h: Use reloc-macros.h.
+       * sh.h: Use reloc-macros.h.
+       * sparc.h: Use reloc-macros.h.
+       * v850.h: Use reloc-macros.h.
+
 1998-07-22 13:07  Ulrich Drepper  <drepper@cygnus.com>
 
        * mn10300.h: Rewrite relocation definition using macros.
@@ -6,7 +31,9 @@
        * alpha.h: Likewise.
        * arm.h: Likewise.
        * d10v.h: Likewise.
+start-sanitize-d30v
        * d30v.h: Likewise.
+end-sanitize-d30v
        * m32r.h: Likewise.
        * m68k.h: Likewise.
        * mn10200.h: Likewise.
index a71feaa..7f13a71 100644 (file)
 #ifndef _ELF_ARM_H
 #define _ELF_ARM_H
 
-/* Unless otherwise told we define an enum with the relocation entries.  */
-#ifndef START_RELOC_NUMBERS
-# define START_RELOC_NUMBERS(name)   enum name {
-# define RELOC_NUMBER(name, number)  name = number ,
-# define END_RELOC_NUMBERS           };
-#endif
+#include "elf/reloc-macros.h"
 
 /* Relocation types.  */
 START_RELOC_NUMBERS (elf_arm_reloc_type)
index 0c023db..62ae632 100644 (file)
@@ -27,12 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #ifndef _ELF_MIPS_H
 #define _ELF_MIPS_H
 
-/* Unless otherwise told we define an enum with the relocation entries.  */
-#ifndef START_RELOC_NUMBERS
-# define START_RELOC_NUMBERS(name)   enum name {
-# define RELOC_NUMBER(name, number)  name = number ,
-# define END_RELOC_NUMBERS           };
-#endif
+#include "elf/reloc-macros.h"
 
 /* Relocation types.  */
 START_RELOC_NUMBERS (elf_mips_reloc_type)
index 1d64c40..79db776 100644 (file)
@@ -22,12 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #ifndef _ELF_MN10300_H
 #define _ELF_MN10300_H
 
-/* Unless otherwise told we define an enum with the relocation entries.  */
-#ifndef START_RELOC_NUMBERS
-# define START_RELOC_NUMBERS(name)   enum name {
-# define RELOC_NUMBER(name, number)  name = number ,
-# define END_RELOC_NUMBERS           };
-#endif
+#include "elf/reloc-macros.h"
 
 /* Relocations.  */
 START_RELOC_NUMBERS (elf_mn10300_reloc_type)
@@ -40,7 +35,7 @@ START_RELOC_NUMBERS (elf_mn10300_reloc_type)
   RELOC_NUMBER (R_MN10300_PCREL8, 6)
   RELOC_NUMBER (R_MN10300_GNU_VTINHERIT, 7)
   RELOC_NUMBER (R_MN10300_GNU_VTENTRY, 8)
-  RELOC_NUMBER (R_MN10300_MAX, 9)
+  EMPTY_RELOC  (R_MN10300_MAX)
 END_RELOC_NUMBERS
 
 /* Machine variant if we know it.  This field was invented at Cygnus,
index c577fdb..557ba37 100644 (file)
@@ -27,15 +27,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #ifndef _ELF_PPC_H
 #define _ELF_PPC_H
 
-/* Unless otherwise told we define an enum with the relocation entries.  */
-#ifndef START_RELOC_NUMBERS
-# define START_RELOC_NUMBERS(name)   enum name {
-# define RELOC_NUMBER(name, number)  name = number ,
-# define END_RELOC_NUMBERS           };
-#endif
+#include "elf/reloc-macros.h"
 
 /* Relocations.  */
-START_RELOC_NUMBERS (elf_ppc_reloc_type)
+START_RELOC_NUMBERS (ppc_reloc_type)
   RELOC_NUMBER (R_PPC_NONE, 0)
   RELOC_NUMBER (R_PPC_ADDR32, 1)
   RELOC_NUMBER (R_PPC_ADDR24, 2)
@@ -101,7 +96,7 @@ START_RELOC_NUMBERS (elf_ppc_reloc_type)
    that may still be in object files.  */
   RELOC_NUMBER (R_PPC_TOC16, 255)
 
-  RELOC_NUMBER (R_PPC_max, 256)
+  EMPTY_RELOC (R_PPC_max)
 END_RELOC_NUMBERS
 
 
diff --git a/include/elf/reloc-macros.h b/include/elf/reloc-macros.h
new file mode 100644 (file)
index 0000000..646dbe5
--- /dev/null
@@ -0,0 +1,103 @@
+/* Generic relocation support for BFD.
+   Copyright (C) 1998 Free Software Foundation, Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+/* These macros are used by the various elf/*.h target specific header
+   files to either generate an enum containing all the known relocations
+   for that target, or if RELOC_MACROS_GEN_FUNC is defined, a recognition
+   function is generated instead.  (This is used by binutils/readelf.c)
+
+   Given a header file like this:
+
+       START_RELOC_NUMBERS (foo)
+           RELOC_NUMBER (R_foo_NONE,    0)
+           RELOC_NUMBER (R_foo_32,      1)
+           FAKE_RELOC   (R_foo_illegal, 2)
+           EMPTY_RELOC  (R_foo_max)
+       END_RELOC_NUMBERS
+
+   Then the following will be produced by default (ie if
+   RELOC_MACROS_GEN_FUNC is *not* defined).
+
+       enum foo {
+         R_foo_NONE = 0,
+         R_foo_32 = 1,
+         R_foo_illegal = 2,
+         R_foo_max
+       };
+
+   If RELOC_MACROS_GEN_FUNC *is* defined, then instead the
+   following function will be generated:
+
+       static char * foo PARAMS ((unsigned long rtype));
+       static char *
+       foo (rtype)
+           unsigned long rtype;
+       {
+          switch (rtype)
+          {
+          case 0: return "R_foo_NONE";
+          case 1: return "R_foo_32";
+          default: return NULL;
+          }
+       }
+   */
+   
+#ifndef _RELOC_MACROS_H
+#define _RELOC_MACROS_H
+
+#ifdef RELOC_MACROS_GEN_FUNC
+
+/* This function takes the relocation number and returns the
+   string version name of the name of that relocation.  If
+   the relocation is not recognised, NULL is returned.  */
+
+#define START_RELOC_NUMBERS(name)                              \
+static const char * name    PARAMS ((unsigned long rtype));    \
+static const char *                                            \
+name (rtype)                                                   \
+       unsigned long rtype;                                    \
+{                                                              \
+  switch (rtype)                                               \
+  {
+
+#ifdef __STDC__                                          
+#define RELOC_NUMBER(name, number)  case number : return #name ;
+#else
+#define RELOC_NUMBER(name, number)  case number : return "name" ;
+#endif
+
+#define FAKE_RELOC(name, number)    
+#define EMPTY_RELOC(name)
+                                         
+#define END_RELOC_NUMBERS              default: return NULL;   \
+                                       }                       \
+                                   }
+
+
+#else /* default to generating enum */
+
+#define START_RELOC_NUMBERS(name)   enum name {
+#define RELOC_NUMBER(name, number)  name = number ,
+#define FAKE_RELOC(name, number)    name = number ,
+#define EMPTY_RELOC(name)           name ,
+#define END_RELOC_NUMBERS           };
+
+#endif
+
+#endif /* RELOC_MACROS_H */
index 91c71e6..f33314a 100644 (file)
@@ -55,12 +55,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #define STT_REGISTER           13              /* global reg reserved to app. */
 
-/* Unless otherwise told we define an enum with the relocation entries.  */
-#ifndef START_RELOC_NUMBERS
-# define START_RELOC_NUMBERS(name)   enum name {
-# define RELOC_NUMBER(name, number)  name = number ,
-# define END_RELOC_NUMBERS           };
-#endif
+#include "elf/reloc-macros.h"
 
 /* Relocation types.  */
 START_RELOC_NUMBERS (elf_sparc_reloc_type)