OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-6.8/] [include/] [elf/] [reloc-macros.h] - Diff between revs 827 and 840

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 827 Rev 840
/* Generic relocation support for BFD.
/* Generic relocation support for BFD.
   Copyright 1998, 1999, 2000, 2003 Free Software Foundation, Inc.
   Copyright 1998, 1999, 2000, 2003 Free Software Foundation, Inc.
 
 
   This file is part of BFD, the Binary File Descriptor library.
   This file is part of BFD, the Binary File Descriptor library.
 
 
   This program is free software; you can redistribute it and/or modify
   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
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
   (at your option) any later version.
 
 
   This program is distributed in the hope that it will be useful,
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   GNU General Public License for more details.
 
 
   You should have received a copy of the GNU General Public License
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software Foundation,
   along with this program; if not, write to the Free Software Foundation,
   Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
   Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 
/* These macros are used by the various *.h target specific header
/* These macros are used by the various *.h target specific header
   files to either generate an enum containing all the known relocations
   files to either generate an enum containing all the known relocations
   for that target, or if RELOC_MACROS_GEN_FUNC is defined, a recognition
   for that target, or if RELOC_MACROS_GEN_FUNC is defined, a recognition
   function is generated instead.  (This is used by binutils/readelf.c)
   function is generated instead.  (This is used by binutils/readelf.c)
 
 
   Given a header file like this:
   Given a header file like this:
 
 
        START_RELOC_NUMBERS (foo)
        START_RELOC_NUMBERS (foo)
            RELOC_NUMBER (R_foo_NONE,    0)
            RELOC_NUMBER (R_foo_NONE,    0)
            RELOC_NUMBER (R_foo_32,      1)
            RELOC_NUMBER (R_foo_32,      1)
            EMPTY_RELOC  (R_foo_good)
            EMPTY_RELOC  (R_foo_good)
            FAKE_RELOC   (R_foo_illegal, 9)
            FAKE_RELOC   (R_foo_illegal, 9)
        END_RELOC_NUMBERS (R_foo_count)
        END_RELOC_NUMBERS (R_foo_count)
 
 
   Then the following will be produced by default (ie if
   Then the following will be produced by default (ie if
   RELOC_MACROS_GEN_FUNC is *not* defined).
   RELOC_MACROS_GEN_FUNC is *not* defined).
 
 
        enum foo
        enum foo
        {
        {
          R_foo_NONE = 0,
          R_foo_NONE = 0,
          R_foo_32 = 1,
          R_foo_32 = 1,
          R_foo_good,
          R_foo_good,
          R_foo_illegal = 9,
          R_foo_illegal = 9,
          R_foo_count
          R_foo_count
        };
        };
 
 
   Note: The value of the symbol defined in the END_RELOC_NUMBERS
   Note: The value of the symbol defined in the END_RELOC_NUMBERS
   macro (R_foo_count in the case of the example above) will be
   macro (R_foo_count in the case of the example above) will be
   set to the value of the whichever *_RELOC macro preceeds it plus
   set to the value of the whichever *_RELOC macro preceeds it plus
   one.  Therefore if you intend to use the symbol as a sentinel for
   one.  Therefore if you intend to use the symbol as a sentinel for
   the highest valid macro value you should make sure that the
   the highest valid macro value you should make sure that the
   preceeding *_RELOC macro is the highest valid number.  ie a
   preceeding *_RELOC macro is the highest valid number.  ie a
   declaration like this:
   declaration like this:
 
 
        START_RELOC_NUMBERS (foo)
        START_RELOC_NUMBERS (foo)
            RELOC_NUMBER (R_foo_NONE,    0)
            RELOC_NUMBER (R_foo_NONE,    0)
            RELOC_NUMBER (R_foo_32,      1)
            RELOC_NUMBER (R_foo_32,      1)
            FAKE_RELOC   (R_foo_illegal, 9)
            FAKE_RELOC   (R_foo_illegal, 9)
            FAKE_RELOC   (R_foo_synonym, 0)
            FAKE_RELOC   (R_foo_synonym, 0)
        END_RELOC_NUMBERS (R_foo_count)
        END_RELOC_NUMBERS (R_foo_count)
 
 
   will result in R_foo_count having a value of 1 (R_foo_synonym + 1)
   will result in R_foo_count having a value of 1 (R_foo_synonym + 1)
   rather than 10 or 2 as might be expected.
   rather than 10 or 2 as might be expected.
 
 
   Alternatively you can assign a value to END_RELOC_NUMBERS symbol
   Alternatively you can assign a value to END_RELOC_NUMBERS symbol
   explicitly, like this:
   explicitly, like this:
 
 
        START_RELOC_NUMBERS (foo)
        START_RELOC_NUMBERS (foo)
            RELOC_NUMBER (R_foo_NONE,    0)
            RELOC_NUMBER (R_foo_NONE,    0)
            RELOC_NUMBER (R_foo_32,      1)
            RELOC_NUMBER (R_foo_32,      1)
            FAKE_RELOC   (R_foo_illegal, 9)
            FAKE_RELOC   (R_foo_illegal, 9)
            FAKE_RELOC   (R_foo_synonym, 0)
            FAKE_RELOC   (R_foo_synonym, 0)
        END_RELOC_NUMBERS (R_foo_count = 2)
        END_RELOC_NUMBERS (R_foo_count = 2)
 
 
   If RELOC_MACROS_GEN_FUNC *is* defined, then instead the
   If RELOC_MACROS_GEN_FUNC *is* defined, then instead the
   following function will be generated:
   following function will be generated:
 
 
        static const char *foo (unsigned long rtype);
        static const char *foo (unsigned long rtype);
        static const char *
        static const char *
        foo (unsigned long rtype)
        foo (unsigned long rtype)
        {
        {
           switch (rtype)
           switch (rtype)
           {
           {
           case 0: return "R_foo_NONE";
           case 0: return "R_foo_NONE";
           case 1: return "R_foo_32";
           case 1: return "R_foo_32";
           default: return NULL;
           default: return NULL;
           }
           }
        }
        }
   */
   */
 
 
