xref: /dflybsd-src/contrib/binutils-2.34/include/elf/rx.h (revision b52ef7118d1621abed722c5bbbd542210290ecef)
1*fae548d3Szrj /* RX ELF support for BFD.
2*fae548d3Szrj    Copyright (C) 2008-2020 Free Software Foundation, Inc.
3*fae548d3Szrj 
4*fae548d3Szrj    This file is part of BFD, the Binary File Descriptor library.
5*fae548d3Szrj 
6*fae548d3Szrj    This program is free software; you can redistribute it and/or modify
7*fae548d3Szrj    it under the terms of the GNU General Public License as published by
8*fae548d3Szrj    the Free Software Foundation; either version 3 of the License, or
9*fae548d3Szrj    (at your option) any later version.
10*fae548d3Szrj 
11*fae548d3Szrj    This program is distributed in the hope that it will be useful,
12*fae548d3Szrj    but WITHOUT ANY WARRANTY; without even the implied warranty of
13*fae548d3Szrj    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*fae548d3Szrj    GNU General Public License for more details.
15*fae548d3Szrj 
16*fae548d3Szrj    You should have received a copy of the GNU General Public License
17*fae548d3Szrj    along with this program; if not, write to the Free Software Foundation,
18*fae548d3Szrj    Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
19*fae548d3Szrj 
20*fae548d3Szrj #ifndef _ELF_RX_H
21*fae548d3Szrj #define _ELF_RX_H
22*fae548d3Szrj 
23*fae548d3Szrj #include "elf/reloc-macros.h"
24*fae548d3Szrj 
25*fae548d3Szrj /* Note that there are a few internal relocation types used by the
26*fae548d3Szrj    linker to do link-time relaxation.  If you update this file, please
27*fae548d3Szrj    check elf32-rx.c to see if any of the internal relocations need to
28*fae548d3Szrj    be, er, relocated.  */
29*fae548d3Szrj 
30*fae548d3Szrj /* Preliminary relocations.  */
31*fae548d3Szrj START_RELOC_NUMBERS (elf_rx_reloc_type)
32*fae548d3Szrj 
33*fae548d3Szrj   RELOC_NUMBER (R_RX_NONE,         0x00)
34*fae548d3Szrj   /* These are for data, and are bi-endian.  */
35*fae548d3Szrj   RELOC_NUMBER (R_RX_DIR32,        0x01) /* Was: R_RX_32.  */
36*fae548d3Szrj   RELOC_NUMBER (R_RX_DIR24S,       0x02) /* Was: R_RX_24.  */
37*fae548d3Szrj   RELOC_NUMBER (R_RX_DIR16,        0x03)
38*fae548d3Szrj   RELOC_NUMBER (R_RX_DIR16U,       0x04) /* Was: R_RX_16_UNS.  */
39*fae548d3Szrj   RELOC_NUMBER (R_RX_DIR16S,       0x05) /* Was: R_RX_16.  */
40*fae548d3Szrj   RELOC_NUMBER (R_RX_DIR8,         0x06)
41*fae548d3Szrj   RELOC_NUMBER (R_RX_DIR8U,        0x07) /* Was: R_RX_8_UNS.  */
42*fae548d3Szrj   RELOC_NUMBER (R_RX_DIR8S,        0x08) /* Was: R_RX_8.  */
43*fae548d3Szrj 
44*fae548d3Szrj   /* Signed pc-relative values.  */
45*fae548d3Szrj   RELOC_NUMBER (R_RX_DIR24S_PCREL, 0x09) /* Was: R_RX_24_PCREL.  */
46*fae548d3Szrj   RELOC_NUMBER (R_RX_DIR16S_PCREL, 0x0a) /* Was: R_RX_16_PCREL.  */
47*fae548d3Szrj   RELOC_NUMBER (R_RX_DIR8S_PCREL,  0x0b) /* Was: R_RX_8_PCREL.  */
48*fae548d3Szrj 
49*fae548d3Szrj   /* These are for fields in the instructions.  */
50*fae548d3Szrj   RELOC_NUMBER (R_RX_DIR16UL,      0x0c)
51*fae548d3Szrj   RELOC_NUMBER (R_RX_DIR16UW,      0x0d)
52*fae548d3Szrj   RELOC_NUMBER (R_RX_DIR8UL,       0x0e)
53*fae548d3Szrj   RELOC_NUMBER (R_RX_DIR8UW,       0x0f)
54*fae548d3Szrj   RELOC_NUMBER (R_RX_DIR32_REV,    0x10)
55*fae548d3Szrj   RELOC_NUMBER (R_RX_DIR16_REV,    0x11)
56*fae548d3Szrj   RELOC_NUMBER (R_RX_DIR3U_PCREL,  0x12)
57*fae548d3Szrj 
58*fae548d3Szrj   /* These are extensions added by Red Hat.  */
59*fae548d3Szrj   RELOC_NUMBER (R_RX_RH_3_PCREL,   0x20) /* Like R_RX_DIR8S_PCREL but only 3-bits.  */
60*fae548d3Szrj   RELOC_NUMBER (R_RX_RH_16_OP,     0x21) /* Like R_RX_DIR16 but for opcodes - always big endian.  */
61*fae548d3Szrj   RELOC_NUMBER (R_RX_RH_24_OP,     0x22) /* Like R_RX_DIR24S but for opcodes - always big endian.  */
62*fae548d3Szrj   RELOC_NUMBER (R_RX_RH_32_OP,     0x23) /* Like R_RX_DIR32 but for opcodes - always big endian.  */
63*fae548d3Szrj   RELOC_NUMBER (R_RX_RH_24_UNS,    0x24) /* Like R_RX_DIR24S but for unsigned values.  */
64*fae548d3Szrj   RELOC_NUMBER (R_RX_RH_8_NEG,     0x25) /* Like R_RX_DIR8 but -x is stored.  */
65*fae548d3Szrj   RELOC_NUMBER (R_RX_RH_16_NEG,    0x26) /* Like R_RX_DIR16 but -x is stored.  */
66*fae548d3Szrj   RELOC_NUMBER (R_RX_RH_24_NEG,    0x27) /* Like R_RX_DIR24S but -x is stored.  */
67*fae548d3Szrj   RELOC_NUMBER (R_RX_RH_32_NEG,    0x28) /* Like R_RX_DIR32 but -x is stored.  */
68*fae548d3Szrj   RELOC_NUMBER (R_RX_RH_DIFF,      0x29) /* Subtract from a previous relocation.  */
69*fae548d3Szrj   RELOC_NUMBER (R_RX_RH_GPRELB,    0x2a) /* Byte value, relative to __gp.  */
70*fae548d3Szrj   RELOC_NUMBER (R_RX_RH_GPRELW,    0x2b) /* Word value, relative to __gp.  */
71*fae548d3Szrj   RELOC_NUMBER (R_RX_RH_GPRELL,    0x2c) /* Long value, relative to __gp.  */
72*fae548d3Szrj   RELOC_NUMBER (R_RX_RH_RELAX,     0x2d) /* Marks opcodes suitable for linker relaxation.  */
73*fae548d3Szrj 
74*fae548d3Szrj   /* These are for complex relocs.  */
75*fae548d3Szrj   RELOC_NUMBER (R_RX_ABS32,        0x41)
76*fae548d3Szrj   RELOC_NUMBER (R_RX_ABS24S,       0x42)
77*fae548d3Szrj   RELOC_NUMBER (R_RX_ABS16,        0x43)
78*fae548d3Szrj   RELOC_NUMBER (R_RX_ABS16U,       0x44)
79*fae548d3Szrj   RELOC_NUMBER (R_RX_ABS16S,       0x45)
80*fae548d3Szrj   RELOC_NUMBER (R_RX_ABS8,         0x46)
81*fae548d3Szrj   RELOC_NUMBER (R_RX_ABS8U,        0x47)
82*fae548d3Szrj   RELOC_NUMBER (R_RX_ABS8S,        0x48)
83*fae548d3Szrj   RELOC_NUMBER (R_RX_ABS24S_PCREL, 0x49)
84*fae548d3Szrj   RELOC_NUMBER (R_RX_ABS16S_PCREL, 0x4a)
85*fae548d3Szrj   RELOC_NUMBER (R_RX_ABS8S_PCREL,  0x4b)
86*fae548d3Szrj   RELOC_NUMBER (R_RX_ABS16UL,      0x4c)
87*fae548d3Szrj   RELOC_NUMBER (R_RX_ABS16UW,      0x4d)
88*fae548d3Szrj   RELOC_NUMBER (R_RX_ABS8UL,       0x4e)
89*fae548d3Szrj   RELOC_NUMBER (R_RX_ABS8UW,       0x4f)
90*fae548d3Szrj   RELOC_NUMBER (R_RX_ABS32_REV,    0x50)
91*fae548d3Szrj   RELOC_NUMBER (R_RX_ABS16_REV,    0x51)
92*fae548d3Szrj 
93*fae548d3Szrj   RELOC_NUMBER (R_RX_SYM,          0x80)
94*fae548d3Szrj   RELOC_NUMBER (R_RX_OPneg,        0x81)
95*fae548d3Szrj   RELOC_NUMBER (R_RX_OPadd,        0x82)
96*fae548d3Szrj   RELOC_NUMBER (R_RX_OPsub,        0x83)
97*fae548d3Szrj   RELOC_NUMBER (R_RX_OPmul,        0x84)
98*fae548d3Szrj   RELOC_NUMBER (R_RX_OPdiv,        0x85)
99*fae548d3Szrj   RELOC_NUMBER (R_RX_OPshla,       0x86)
100*fae548d3Szrj   RELOC_NUMBER (R_RX_OPshra,       0x87)
101*fae548d3Szrj   RELOC_NUMBER (R_RX_OPsctsize,    0x88)
102*fae548d3Szrj   RELOC_NUMBER (R_RX_OPscttop,     0x8d)
103*fae548d3Szrj   RELOC_NUMBER (R_RX_OPand,        0x90)
104*fae548d3Szrj   RELOC_NUMBER (R_RX_OPor,         0x91)
105*fae548d3Szrj   RELOC_NUMBER (R_RX_OPxor,        0x92)
106*fae548d3Szrj   RELOC_NUMBER (R_RX_OPnot,        0x93)
107*fae548d3Szrj   RELOC_NUMBER (R_RX_OPmod,        0x94)
108*fae548d3Szrj   RELOC_NUMBER (R_RX_OPromtop,     0x95)
109*fae548d3Szrj   RELOC_NUMBER (R_RX_OPramtop,     0x96)
110*fae548d3Szrj 
111*fae548d3Szrj END_RELOC_NUMBERS (R_RX_max)
112*fae548d3Szrj 
113*fae548d3Szrj #define EF_RX_CPU_RX	0x00000079      /* FIXME: this collides with the E_FLAG_RX_... values below.  */
114*fae548d3Szrj #define EF_RX_CPU_MASK	0x000003FF	/* specific cpu bits.  */
115*fae548d3Szrj #define EF_RX_ALL_FLAGS	(EF_RX_CPU_MASK)
116*fae548d3Szrj 
117*fae548d3Szrj /* Values for the e_flags field in the ELF header.  */
118*fae548d3Szrj #define E_FLAG_RX_64BIT_DOUBLES		(1 << 0)
119*fae548d3Szrj #define E_FLAG_RX_DSP			(1 << 1) /* Defined in the RX CPU Object file specification, but not explained. */
120*fae548d3Szrj #define E_FLAG_RX_PID			(1 << 2) /* Unofficial - DJ */
121*fae548d3Szrj #define E_FLAG_RX_ABI			(1 << 3) /* Binary passes stacked arguments using natural alignment.  Unofficial - NC.  */
122*fae548d3Szrj #define E_FLAG_RX_SINSNS_SET		(1 << 6) /* Set if bit-5 is significant.  */
123*fae548d3Szrj #define E_FLAG_RX_SINSNS_YES		(1 << 7) /* Set if string instructions are used in the binary.  */
124*fae548d3Szrj #define E_FLAG_RX_SINSNS_NO		0        /* Bit-5 if this binary must not be linked with a string instruction using binary.  */
125*fae548d3Szrj #define E_FLAG_RX_SINSNS_MASK		(3 << 6) /* Mask of bits used to determine string instruction use.  */
126*fae548d3Szrj #define E_FLAG_RX_V2			(1 << 8) /* RX v2 instructions */
127*fae548d3Szrj #define E_FLAG_RX_V3			(1 << 9) /* RX v3 instructions */
128*fae548d3Szrj 
129*fae548d3Szrj /* These define the addend field of R_RX_RH_RELAX relocations.  */
130*fae548d3Szrj #define	RX_RELAXA_IMM6	0x00000010	/* Imm8/16/24/32 at bit offset 6.  */
131*fae548d3Szrj #define	RX_RELAXA_IMM12	0x00000020	/* Imm8/16/24/32 at bit offset 12.  */
132*fae548d3Szrj #define	RX_RELAXA_DSP4	0x00000040	/* Dsp0/8/16 at bit offset 4.  */
133*fae548d3Szrj #define	RX_RELAXA_DSP6	0x00000080	/* Dsp0/8/16 at bit offset 6.  */
134*fae548d3Szrj #define	RX_RELAXA_DSP14	0x00000100	/* Dsp0/8/16 at bit offset 14.  */
135*fae548d3Szrj #define	RX_RELAXA_BRA	0x00000200	/* Any type of branch (must be decoded).  */
136*fae548d3Szrj #define RX_RELAXA_RNUM	0x0000000f	/* Number of associated relocations.  */
137*fae548d3Szrj /* These mark the place where alignment is requested, and the place where the filler bytes end.  */
138*fae548d3Szrj #define	RX_RELAXA_ALIGN	0x10000000	/* Start alignment; the remaining bits are the alignment value.  */
139*fae548d3Szrj #define	RX_RELAXA_ELIGN	0x20000000	/* End alignment; the remaining bits are the alignment value.  */
140*fae548d3Szrj #define	RX_RELAXA_ANUM	0x00ffffff	/* Alignment amount, in bytes (i.e. .balign).  */
141*fae548d3Szrj 
142*fae548d3Szrj #endif /* _ELF_RX_H */
143