Rizin
unix-like reverse engineering framework and cli tools
reloc-macros.h
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 1998, 1999, 2000, 2003 Free Software Foundation, Inc.
2
// SPDX-License-Identifier: GPL-2.0-or-later
3
4
/* Generic relocation support for BFD.
5
Copyright 1998, 1999, 2000, 2003 Free Software Foundation, Inc.
6
7
This file is part of BFD, the Binary File Descriptor library.
8
9
This program is free software; you can redistribute it and/or modify
10
it under the terms of the GNU General Public License as published by
11
the Free Software Foundation; either version 2 of the License, or
12
(at your option) any later version.
13
14
This program is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
GNU General Public License for more details.
18
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to the Free Software Foundation,
21
Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
22
23
/* These macros are used by the various *.h target specific header
24
files to either generate an enum containing all the known relocations
25
for that target, or if RELOC_MACROS_GEN_FUNC is defined, a recognition
26
function is generated instead. (This is used by binutils/readelf.c)
27
28
Given a header file like this:
29
30
START_RELOC_NUMBERS (foo)
31
RELOC_NUMBER (RZ_foo_NONE, 0)
32
RELOC_NUMBER (RZ_foo_32, 1)
33
EMPTY_RELOC (RZ_foo_good)
34
FAKE_RELOC (RZ_foo_illegal, 9)
35
END_RELOC_NUMBERS (RZ_foo_count)
36
37
Then the following will be produced by default (ie if
38
RELOC_MACROS_GEN_FUNC is *not* defined).
39
40
enum foo
41
{
42
RZ_foo_NONE = 0,
43
RZ_foo_32 = 1,
44
RZ_foo_good,
45
RZ_foo_illegal = 9,
46
RZ_foo_count
47
};
48
49
If RELOC_MACROS_GEN_FUNC *is* defined, then instead the
50
following function will be generated:
51
52
static const char *foo (unsigned long rtype);
53
static const char *
54
foo (unsigned long rtype)
55
{
56
switch (rtype)
57
{
58
case 0: return "RZ_foo_NONE";
59
case 1: return "RZ_foo_32";
60
default: return NULL;
61
}
62
}
63
*/
64
65
#ifndef _RELOC_MACROS_H
66
#define _RELOC_MACROS_H
67
68
#ifdef RELOC_MACROS_GEN_FUNC
69
70
/* This function takes the relocation number and returns the
71
string version name of the name of that relocation. If
72
the relocation is not recognised, NULL is returned. */
73
74
#define START_RELOC_NUMBERS(name) \
75
static const char *name(unsigned long rtype); \
76
static const char * \
77
name(unsigned long rtype) { \
78
switch (rtype) {
79
80
#define RELOC_NUMBER(name, number) \
81
case number: \
82
return #name;
83
84
#define FAKE_RELOC(name, number)
85
#define EMPTY_RELOC(name)
86
87
#define END_RELOC_NUMBERS(name) \
88
default: return NULL; \
89
} \
90
}
91
92
#else
/* Default to generating enum. */
93
94
#define START_RELOC_NUMBERS(name) enum name {
95
#define RELOC_NUMBER(name, number) name = number,
96
#define FAKE_RELOC(name, number) name = number,
97
#define EMPTY_RELOC(name) name,
98
#define END_RELOC_NUMBERS(name) \
99
name \
100
} \
101
;
102
103
#endif
104
105
#endif
/* _RELOC_MACROS_H */
librz
asm
arch
include
elf
reloc-macros.h
Generated by
1.9.1