#ifndef _RELOC_MACROS_H
#ifndef _RELOC_MACROS_H
#define _RELOC_MACROS_H
#define _RELOC_MACROS_H
 
 
#ifdef RELOC_MACROS_GEN_FUNC
#ifdef RELOC_MACROS_GEN_FUNC
 
 
/* This function takes the relocation number and returns the
/* This function takes the relocation number and returns the
   string version name of the name of that relocation.  If
   string version name of the name of that relocation.  If
   the relocation is not recognised, NULL is returned.  */
   the relocation is not recognised, NULL is returned.  */
 
 
#define START_RELOC_NUMBERS(name)                               \
#define START_RELOC_NUMBERS(name)                               \
static const char *name (unsigned long rtype);                  \
static const char *name (unsigned long rtype);                  \
static const char *                                             \
static const char *                                             \
name (unsigned long rtype)                                      \
name (unsigned long rtype)                                      \
{                                                               \
{                                                               \
  switch (rtype)                                                \
  switch (rtype)                                                \
    {
    {
 
 
#define RELOC_NUMBER(name, number) \
#define RELOC_NUMBER(name, number) \
    case number: return #name;
    case number: return #name;
 
 
#define FAKE_RELOC(name, number)
#define FAKE_RELOC(name, number)
#define EMPTY_RELOC(name)
#define EMPTY_RELOC(name)
 
 
#define END_RELOC_NUMBERS(name) \
#define END_RELOC_NUMBERS(name) \
    default: return NULL;       \
    default: return NULL;       \
    }                           \
    }                           \
}
}
 
 
 
 
#else /* Default to generating enum.  */
#else /* Default to generating enum.  */
 
 
#define START_RELOC_NUMBERS(name)   enum name {
#define START_RELOC_NUMBERS(name)   enum name {
#define RELOC_NUMBER(name, number)  name = number,
#define RELOC_NUMBER(name, number)  name = number,
#define FAKE_RELOC(name, number)    name = number,
#define FAKE_RELOC(name, number)    name = number,
#define EMPTY_RELOC(name)           name,
#define EMPTY_RELOC(name)           name,
#define END_RELOC_NUMBERS(name)     name };
#define END_RELOC_NUMBERS(name)     name };
 
 
#endif
#endif
 
 
#endif /* _RELOC_MACROS_H */
#endif /* _RELOC_MACROS_H */
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.