+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.
* 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.
#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)
#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)
#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)
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,
#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)
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
--- /dev/null
+/* 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 */
#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)