Register NT_NETBSDCORE_AUXV (NetBSD-Core)
[deliverable/binutils-gdb.git] / include / elf / reloc-macros.h
index 9ad346c9f3db538f4a85f0fc7280a02cc453419c..7ff6a41a44e494d2140bec12c710dc583463a785 100644 (file)
@@ -1,11 +1,11 @@
 /* Generic relocation support for BFD.
-   Copyright 1998, 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1998-2020 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
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -15,7 +15,7 @@
 
    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.  */
+   Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 /* These macros are used by the various *.h target specific header
    files to either generate an enum containing all the known relocations
          R_foo_count
        };
 
+   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
+   set to the value of the whichever *_RELOC macro precedes it plus
+   one.  Therefore if you intend to use the symbol as a sentinel for
+   the highest valid macro value you should make sure that the
+   preceding *_RELOC macro is the highest valid number.  ie a
+   declaration like this:
+
+       START_RELOC_NUMBERS (foo)
+           RELOC_NUMBER (R_foo_NONE,    0)
+           RELOC_NUMBER (R_foo_32,      1)
+           FAKE_RELOC   (R_foo_illegal, 9)
+           FAKE_RELOC   (R_foo_synonym, 0)
+       END_RELOC_NUMBERS (R_foo_count)
+
+   will result in R_foo_count having a value of 1 (R_foo_synonym + 1)
+   rather than 10 or 2 as might be expected.
+
+   Alternatively you can assign a value to END_RELOC_NUMBERS symbol
+   explicitly, like this:
+
+       START_RELOC_NUMBERS (foo)
+           RELOC_NUMBER (R_foo_NONE,    0)
+           RELOC_NUMBER (R_foo_32,      1)
+           FAKE_RELOC   (R_foo_illegal, 9)
+           FAKE_RELOC   (R_foo_synonym, 0)
+       END_RELOC_NUMBERS (R_foo_count = 2)
+
    If RELOC_MACROS_GEN_FUNC *is* defined, then instead the
    following function will be generated:
 
-       static const char * foo PARAMS ((unsigned long rtype));
+       static const char *foo (unsigned long rtype);
        static const char *
-       foo (rtype)
-           unsigned long rtype;
+       foo (unsigned long rtype)
        {
           switch (rtype)
           {
    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 (unsigned long rtype);                 \
 static const char *                                            \
-name (rtype)                                                   \
-       unsigned long rtype;                                    \
+name (unsigned long rtype)                                     \
 {                                                              \
   switch (rtype)                                               \
-  {
+    {
 
-#if defined (__STDC__) || defined (ALMOST_STDC)
-#define RELOC_NUMBER(name, number)  case number : return #name ;
-#else
-#define RELOC_NUMBER(name, number)  case number : return "name" ;
-#endif
+#define RELOC_NUMBER(name, number) \
+    case number: return #name;
 
 #define FAKE_RELOC(name, number)
 #define EMPTY_RELOC(name)
 
 #define END_RELOC_NUMBERS(name)        \
     default: return NULL;      \
-  }                            \
+    }                          \
 }
 
 
@@ -103,4 +126,4 @@ name (rtype)                                                        \
 
 #endif
 
-#endif /* RELOC_MACROS_H */
+#endif /* _RELOC_MACROS_H */
This page took 0.028764 seconds and 4 git commands to generate.