1*a9fa9459Szrj /* CRIS ELF support for BFD.
2*a9fa9459Szrj    Copyright (C) 2000-2016 Free Software Foundation, Inc.
3*a9fa9459Szrj    Contributed by Axis Communications AB, Lund, Sweden.
4*a9fa9459Szrj    Written by Hans-Peter Nilsson.
5*a9fa9459Szrj 
6*a9fa9459Szrj    This file is part of BFD, the Binary File Descriptor library.
7*a9fa9459Szrj 
8*a9fa9459Szrj    This program is free software; you can redistribute it and/or modify
9*a9fa9459Szrj    it under the terms of the GNU General Public License as published by
10*a9fa9459Szrj    the Free Software Foundation; either version 3 of the License, or
11*a9fa9459Szrj    (at your option) any later version.
12*a9fa9459Szrj 
13*a9fa9459Szrj    This program is distributed in the hope that it will be useful,
14*a9fa9459Szrj    but WITHOUT ANY WARRANTY; without even the implied warranty of
15*a9fa9459Szrj    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*a9fa9459Szrj    GNU General Public License for more details.
17*a9fa9459Szrj 
18*a9fa9459Szrj    You should have received a copy of the GNU General Public License
19*a9fa9459Szrj    along with this program; if not, write to the Free Software Foundation,
20*a9fa9459Szrj    Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
21*a9fa9459Szrj 
22*a9fa9459Szrj #ifndef _ELF_CRIS_H
23*a9fa9459Szrj #define _ELF_CRIS_H
24*a9fa9459Szrj 
25*a9fa9459Szrj #include "elf/reloc-macros.h"
26*a9fa9459Szrj 
27*a9fa9459Szrj /* Relocations.  */
28*a9fa9459Szrj START_RELOC_NUMBERS (elf_cris_reloc_type)
29*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_NONE,		0)
30*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_8,		1)
31*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_16,		2)
32*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_32,		3)
33*a9fa9459Szrj 
34*a9fa9459Szrj   /* The "PC" position is the location right after the relocation.  */
35*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_8_PCREL,		4)
36*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_16_PCREL,	5)
37*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_32_PCREL,	6)
38*a9fa9459Szrj 
39*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_GNU_VTINHERIT,	7)
40*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_GNU_VTENTRY,	8)
41*a9fa9459Szrj 
42*a9fa9459Szrj   /* Copy contents at dynlinking.  Generated by the linker.
43*a9fa9459Szrj      The BFD equivalent is BFD_RELOC_CRIS_COPY.  */
44*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_COPY, 9)
45*a9fa9459Szrj 
46*a9fa9459Szrj   /* Create GOT entry.  Generated by the linker.
47*a9fa9459Szrj      The BFD equivalent is BFD_RELOC_CRIS_GLOB_DAT.  */
48*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_GLOB_DAT, 10)
49*a9fa9459Szrj 
50*a9fa9459Szrj   /* Create PLT entry.  Generated by the linker.
51*a9fa9459Szrj      The BFD equivalent is BFD_RELOC_CRIS_JUMP_SLOT.  */
52*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_JUMP_SLOT, 11)
53*a9fa9459Szrj 
54*a9fa9459Szrj   /* Adjust by program base.  Generated by the linker.
55*a9fa9459Szrj      The BFD equivalent is BFD_RELOC_CRIS_RELATIVE.  */
56*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_RELATIVE, 12)
57*a9fa9459Szrj 
58*a9fa9459Szrj   /* A 16-bit offset to entry in GOT and request to create GOT entry for
59*a9fa9459Szrj      that symbol.
60*a9fa9459Szrj      The BFD equivalent is BFD_RELOC_CRIS_16_GOT.  */
61*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_16_GOT, 13)
62*a9fa9459Szrj 
63*a9fa9459Szrj   /* A 32-bit offset to entry in GOT and request to create GOT entry for
64*a9fa9459Szrj      that symbol.
65*a9fa9459Szrj      The BFD equivalent is BFD_RELOC_CRIS_32_GOT.  */
66*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_32_GOT, 14)
67*a9fa9459Szrj 
68*a9fa9459Szrj   /* A 16-bit offset to entry in PLT part of GOT and request to create PLT
69*a9fa9459Szrj      entry for that symbol.
70*a9fa9459Szrj      The BFD equivalent is BFD_RELOC_CRIS_16_GOTPLT.  */
71*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_16_GOTPLT, 15)
72*a9fa9459Szrj 
73*a9fa9459Szrj   /* A 32-bit offset to entry in PLT part of GOT and request to create PLT
74*a9fa9459Szrj      entry for that symbol.
75*a9fa9459Szrj      The BFD equivalent is BFD_RELOC_CRIS_32_GOTPLT.  */
76*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_32_GOTPLT, 16)
77*a9fa9459Szrj 
78*a9fa9459Szrj   /* A 32-bit offset from GOT to (local) symbol: no GOT entry should be
79*a9fa9459Szrj      necessary.
80*a9fa9459Szrj      The BFD equivalent is BFD_RELOC_CRIS_32_GOTREL.  */
81*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_32_GOTREL, 17)
82*a9fa9459Szrj 
83*a9fa9459Szrj   /* A 32-bit offset from GOT to entry for this symbol in PLT and request
84*a9fa9459Szrj      to create PLT entry for symbol.
85*a9fa9459Szrj      The BFD equivalent is BFD_RELOC_CRIS_32_GOTREL.  */
86*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_32_PLT_GOTREL, 18)
87*a9fa9459Szrj 
88*a9fa9459Szrj   /* A 32-bit offset from location after this relocation (addend specifies
89*a9fa9459Szrj      offset) to entry for this symbol in PLT and request to create PLT
90*a9fa9459Szrj      entry for symbol.
91*a9fa9459Szrj      The BFD equivalent is BFD_RELOC_CRIS_32_PLT_PCREL.  */
92*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_32_PLT_PCREL, 19)
93*a9fa9459Szrj 
94*a9fa9459Szrj   /* An assembler-generated-only relocation, instructing the linker to
95*a9fa9459Szrj      reserve two GOT slots, carrying the R_CRIS_DTP relocation for the
96*a9fa9459Szrj      symbol (pointing to the first slot, the relocation fills in
97*a9fa9459Szrj      both).  The value is a 32-bit-value, relative to the start of the
98*a9fa9459Szrj      GOT.  Assembly syntax: "sym:GDGOTREL".  */
99*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_32_GOT_GD, 20)
100*a9fa9459Szrj 
101*a9fa9459Szrj   /* Similar to R_CRIS_32_GOT_GD, but the value is a 16-bit unsigned
102*a9fa9459Szrj      number, limiting access to 65536/4 global symbols per module (or
103*a9fa9459Szrj      65536/8 thread variables; loosely speaking G*4+T*8 < 65536, where
104*a9fa9459Szrj      T is the number of thread variables and G is the number of other
105*a9fa9459Szrj      external global variables and functions).  Assembly syntax:
106*a9fa9459Szrj      "sym:GDGOTREL16".  */
107*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_16_GOT_GD, 21)
108*a9fa9459Szrj 
109*a9fa9459Szrj   /* Similar to R_CRIS_32_GOT_GD, but the value is the absolute
110*a9fa9459Szrj      address of the GOT entry.  Disallowed in DSOs created with
111*a9fa9459Szrj      -shared.  Assembly syntax: "sym:GD".  */
112*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_32_GD, 22)
113*a9fa9459Szrj 
114*a9fa9459Szrj   /* A linker-generated-only relocation, instructing the dynamic
115*a9fa9459Szrj      linker to fill in the module ID and module-relative-TLS-block
116*a9fa9459Szrj      offset of the symbol in question, used for GOT entries.  Note
117*a9fa9459Szrj      that this relocation instructs to fill in two 32-bit values.  */
118*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_DTP, 23)
119*a9fa9459Szrj 
120*a9fa9459Szrj   /* An assembler-generated-only relocation, instructing the linker to
121*a9fa9459Szrj      reserve the first two GOT slots, and attach the R_CRIS_DTPMOD
122*a9fa9459Szrj      relocation(*) for the module to the first slot, the second
123*a9fa9459Szrj      containing zero.  The value is 32 bits, the offset from the start
124*a9fa9459Szrj      of the TLS block of the module to the thread-local symbol
125*a9fa9459Szrj      mentioned in the relocation.  This relocation must only be applied
126*a9fa9459Szrj      to module-local symbols.  Assembly syntax: "expr:DTPREL".  */
127*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_32_DTPREL, 24)
128*a9fa9459Szrj 
129*a9fa9459Szrj   /* Similar to R_CRIS_32_DTPREL, but the value is a 16-bit signed
130*a9fa9459Szrj      number, limiting the size of thread-variables of the DSO to 32768
131*a9fa9459Szrj      bytes.  (Note: matches both model 1 and 2 and allows use of addo.w
132*a9fa9459Szrj      as the instruction where this relocation is used.)  Assembly
133*a9fa9459Szrj      syntax: "expr:DTPREL16".  */
134*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_16_DTPREL, 25)
135*a9fa9459Szrj 
136*a9fa9459Szrj   /* An assembler-generated-only relocation, instructing the linker to
137*a9fa9459Szrj      reserve a GOT slot and attach the R_CRIS_32_TPREL relocation for
138*a9fa9459Szrj      the symbol in question.  The value is 32 bits, which is the
139*a9fa9459Szrj      GOT-relative offset of the slot.  Assembly syntax:
140*a9fa9459Szrj      "sym:TPOFFGOT".  */
141*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_32_GOT_TPREL, 26)
142*a9fa9459Szrj 
143*a9fa9459Szrj   /* Similar to R_CRIS_32_TPREL, but the value is a 16-bit positive
144*a9fa9459Szrj      number, limiting the number of thread- and global variables of
145*a9fa9459Szrj      the DSO to 32768/4.  Assembly syntax: "sym:TPOFFGOT16".  */
146*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_16_GOT_TPREL, 27)
147*a9fa9459Szrj 
148*a9fa9459Szrj   /* An assembler- and linker-generated relocation, instructing to
149*a9fa9459Szrj      resolve the symbol in question yielding the TLS offset of the
150*a9fa9459Szrj      thread variable, relative to the global TLS block.  Not allowed
151*a9fa9459Szrj      as input when generating a DSO.  Assembly syntax:
152*a9fa9459Szrj      "expr:TPOFF".  */
153*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_32_TPREL, 28)
154*a9fa9459Szrj 
155*a9fa9459Szrj   /* Similar to R_CRIS_32_TPREL, but only applicable to executables
156*a9fa9459Szrj      compiled with -msmall-tls. Not allowed in a DSO. The value is a
157*a9fa9459Szrj      16-bit signed number, limiting the size of thread-variables of
158*a9fa9459Szrj      the executable to 32768 bytes. (Note: being signed makes it match
159*a9fa9459Szrj      both model 1 and 2 and allows use of addo.w as the instruction
160*a9fa9459Szrj      where this relocation is applied.)  Assembly syntax:
161*a9fa9459Szrj      "expr:TPOFF16".  */
162*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_16_TPREL, 29)
163*a9fa9459Szrj 
164*a9fa9459Szrj   /* A linker-generated-only relocation, instructing the dynamic
165*a9fa9459Szrj      linker to fill in the current module ID, used for GOT entries
166*a9fa9459Szrj      (usually the fourth one).  */
167*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_DTPMOD, 30)
168*a9fa9459Szrj 
169*a9fa9459Szrj   /* Similar to R_CRIS_32_GOT_TPREL, but the value is the absolute
170*a9fa9459Szrj      address of the GOT entry.  Disallowed in DSOs created with
171*a9fa9459Szrj      -shared.  Assembly syntax: "sym:IE".  */
172*a9fa9459Szrj   RELOC_NUMBER (R_CRIS_32_IE, 31)
173*a9fa9459Szrj 
174*a9fa9459Szrj   /* No other relocs must be visible outside the assembler.  */
175*a9fa9459Szrj 
176*a9fa9459Szrj END_RELOC_NUMBERS (R_CRIS_max)
177*a9fa9459Szrj 
178*a9fa9459Szrj /* User symbols in this file have a leading underscore.  */
179*a9fa9459Szrj #define EF_CRIS_UNDERSCORE		0x00000001
180*a9fa9459Szrj 
181*a9fa9459Szrj /* This is a mask for different incompatible machine variants.  */
182*a9fa9459Szrj #define EF_CRIS_VARIANT_MASK		0x0000000e
183*a9fa9459Szrj 
184*a9fa9459Szrj /* Variant 0; may contain v0..10 object.  */
185*a9fa9459Szrj #define EF_CRIS_VARIANT_ANY_V0_V10	0x00000000
186*a9fa9459Szrj 
187*a9fa9459Szrj /* Variant 1; contains v32 object.  */
188*a9fa9459Szrj #define EF_CRIS_VARIANT_V32		0x00000002
189*a9fa9459Szrj 
190*a9fa9459Szrj /* Variant 2; contains object compatible with v32 and v10.  */
191*a9fa9459Szrj #define EF_CRIS_VARIANT_COMMON_V10_V32	0x00000004
192*a9fa9459Szrj 
193*a9fa9459Szrj #endif /* _ELF_CRIS_H */
194