* mips.h (Elf64_Mips_External_Rel): Define.
[external/binutils.git] / include / elf / mips.h
1 /* MIPS ELF support for BFD.
2    Copyright (C) 1993, 1994 Free Software Foundation, Inc.
3
4    By Ian Lance Taylor, Cygnus Support, <ian@cygnus.com>, from
5    information in the System V Application Binary Interface, MIPS
6    Processor Supplement.
7
8 This file is part of BFD, the Binary File Descriptor library.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
23
24 /* This file holds definitions specific to the MIPS ELF ABI.  Note
25    that most of this is not actually implemented by BFD.  */
26
27 #ifndef _ELF_MIPS_H
28 #define _ELF_MIPS_H
29
30 /* Processor specific flags for the ELF header e_flags field.  */
31
32 /* At least one .noreorder directive appears in the source.  */
33 #define EF_MIPS_NOREORDER       0x00000001
34
35 /* File contains position independent code.  */
36 #define EF_MIPS_PIC             0x00000002
37
38 /* Code in file uses the standard calling sequence for calling
39    position independent code.  */
40 #define EF_MIPS_CPIC            0x00000004
41
42 /* Four bit MIPS architecture field.  */
43 #define EF_MIPS_ARCH            0xf0000000
44
45 /* -mips1 code.  */
46 #define E_MIPS_ARCH_1           0x00000000
47
48 /* -mips2 code.  */
49 #define E_MIPS_ARCH_2           0x10000000
50
51 /* -mips3 code.  */
52 #define E_MIPS_ARCH_3           0x20000000
53 \f
54 /* Processor specific section indices.  These sections do not actually
55    exist.  Symbols with a st_shndx field corresponding to one of these
56    values have a special meaning.  */
57
58 /* Defined and allocated common symbol.  Value is virtual address.  If
59    relocated, alignment must be preserved.  */
60 #define SHN_MIPS_ACOMMON        0xff00
61
62 /* Defined and allocated text symbol.  Value is virtual address.
63    Occur in the dynamic symbol table of Alpha OSF/1 and Irix 5 executables.  */
64 #define SHN_MIPS_TEXT           0xff01
65
66 /* Defined and allocated data symbol.  Value is virtual address.
67    Occur in the dynamic symbol table of Alpha OSF/1 and Irix 5 executables.  */
68 #define SHN_MIPS_DATA           0xff02
69
70 /* Small common symbol.  */
71 #define SHN_MIPS_SCOMMON        0xff03
72
73 /* Small undefined symbol.  */
74 #define SHN_MIPS_SUNDEFINED     0xff04
75 \f
76 /* Processor specific section types.  */
77
78 /* Section contains the set of dynamic shared objects used when
79    statically linking.  */
80 #define SHT_MIPS_LIBLIST        0x70000000
81
82 /* I'm not sure what this is, but it's used on Irix 5.  */
83 #define SHT_MIPS_MSYM           0x70000001
84
85 /* Section contains list of symbols whose definitions conflict with
86    symbols defined in shared objects.  */
87 #define SHT_MIPS_CONFLICT       0x70000002
88
89 /* Section contains the global pointer table.  */
90 #define SHT_MIPS_GPTAB          0x70000003
91
92 /* Section contains microcode information.  The exact format is
93    unspecified.  */
94 #define SHT_MIPS_UCODE          0x70000004
95
96 /* Section contains some sort of debugging information.  The exact
97    format is unspecified.  It's probably ECOFF symbols.  */
98 #define SHT_MIPS_DEBUG          0x70000005
99
100 /* Section contains register usage information.  */
101 #define SHT_MIPS_REGINFO        0x70000006
102
103 /* Section contains miscellaneous options (used on Irix).  */
104 #define SHT_MIPS_OPTIONS        0x7000000d
105
106 /* DWARF debugging section (used on Irix 6).  */
107 #define SHT_MIPS_DWARF          0x7000001e
108
109 /* Events section.  This appears on Irix 6.  I don't know what it
110    means.  */
111 #define SHT_MIPS_EVENTS         0x70000021
112
113 /* A section of type SHT_MIPS_LIBLIST contains an array of the
114    following structure.  The sh_link field is the section index of the
115    string table.  The sh_info field is the number of entries in the
116    section.  */
117 typedef struct
118 {
119   /* String table index for name of shared object.  */
120   unsigned long l_name;
121   /* Time stamp.  */
122   unsigned long l_time_stamp;
123   /* Checksum of symbol names and common sizes.  */
124   unsigned long l_checksum;
125   /* String table index for version.  */
126   unsigned long l_version;
127   /* Flags.  */
128   unsigned long l_flags;
129 } Elf32_Lib;
130
131 /* The l_flags field of an Elf32_Lib structure may contain the
132    following flags.  */
133
134 /* Require an exact match at runtime.  */
135 #define LL_EXACT_MATCH          0x00000001
136
137 /* Ignore version incompatibilities at runtime.  */
138 #define LL_IGNORE_INT_VER       0x00000002
139
140 /* A section of type SHT_MIPS_CONFLICT is an array of indices into the
141    .dynsym section.  Each element has the following type.  */
142 typedef unsigned long Elf32_Conflict;
143
144 /* A section of type SHT_MIPS_GPTAB contains information about how
145    much GP space would be required for different -G arguments.  This
146    information is only used so that the linker can provide informative
147    suggestions as to the best -G value to use.  The sh_info field is
148    the index of the section for which this information applies.  The
149    contents of the section are an array of the following union.  The
150    first element uses the gt_header field.  The remaining elements use
151    the gt_entry field.  */
152 typedef union
153 {
154   struct
155     {
156       /* -G value actually used for this object file.  */
157       unsigned long gt_current_g_value;
158       /* Unused.  */
159       unsigned long gt_unused;
160     } gt_header;
161   struct
162     {
163       /* If this -G argument has been used...  */
164       unsigned long gt_g_value;
165       /* ...this many GP section bytes would be required.  */
166       unsigned long gt_bytes;
167     } gt_entry;
168 } Elf32_gptab;
169
170 /* The external version of Elf32_gptab.  */
171
172 typedef union
173 {
174   struct
175     {
176       unsigned char gt_current_g_value[4];
177       unsigned char gt_unused[4];
178     } gt_header;
179   struct
180     {
181       unsigned char gt_g_value[4];
182       unsigned char gt_bytes[4];
183     } gt_entry;
184 } Elf32_External_gptab;
185
186 /* A section of type SHT_MIPS_REGINFO contains the following
187    structure.  */
188 typedef struct
189 {
190   /* Mask of general purpose registers used.  */
191   unsigned long ri_gprmask;
192   /* Mask of co-processor registers used.  */
193   unsigned long ri_cprmask[4];
194   /* GP register value for this object file.  */
195   long ri_gp_value;
196 } Elf32_RegInfo;
197
198 /* The external version of the Elf_RegInfo structure.  */
199 typedef struct
200 {
201   unsigned char ri_gprmask[4];
202   unsigned char ri_cprmask[4][4];
203   unsigned char ri_gp_value[4];
204 } Elf32_External_RegInfo;
205
206 /* MIPS ELF .reginfo swapping routines.  */
207 extern void bfd_mips_elf32_swap_reginfo_in
208   PARAMS ((bfd *, const Elf32_External_RegInfo *, Elf32_RegInfo *));
209 extern void bfd_mips_elf32_swap_reginfo_out
210   PARAMS ((bfd *, const Elf32_RegInfo *, Elf32_External_RegInfo *));
211 \f
212 /* Processor specific section flags.  */
213
214 /* This section must be in the global data area.  */
215 #define SHF_MIPS_GPREL          0x10000000
216 \f
217 /* Processor specific program header types.  */
218
219 /* Register usage information.  Identifies one .reginfo section.  */
220 #define PT_MIPS_REGINFO         0x70000000
221
222 /* Runtime procedure table.  */
223 #define PT_MIPS_RTPROC          0x70000001
224 \f
225 /* Processor specific dynamic array tags.  */
226
227 /* 32 bit version number for runtime linker interface.  */
228 #define DT_MIPS_RLD_VERSION     0x70000001
229
230 /* Time stamp.  */
231 #define DT_MIPS_TIME_STAMP      0x70000002
232
233 /* Checksum of external strings and common sizes.  */
234 #define DT_MIPS_ICHECKSUM       0x70000003
235
236 /* Index of version string in string table.  */
237 #define DT_MIPS_IVERSION        0x70000004
238
239 /* 32 bits of flags.  */
240 #define DT_MIPS_FLAGS           0x70000005
241
242 /* Base address of the segment.  */
243 #define DT_MIPS_BASE_ADDRESS    0x70000006
244
245 /* Address of .conflict section.  */
246 #define DT_MIPS_CONFLICT        0x70000008
247
248 /* Address of .liblist section.  */
249 #define DT_MIPS_LIBLIST         0x70000009
250
251 /* Number of local global offset table entries.  */
252 #define DT_MIPS_LOCAL_GOTNO     0x7000000a
253
254 /* Number of entries in the .conflict section.  */
255 #define DT_MIPS_CONFLICTNO      0x7000000b
256
257 /* Number of entries in the .liblist section.  */
258 #define DT_MIPS_LIBLISTNO       0x70000010
259
260 /* Number of entries in the .dynsym section.  */
261 #define DT_MIPS_SYMTABNO        0x70000011
262
263 /* Index of first external dynamic symbol not referenced locally.  */
264 #define DT_MIPS_UNREFEXTNO      0x70000012
265
266 /* Index of first dynamic symbol in global offset table.  */
267 #define DT_MIPS_GOTSYM          0x70000013
268
269 /* Number of page table entries in global offset table.  */
270 #define DT_MIPS_HIPAGENO        0x70000014
271
272 /* Address of run time loader map, used for debugging.  */
273 #define DT_MIPS_RLD_MAP         0x70000016
274 \f
275 /* Flags which may appear in a DT_MIPS_FLAGS entry.  */
276
277 /* No flags.  */
278 #define RHF_NONE                0x00000000
279
280 /* Uses shortcut pointers.  */
281 #define RHF_QUICKSTART          0x00000001
282
283 /* Hash size is not a power of two.  */
284 #define RHF_NOTPOT              0x00000002
285
286 /* Ignore LD_LIBRARY_PATH.  */
287 #define RHS_NO_LIBRARY_REPLACEMENT \
288                                 0x00000004
289 \f
290 /* Special values for the st_other field in the symbol table.  These
291    are used in an Irix 5 dynamic symbol table.  */
292
293 #define STO_DEFAULT             0x00
294 #define STO_INTERNAL            0x01
295 #define STO_HIDDEN              0x02
296 #define STO_PROTECTED           0x03
297 \f
298 /* The 64-bit MIPS ELF ABI uses an usual reloc format.  Each
299    relocation entry specifies up to three actual relocations, all at
300    the same address.  The first relocation which required a symbol
301    uses the symbol in the r_sym field.  The second relocation which
302    requires a symbol uses the symbol in the r_ssym field.  If all
303    three relocations require a symbol, the third one uses a zero
304    value.  */
305
306 /* An entry in a 64 bit SHT_REL section.  */
307
308 typedef struct
309 {
310   /* Address of relocation.  */
311   unsigned char r_offset[8];
312   /* Symbol index.  */
313   unsigned char r_sym[4];
314   /* Special symbol.  */
315   unsigned char r_ssym[1];
316   /* Third relocation.  */
317   unsigned char r_type3[1];
318   /* Second relocation.  */
319   unsigned char r_type2[1];
320   /* First relocation.  */
321   unsigned char r_type[1];
322 } Elf64_Mips_External_Rel;
323
324 typedef struct
325 {
326   /* Address of relocation.  */
327   bfd_vma r_offset;
328   /* Symbol index.  */
329   unsigned long r_sym;
330   /* Special symbol.  */
331   unsigned char r_ssym;
332   /* Third relocation.  */
333   unsigned char r_type3;
334   /* Second relocation.  */
335   unsigned char r_type2;
336   /* First relocation.  */
337   unsigned char r_type;
338 } Elf64_Mips_Internal_Rel;
339
340 /* An entry in a 64 bit SHT_RELA section.  */
341
342 typedef struct
343 {
344   /* Address of relocation.  */
345   unsigned char r_offset[8];
346   /* Symbol index.  */
347   unsigned char r_sym[4];
348   /* Special symbol.  */
349   unsigned char r_ssym[1];
350   /* Third relocation.  */
351   unsigned char r_type3[1];
352   /* Second relocation.  */
353   unsigned char r_type2[1];
354   /* First relocation.  */
355   unsigned char r_type[1];
356   /* Addend.  */
357   unsigned char r_addend[8];
358 } Elf64_Mips_External_Rela;
359
360 typedef struct
361 {
362   /* Address of relocation.  */
363   bfd_vma r_offset;
364   /* Symbol index.  */
365   unsigned long r_sym;
366   /* Special symbol.  */
367   unsigned char r_ssym;
368   /* Third relocation.  */
369   unsigned char r_type3;
370   /* Second relocation.  */
371   unsigned char r_type2;
372   /* First relocation.  */
373   unsigned char r_type;
374   /* Addend.  */
375   bfd_signed_vma r_addend;
376 } Elf64_Mips_Internal_Rela;
377
378 /* Values found in the r_ssym field of a relocation entry.  */
379
380 /* No relocation.  */
381 #define RSS_UNDEF       0
382
383 /* Value of GP.  */
384 #define RSS_GP          1
385
386 /* Value of GP in object being relocated.  */
387 #define RSS_GP0         2
388
389 /* Address of location being relocated.  */
390 #define RSS_LOC         3
391
392 #endif /* _ELF_MIPS_H */