Reloc macros tidied up. i386 and v850 reloc macros added.

New file created to contain reloc macros: reloc-macros.h
This commit is contained in:
Nick Clifton 1998-07-22 23:27:31 +00:00
parent faac4767b1
commit 36dd637fc4
7 changed files with 138 additions and 33 deletions

View 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.

View File

@ -20,12 +20,7 @@
#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)

View 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)

View 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,

View 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

103
include/elf/reloc-macros.h Normal file
View File

@ -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 */

View 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)