1 /* MIPS ELF support for BFD. 2 Copyright (C) 1993, 1994, 1995, 1996 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 54 /* -mips4 code. */ 55 #define E_MIPS_ARCH_4 0x30000000 56 57 /* Processor specific section indices. These sections do not actually 58 exist. Symbols with a st_shndx field corresponding to one of these 59 values have a special meaning. */ 60 61 /* Defined and allocated common symbol. Value is virtual address. If 62 relocated, alignment must be preserved. */ 63 #define SHN_MIPS_ACOMMON 0xff00 64 65 /* Defined and allocated text symbol. Value is virtual address. 66 Occur in the dynamic symbol table of Alpha OSF/1 and Irix 5 executables. */ 67 #define SHN_MIPS_TEXT 0xff01 68 69 /* Defined and allocated data symbol. Value is virtual address. 70 Occur in the dynamic symbol table of Alpha OSF/1 and Irix 5 executables. */ 71 #define SHN_MIPS_DATA 0xff02 72 73 /* Small common symbol. */ 74 #define SHN_MIPS_SCOMMON 0xff03 75 76 /* Small undefined symbol. */ 77 #define SHN_MIPS_SUNDEFINED 0xff04 78 79 /* Processor specific section types. */ 80 81 /* Section contains the set of dynamic shared objects used when 82 statically linking. */ 83 #define SHT_MIPS_LIBLIST 0x70000000 84 85 /* I'm not sure what this is, but it's used on Irix 5. */ 86 #define SHT_MIPS_MSYM 0x70000001 87 88 /* Section contains list of symbols whose definitions conflict with 89 symbols defined in shared objects. */ 90 #define SHT_MIPS_CONFLICT 0x70000002 91 92 /* Section contains the global pointer table. */ 93 #define SHT_MIPS_GPTAB 0x70000003 94 95 /* Section contains microcode information. The exact format is 96 unspecified. */ 97 #define SHT_MIPS_UCODE 0x70000004 98 99 /* Section contains some sort of debugging information. The exact 100 format is unspecified. It's probably ECOFF symbols. */ 101 #define SHT_MIPS_DEBUG 0x70000005 102 103 /* Section contains register usage information. */ 104 #define SHT_MIPS_REGINFO 0x70000006 105 106 /* Section contains interface information. */ 107 #define SHT_MIPS_IFACE 0x7000000b 108 109 /* Section contains description of contents of another section. */ 110 #define SHT_MIPS_CONTENT 0x7000000c 111 112 /* Section contains miscellaneous options. */ 113 #define SHT_MIPS_OPTIONS 0x7000000d 114 115 /* DWARF debugging section. */ 116 #define SHT_MIPS_DWARF 0x7000001e 117 118 /* I'm not sure what this is, but it appears on Irix 6. */ 119 #define SHT_MIPS_SYMBOL_LIB 0x70000020 120 121 /* Events section. */ 122 #define SHT_MIPS_EVENTS 0x70000021 123 124 /* A section of type SHT_MIPS_LIBLIST contains an array of the 125 following structure. The sh_link field is the section index of the 126 string table. The sh_info field is the number of entries in the 127 section. */ 128 typedef struct 129 { 130 /* String table index for name of shared object. */ 131 unsigned long l_name; 132 /* Time stamp. */ 133 unsigned long l_time_stamp; 134 /* Checksum of symbol names and common sizes. */ 135 unsigned long l_checksum; 136 /* String table index for version. */ 137 unsigned long l_version; 138 /* Flags. */ 139 unsigned long l_flags; 140 } Elf32_Lib; 141 142 /* The l_flags field of an Elf32_Lib structure may contain the 143 following flags. */ 144 145 /* Require an exact match at runtime. */ 146 #define LL_EXACT_MATCH 0x00000001 147 148 /* Ignore version incompatibilities at runtime. */ 149 #define LL_IGNORE_INT_VER 0x00000002 150 151 /* A section of type SHT_MIPS_CONFLICT is an array of indices into the 152 .dynsym section. Each element has the following type. */ 153 typedef unsigned long Elf32_Conflict; 154 155 /* A section of type SHT_MIPS_GPTAB contains information about how 156 much GP space would be required for different -G arguments. This 157 information is only used so that the linker can provide informative 158 suggestions as to the best -G value to use. The sh_info field is 159 the index of the section for which this information applies. The 160 contents of the section are an array of the following union. The 161 first element uses the gt_header field. The remaining elements use 162 the gt_entry field. */ 163 typedef union 164 { 165 struct 166 { 167 /* -G value actually used for this object file. */ 168 unsigned long gt_current_g_value; 169 /* Unused. */ 170 unsigned long gt_unused; 171 } gt_header; 172 struct 173 { 174 /* If this -G argument has been used... */ 175 unsigned long gt_g_value; 176 /* ...this many GP section bytes would be required. */ 177 unsigned long gt_bytes; 178 } gt_entry; 179 } Elf32_gptab; 180 181 /* The external version of Elf32_gptab. */ 182 183 typedef union 184 { 185 struct 186 { 187 unsigned char gt_current_g_value[4]; 188 unsigned char gt_unused[4]; 189 } gt_header; 190 struct 191 { 192 unsigned char gt_g_value[4]; 193 unsigned char gt_bytes[4]; 194 } gt_entry; 195 } Elf32_External_gptab; 196 197 /* A section of type SHT_MIPS_REGINFO contains the following 198 structure. */ 199 typedef struct 200 { 201 /* Mask of general purpose registers used. */ 202 unsigned long ri_gprmask; 203 /* Mask of co-processor registers used. */ 204 unsigned long ri_cprmask[4]; 205 /* GP register value for this object file. */ 206 long ri_gp_value; 207 } Elf32_RegInfo; 208 209 /* The external version of the Elf_RegInfo structure. */ 210 typedef struct 211 { 212 unsigned char ri_gprmask[4]; 213 unsigned char ri_cprmask[4][4]; 214 unsigned char ri_gp_value[4]; 215 } Elf32_External_RegInfo; 216 217 /* MIPS ELF .reginfo swapping routines. */ 218 extern void bfd_mips_elf32_swap_reginfo_in 219 PARAMS ((bfd *, const Elf32_External_RegInfo *, Elf32_RegInfo *)); 220 extern void bfd_mips_elf32_swap_reginfo_out 221 PARAMS ((bfd *, const Elf32_RegInfo *, Elf32_External_RegInfo *)); 222 223 /* Processor specific section flags. */ 224 225 /* This section must be in the global data area. */ 226 #define SHF_MIPS_GPREL 0x10000000 227 228 /* This section should be merged. */ 229 #define SHF_MIPS_MERGE 0x20000000 230 231 /* This section contains 32 bit addresses. */ 232 #define SHF_MIPS_ADDR32 0x40000000 233 234 /* This section contains 64 bit addresses. */ 235 #define SHF_MIPS_ADDR64 0x80000000 236 237 /* This section may not be stripped. */ 238 #define SHF_MIPS_NOSTRIP 0x08000000 239 240 /* This section is local to threads. */ 241 #define SHF_MIPS_LOCAL 0x04000000 242 243 /* Linker should generate implicit weak names for this section. */ 244 #define SHF_MIPS_NAMES 0x02000000 245 246 /* Processor specific program header types. */ 247 248 /* Register usage information. Identifies one .reginfo section. */ 249 #define PT_MIPS_REGINFO 0x70000000 250 251 /* Runtime procedure table. */ 252 #define PT_MIPS_RTPROC 0x70000001 253 254 /* Processor specific dynamic array tags. */ 255 256 /* 32 bit version number for runtime linker interface. */ 257 #define DT_MIPS_RLD_VERSION 0x70000001 258 259 /* Time stamp. */ 260 #define DT_MIPS_TIME_STAMP 0x70000002 261 262 /* Checksum of external strings and common sizes. */ 263 #define DT_MIPS_ICHECKSUM 0x70000003 264 265 /* Index of version string in string table. */ 266 #define DT_MIPS_IVERSION 0x70000004 267 268 /* 32 bits of flags. */ 269 #define DT_MIPS_FLAGS 0x70000005 270 271 /* Base address of the segment. */ 272 #define DT_MIPS_BASE_ADDRESS 0x70000006 273 274 /* Address of .conflict section. */ 275 #define DT_MIPS_CONFLICT 0x70000008 276 277 /* Address of .liblist section. */ 278 #define DT_MIPS_LIBLIST 0x70000009 279 280 /* Number of local global offset table entries. */ 281 #define DT_MIPS_LOCAL_GOTNO 0x7000000a 282 283 /* Number of entries in the .conflict section. */ 284 #define DT_MIPS_CONFLICTNO 0x7000000b 285 286 /* Number of entries in the .liblist section. */ 287 #define DT_MIPS_LIBLISTNO 0x70000010 288 289 /* Number of entries in the .dynsym section. */ 290 #define DT_MIPS_SYMTABNO 0x70000011 291 292 /* Index of first external dynamic symbol not referenced locally. */ 293 #define DT_MIPS_UNREFEXTNO 0x70000012 294 295 /* Index of first dynamic symbol in global offset table. */ 296 #define DT_MIPS_GOTSYM 0x70000013 297 298 /* Number of page table entries in global offset table. */ 299 #define DT_MIPS_HIPAGENO 0x70000014 300 301 /* Address of run time loader map, used for debugging. */ 302 #define DT_MIPS_RLD_MAP 0x70000016 303 304 /* Flags which may appear in a DT_MIPS_FLAGS entry. */ 305 306 /* No flags. */ 307 #define RHF_NONE 0x00000000 308 309 /* Uses shortcut pointers. */ 310 #define RHF_QUICKSTART 0x00000001 311 312 /* Hash size is not a power of two. */ 313 #define RHF_NOTPOT 0x00000002 314 315 /* Ignore LD_LIBRARY_PATH. */ 316 #define RHS_NO_LIBRARY_REPLACEMENT \ 317 0x00000004 318 319 /* Special values for the st_other field in the symbol table. These 320 are used in an Irix 5 dynamic symbol table. */ 321 322 #define STO_DEFAULT 0x00 323 #define STO_INTERNAL 0x01 324 #define STO_HIDDEN 0x02 325 #define STO_PROTECTED 0x03 326 327 /* The 64-bit MIPS ELF ABI uses an usual reloc format. Each 328 relocation entry specifies up to three actual relocations, all at 329 the same address. The first relocation which required a symbol 330 uses the symbol in the r_sym field. The second relocation which 331 requires a symbol uses the symbol in the r_ssym field. If all 332 three relocations require a symbol, the third one uses a zero 333 value. */ 334 335 /* An entry in a 64 bit SHT_REL section. */ 336 337 typedef struct 338 { 339 /* Address of relocation. */ 340 unsigned char r_offset[8]; 341 /* Symbol index. */ 342 unsigned char r_sym[4]; 343 /* Special symbol. */ 344 unsigned char r_ssym[1]; 345 /* Third relocation. */ 346 unsigned char r_type3[1]; 347 /* Second relocation. */ 348 unsigned char r_type2[1]; 349 /* First relocation. */ 350 unsigned char r_type[1]; 351 } Elf64_Mips_External_Rel; 352 353 typedef struct 354 { 355 /* Address of relocation. */ 356 bfd_vma r_offset; 357 /* Symbol index. */ 358 unsigned long r_sym; 359 /* Special symbol. */ 360 unsigned char r_ssym; 361 /* Third relocation. */ 362 unsigned char r_type3; 363 /* Second relocation. */ 364 unsigned char r_type2; 365 /* First relocation. */ 366 unsigned char r_type; 367 } Elf64_Mips_Internal_Rel; 368 369 /* An entry in a 64 bit SHT_RELA section. */ 370 371 typedef struct 372 { 373 /* Address of relocation. */ 374 unsigned char r_offset[8]; 375 /* Symbol index. */ 376 unsigned char r_sym[4]; 377 /* Special symbol. */ 378 unsigned char r_ssym[1]; 379 /* Third relocation. */ 380 unsigned char r_type3[1]; 381 /* Second relocation. */ 382 unsigned char r_type2[1]; 383 /* First relocation. */ 384 unsigned char r_type[1]; 385 /* Addend. */ 386 unsigned char r_addend[8]; 387 } Elf64_Mips_External_Rela; 388 389 typedef struct 390 { 391 /* Address of relocation. */ 392 bfd_vma r_offset; 393 /* Symbol index. */ 394 unsigned long r_sym; 395 /* Special symbol. */ 396 unsigned char r_ssym; 397 /* Third relocation. */ 398 unsigned char r_type3; 399 /* Second relocation. */ 400 unsigned char r_type2; 401 /* First relocation. */ 402 unsigned char r_type; 403 /* Addend. */ 404 bfd_signed_vma r_addend; 405 } Elf64_Mips_Internal_Rela; 406 407 /* Values found in the r_ssym field of a relocation entry. */ 408 409 /* No relocation. */ 410 #define RSS_UNDEF 0 411 412 /* Value of GP. */ 413 #define RSS_GP 1 414 415 /* Value of GP in object being relocated. */ 416 #define RSS_GP0 2 417 418 /* Address of location being relocated. */ 419 #define RSS_LOC 3 420 421 /* A SHT_MIPS_OPTIONS section contains a series of options, each of 422 which starts with this header. */ 423 424 typedef struct 425 { 426 /* Type of option. */ 427 unsigned char kind[1]; 428 /* Size of option descriptor, including header. */ 429 unsigned char size[1]; 430 /* Section index of affected section, or 0 for global option. */ 431 unsigned char section[2]; 432 /* Information specific to this kind of option. */ 433 unsigned char info[4]; 434 } Elf_External_Options; 435 436 typedef struct 437 { 438 /* Type of option. */ 439 unsigned char kind; 440 /* Size of option descriptor, including header. */ 441 unsigned char size; 442 /* Section index of affected section, or 0 for global option. */ 443 unsigned short section; 444 /* Information specific to this kind of option. */ 445 unsigned long info; 446 } Elf_Internal_Options; 447 448 /* MIPS ELF option header swapping routines. */ 449 extern void bfd_mips_elf_swap_options_in 450 PARAMS ((bfd *, const Elf_External_Options *, Elf_Internal_Options *)); 451 extern void bfd_mips_elf_swap_options_out 452 PARAMS ((bfd *, const Elf_Internal_Options *, Elf_External_Options *)); 453 454 /* Values which may appear in the kind field of an Elf_Options 455 structure. */ 456 457 /* Undefined. */ 458 #define ODK_NULL 0 459 460 /* Register usage and GP value. */ 461 #define ODK_REGINFO 1 462 463 /* Exception processing information. */ 464 #define ODK_EXCEPTIONS 2 465 466 /* Section padding information. */ 467 #define ODK_PAD 3 468 469 /* In the 32 bit ABI, an ODK_REGINFO option is just a Elf32_Reginfo 470 structure. In the 64 bit ABI, it is the following structure. The 471 info field of the options header is not used. */ 472 473 typedef struct 474 { 475 /* Mask of general purpose registers used. */ 476 unsigned char ri_gprmask[4]; 477 /* Padding. */ 478 unsigned char ri_pad[4]; 479 /* Mask of co-processor registers used. */ 480 unsigned char ri_cprmask[4][4]; 481 /* GP register value for this object file. */ 482 unsigned char ri_gp_value[8]; 483 } Elf64_External_RegInfo; 484 485 typedef struct 486 { 487 /* Mask of general purpose registers used. */ 488 unsigned long ri_gprmask; 489 /* Padding. */ 490 unsigned long ri_pad; 491 /* Mask of co-processor registers used. */ 492 unsigned long ri_cprmask[4]; 493 /* GP register value for this object file. */ 494 bfd_vma ri_gp_value; 495 } Elf64_Internal_RegInfo; 496 497 /* MIPS ELF reginfo swapping routines. */ 498 extern void bfd_mips_elf64_swap_reginfo_in 499 PARAMS ((bfd *, const Elf64_External_RegInfo *, Elf64_Internal_RegInfo *)); 500 extern void bfd_mips_elf64_swap_reginfo_out 501 PARAMS ((bfd *, const Elf64_Internal_RegInfo *, Elf64_External_RegInfo *)); 502 503 #endif /* _ELF_MIPS_H */ 504