| 1 | /* BFD support for handling relocation entries. |
| 2 | Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 |
| 3 | Free Software Foundation, Inc. |
| 4 | Written by Cygnus Support. |
| 5 | |
| 6 | This file is part of BFD, the Binary File Descriptor library. |
| 7 | |
| 8 | This program is free software; you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation; either version 2 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | This program is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with this program; if not, write to the Free Software |
| 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
| 21 | |
| 22 | /* |
| 23 | SECTION |
| 24 | Relocations |
| 25 | |
| 26 | BFD maintains relocations in much the same way it maintains |
| 27 | symbols: they are left alone until required, then read in |
| 28 | en-masse and translated into an internal form. A common |
| 29 | routine <<bfd_perform_relocation>> acts upon the |
| 30 | canonical form to do the fixup. |
| 31 | |
| 32 | Relocations are maintained on a per section basis, |
| 33 | while symbols are maintained on a per BFD basis. |
| 34 | |
| 35 | All that a back end has to do to fit the BFD interface is to create |
| 36 | a <<struct reloc_cache_entry>> for each relocation |
| 37 | in a particular section, and fill in the right bits of the structures. |
| 38 | |
| 39 | @menu |
| 40 | @* typedef arelent:: |
| 41 | @* howto manager:: |
| 42 | @end menu |
| 43 | |
| 44 | */ |
| 45 | |
| 46 | /* DO compile in the reloc_code name table from libbfd.h. */ |
| 47 | #define _BFD_MAKE_TABLE_bfd_reloc_code_real |
| 48 | |
| 49 | #include "bfd.h" |
| 50 | #include "sysdep.h" |
| 51 | #include "bfdlink.h" |
| 52 | #include "libbfd.h" |
| 53 | /* |
| 54 | DOCDD |
| 55 | INODE |
| 56 | typedef arelent, howto manager, Relocations, Relocations |
| 57 | |
| 58 | SUBSECTION |
| 59 | typedef arelent |
| 60 | |
| 61 | This is the structure of a relocation entry: |
| 62 | |
| 63 | CODE_FRAGMENT |
| 64 | . |
| 65 | .typedef enum bfd_reloc_status |
| 66 | .{ |
| 67 | . {* No errors detected *} |
| 68 | . bfd_reloc_ok, |
| 69 | . |
| 70 | . {* The relocation was performed, but there was an overflow. *} |
| 71 | . bfd_reloc_overflow, |
| 72 | . |
| 73 | . {* The address to relocate was not within the section supplied. *} |
| 74 | . bfd_reloc_outofrange, |
| 75 | . |
| 76 | . {* Used by special functions *} |
| 77 | . bfd_reloc_continue, |
| 78 | . |
| 79 | . {* Unsupported relocation size requested. *} |
| 80 | . bfd_reloc_notsupported, |
| 81 | . |
| 82 | . {* Unused *} |
| 83 | . bfd_reloc_other, |
| 84 | . |
| 85 | . {* The symbol to relocate against was undefined. *} |
| 86 | . bfd_reloc_undefined, |
| 87 | . |
| 88 | . {* The relocation was performed, but may not be ok - presently |
| 89 | . generated only when linking i960 coff files with i960 b.out |
| 90 | . symbols. If this type is returned, the error_message argument |
| 91 | . to bfd_perform_relocation will be set. *} |
| 92 | . bfd_reloc_dangerous |
| 93 | . } |
| 94 | . bfd_reloc_status_type; |
| 95 | . |
| 96 | . |
| 97 | .typedef struct reloc_cache_entry |
| 98 | .{ |
| 99 | . {* A pointer into the canonical table of pointers *} |
| 100 | . struct symbol_cache_entry **sym_ptr_ptr; |
| 101 | . |
| 102 | . {* offset in section *} |
| 103 | . bfd_size_type address; |
| 104 | . |
| 105 | . {* addend for relocation value *} |
| 106 | . bfd_vma addend; |
| 107 | . |
| 108 | . {* Pointer to how to perform the required relocation *} |
| 109 | . reloc_howto_type *howto; |
| 110 | . |
| 111 | .} arelent; |
| 112 | |
| 113 | */ |
| 114 | |
| 115 | /* |
| 116 | DESCRIPTION |
| 117 | |
| 118 | Here is a description of each of the fields within an <<arelent>>: |
| 119 | |
| 120 | o <<sym_ptr_ptr>> |
| 121 | |
| 122 | The symbol table pointer points to a pointer to the symbol |
| 123 | associated with the relocation request. It is |
| 124 | the pointer into the table returned by the back end's |
| 125 | <<get_symtab>> action. @xref{Symbols}. The symbol is referenced |
| 126 | through a pointer to a pointer so that tools like the linker |
| 127 | can fix up all the symbols of the same name by modifying only |
| 128 | one pointer. The relocation routine looks in the symbol and |
| 129 | uses the base of the section the symbol is attached to and the |
| 130 | value of the symbol as the initial relocation offset. If the |
| 131 | symbol pointer is zero, then the section provided is looked up. |
| 132 | |
| 133 | o <<address>> |
| 134 | |
| 135 | The <<address>> field gives the offset in bytes from the base of |
| 136 | the section data which owns the relocation record to the first |
| 137 | byte of relocatable information. The actual data relocated |
| 138 | will be relative to this point; for example, a relocation |
| 139 | type which modifies the bottom two bytes of a four byte word |
| 140 | would not touch the first byte pointed to in a big endian |
| 141 | world. |
| 142 | |
| 143 | o <<addend>> |
| 144 | |
| 145 | The <<addend>> is a value provided by the back end to be added (!) |
| 146 | to the relocation offset. Its interpretation is dependent upon |
| 147 | the howto. For example, on the 68k the code: |
| 148 | |
| 149 | |
| 150 | | char foo[]; |
| 151 | | main() |
| 152 | | { |
| 153 | | return foo[0x12345678]; |
| 154 | | } |
| 155 | |
| 156 | Could be compiled into: |
| 157 | |
| 158 | | linkw fp,#-4 |
| 159 | | moveb @@#12345678,d0 |
| 160 | | extbl d0 |
| 161 | | unlk fp |
| 162 | | rts |
| 163 | |
| 164 | |
| 165 | This could create a reloc pointing to <<foo>>, but leave the |
| 166 | offset in the data, something like: |
| 167 | |
| 168 | |
| 169 | |RELOCATION RECORDS FOR [.text]: |
| 170 | |offset type value |
| 171 | |00000006 32 _foo |
| 172 | | |
| 173 | |00000000 4e56 fffc ; linkw fp,#-4 |
| 174 | |00000004 1039 1234 5678 ; moveb @@#12345678,d0 |
| 175 | |0000000a 49c0 ; extbl d0 |
| 176 | |0000000c 4e5e ; unlk fp |
| 177 | |0000000e 4e75 ; rts |
| 178 | |
| 179 | |
| 180 | Using coff and an 88k, some instructions don't have enough |
| 181 | space in them to represent the full address range, and |
| 182 | pointers have to be loaded in two parts. So you'd get something like: |
| 183 | |
| 184 | |
| 185 | | or.u r13,r0,hi16(_foo+0x12345678) |
| 186 | | ld.b r2,r13,lo16(_foo+0x12345678) |
| 187 | | jmp r1 |
| 188 | |
| 189 | |
| 190 | This should create two relocs, both pointing to <<_foo>>, and with |
| 191 | 0x12340000 in their addend field. The data would consist of: |
| 192 | |
| 193 | |
| 194 | |RELOCATION RECORDS FOR [.text]: |
| 195 | |offset type value |
| 196 | |00000002 HVRT16 _foo+0x12340000 |
| 197 | |00000006 LVRT16 _foo+0x12340000 |
| 198 | | |
| 199 | |00000000 5da05678 ; or.u r13,r0,0x5678 |
| 200 | |00000004 1c4d5678 ; ld.b r2,r13,0x5678 |
| 201 | |00000008 f400c001 ; jmp r1 |
| 202 | |
| 203 | |
| 204 | The relocation routine digs out the value from the data, adds |
| 205 | it to the addend to get the original offset, and then adds the |
| 206 | value of <<_foo>>. Note that all 32 bits have to be kept around |
| 207 | somewhere, to cope with carry from bit 15 to bit 16. |
| 208 | |
| 209 | One further example is the sparc and the a.out format. The |
| 210 | sparc has a similar problem to the 88k, in that some |
| 211 | instructions don't have room for an entire offset, but on the |
| 212 | sparc the parts are created in odd sized lumps. The designers of |
| 213 | the a.out format chose to not use the data within the section |
| 214 | for storing part of the offset; all the offset is kept within |
| 215 | the reloc. Anything in the data should be ignored. |
| 216 | |
| 217 | | save %sp,-112,%sp |
| 218 | | sethi %hi(_foo+0x12345678),%g2 |
| 219 | | ldsb [%g2+%lo(_foo+0x12345678)],%i0 |
| 220 | | ret |
| 221 | | restore |
| 222 | |
| 223 | Both relocs contain a pointer to <<foo>>, and the offsets |
| 224 | contain junk. |
| 225 | |
| 226 | |
| 227 | |RELOCATION RECORDS FOR [.text]: |
| 228 | |offset type value |
| 229 | |00000004 HI22 _foo+0x12345678 |
| 230 | |00000008 LO10 _foo+0x12345678 |
| 231 | | |
| 232 | |00000000 9de3bf90 ; save %sp,-112,%sp |
| 233 | |00000004 05000000 ; sethi %hi(_foo+0),%g2 |
| 234 | |00000008 f048a000 ; ldsb [%g2+%lo(_foo+0)],%i0 |
| 235 | |0000000c 81c7e008 ; ret |
| 236 | |00000010 81e80000 ; restore |
| 237 | |
| 238 | |
| 239 | o <<howto>> |
| 240 | |
| 241 | The <<howto>> field can be imagined as a |
| 242 | relocation instruction. It is a pointer to a structure which |
| 243 | contains information on what to do with all of the other |
| 244 | information in the reloc record and data section. A back end |
| 245 | would normally have a relocation instruction set and turn |
| 246 | relocations into pointers to the correct structure on input - |
| 247 | but it would be possible to create each howto field on demand. |
| 248 | |
| 249 | */ |
| 250 | |
| 251 | /* |
| 252 | SUBSUBSECTION |
| 253 | <<enum complain_overflow>> |
| 254 | |
| 255 | Indicates what sort of overflow checking should be done when |
| 256 | performing a relocation. |
| 257 | |
| 258 | CODE_FRAGMENT |
| 259 | . |
| 260 | .enum complain_overflow |
| 261 | .{ |
| 262 | . {* Do not complain on overflow. *} |
| 263 | . complain_overflow_dont, |
| 264 | . |
| 265 | . {* Complain if the bitfield overflows, whether it is considered |
| 266 | . as signed or unsigned. *} |
| 267 | . complain_overflow_bitfield, |
| 268 | . |
| 269 | . {* Complain if the value overflows when considered as signed |
| 270 | . number. *} |
| 271 | . complain_overflow_signed, |
| 272 | . |
| 273 | . {* Complain if the value overflows when considered as an |
| 274 | . unsigned number. *} |
| 275 | . complain_overflow_unsigned |
| 276 | .}; |
| 277 | |
| 278 | */ |
| 279 | |
| 280 | /* |
| 281 | SUBSUBSECTION |
| 282 | <<reloc_howto_type>> |
| 283 | |
| 284 | The <<reloc_howto_type>> is a structure which contains all the |
| 285 | information that libbfd needs to know to tie up a back end's data. |
| 286 | |
| 287 | CODE_FRAGMENT |
| 288 | .struct symbol_cache_entry; {* Forward declaration *} |
| 289 | . |
| 290 | .struct reloc_howto_struct |
| 291 | .{ |
| 292 | . {* The type field has mainly a documentary use - the back end can |
| 293 | . do what it wants with it, though normally the back end's |
| 294 | . external idea of what a reloc number is stored |
| 295 | . in this field. For example, a PC relative word relocation |
| 296 | . in a coff environment has the type 023 - because that's |
| 297 | . what the outside world calls a R_PCRWORD reloc. *} |
| 298 | . unsigned int type; |
| 299 | . |
| 300 | . {* The value the final relocation is shifted right by. This drops |
| 301 | . unwanted data from the relocation. *} |
| 302 | . unsigned int rightshift; |
| 303 | . |
| 304 | . {* The size of the item to be relocated. This is *not* a |
| 305 | . power-of-two measure. To get the number of bytes operated |
| 306 | . on by a type of relocation, use bfd_get_reloc_size. *} |
| 307 | . int size; |
| 308 | . |
| 309 | . {* The number of bits in the item to be relocated. This is used |
| 310 | . when doing overflow checking. *} |
| 311 | . unsigned int bitsize; |
| 312 | . |
| 313 | . {* Notes that the relocation is relative to the location in the |
| 314 | . data section of the addend. The relocation function will |
| 315 | . subtract from the relocation value the address of the location |
| 316 | . being relocated. *} |
| 317 | . boolean pc_relative; |
| 318 | . |
| 319 | . {* The bit position of the reloc value in the destination. |
| 320 | . The relocated value is left shifted by this amount. *} |
| 321 | . unsigned int bitpos; |
| 322 | . |
| 323 | . {* What type of overflow error should be checked for when |
| 324 | . relocating. *} |
| 325 | . enum complain_overflow complain_on_overflow; |
| 326 | . |
| 327 | . {* If this field is non null, then the supplied function is |
| 328 | . called rather than the normal function. This allows really |
| 329 | . strange relocation methods to be accomodated (e.g., i960 callj |
| 330 | . instructions). *} |
| 331 | . bfd_reloc_status_type (*special_function) |
| 332 | . PARAMS ((bfd *abfd, |
| 333 | . arelent *reloc_entry, |
| 334 | . struct symbol_cache_entry *symbol, |
| 335 | . PTR data, |
| 336 | . asection *input_section, |
| 337 | . bfd *output_bfd, |
| 338 | . char **error_message)); |
| 339 | . |
| 340 | . {* The textual name of the relocation type. *} |
| 341 | . char *name; |
| 342 | . |
| 343 | . {* Some formats record a relocation addend in the section contents |
| 344 | . rather than with the relocation. For ELF formats this is the |
| 345 | . distinction between USE_REL and USE_RELA (though the code checks |
| 346 | . for USE_REL == 1/0). The value of this field is TRUE if the |
| 347 | . addend is recorded with the section contents; when performing a |
| 348 | . partial link (ld -r) the section contents (the data) will be |
| 349 | . modified. The value of this field is FALSE if addends are |
| 350 | . recorded with the relocation (in arelent.addend); when performing |
| 351 | . a partial link the relocation will be modified. |
| 352 | . All relocations for all ELF USE_RELA targets should set this field |
| 353 | . to FALSE (values of TRUE should be looked on with suspicion). |
| 354 | . However, the converse is not true: not all relocations of all ELF |
| 355 | . USE_REL targets set this field to TRUE. Why this is so is peculiar |
| 356 | . to each particular target. For relocs that aren't used in partial |
| 357 | . links (e.g. GOT stuff) it doesn't matter what this is set to. *} |
| 358 | . boolean partial_inplace; |
| 359 | . |
| 360 | . {* The src_mask selects which parts of the read in data |
| 361 | . are to be used in the relocation sum. E.g., if this was an 8 bit |
| 362 | . byte of data which we read and relocated, this would be |
| 363 | . 0x000000ff. When we have relocs which have an addend, such as |
| 364 | . sun4 extended relocs, the value in the offset part of a |
| 365 | . relocating field is garbage so we never use it. In this case |
| 366 | . the mask would be 0x00000000. *} |
| 367 | . bfd_vma src_mask; |
| 368 | . |
| 369 | . {* The dst_mask selects which parts of the instruction are replaced |
| 370 | . into the instruction. In most cases src_mask == dst_mask, |
| 371 | . except in the above special case, where dst_mask would be |
| 372 | . 0x000000ff, and src_mask would be 0x00000000. *} |
| 373 | . bfd_vma dst_mask; |
| 374 | . |
| 375 | . {* When some formats create PC relative instructions, they leave |
| 376 | . the value of the pc of the place being relocated in the offset |
| 377 | . slot of the instruction, so that a PC relative relocation can |
| 378 | . be made just by adding in an ordinary offset (e.g., sun3 a.out). |
| 379 | . Some formats leave the displacement part of an instruction |
| 380 | . empty (e.g., m88k bcs); this flag signals the fact.*} |
| 381 | . boolean pcrel_offset; |
| 382 | . |
| 383 | .}; |
| 384 | |
| 385 | */ |
| 386 | |
| 387 | /* |
| 388 | FUNCTION |
| 389 | The HOWTO Macro |
| 390 | |
| 391 | DESCRIPTION |
| 392 | The HOWTO define is horrible and will go away. |
| 393 | |
| 394 | |
| 395 | .#define HOWTO(C, R,S,B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \ |
| 396 | . {(unsigned)C,R,S,B, P, BI, O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC} |
| 397 | |
| 398 | DESCRIPTION |
| 399 | And will be replaced with the totally magic way. But for the |
| 400 | moment, we are compatible, so do it this way. |
| 401 | |
| 402 | |
| 403 | .#define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,complain_overflow_dont,FUNCTION, NAME,false,0,0,IN) |
| 404 | . |
| 405 | |
| 406 | DESCRIPTION |
| 407 | This is used to fill in an empty howto entry in an array. |
| 408 | |
| 409 | .#define EMPTY_HOWTO(C) \ |
| 410 | . HOWTO((C),0,0,0,false,0,complain_overflow_dont,NULL,NULL,false,0,0,false) |
| 411 | . |
| 412 | |
| 413 | DESCRIPTION |
| 414 | Helper routine to turn a symbol into a relocation value. |
| 415 | |
| 416 | .#define HOWTO_PREPARE(relocation, symbol) \ |
| 417 | . { \ |
| 418 | . if (symbol != (asymbol *)NULL) { \ |
| 419 | . if (bfd_is_com_section (symbol->section)) { \ |
| 420 | . relocation = 0; \ |
| 421 | . } \ |
| 422 | . else { \ |
| 423 | . relocation = symbol->value; \ |
| 424 | . } \ |
| 425 | . } \ |
| 426 | .} |
| 427 | |
| 428 | */ |
| 429 | |
| 430 | /* |
| 431 | FUNCTION |
| 432 | bfd_get_reloc_size |
| 433 | |
| 434 | SYNOPSIS |
| 435 | unsigned int bfd_get_reloc_size (reloc_howto_type *); |
| 436 | |
| 437 | DESCRIPTION |
| 438 | For a reloc_howto_type that operates on a fixed number of bytes, |
| 439 | this returns the number of bytes operated on. |
| 440 | */ |
| 441 | |
| 442 | unsigned int |
| 443 | bfd_get_reloc_size (howto) |
| 444 | reloc_howto_type *howto; |
| 445 | { |
| 446 | switch (howto->size) |
| 447 | { |
| 448 | case 0: return 1; |
| 449 | case 1: return 2; |
| 450 | case 2: return 4; |
| 451 | case 3: return 0; |
| 452 | case 4: return 8; |
| 453 | case 8: return 16; |
| 454 | case -2: return 4; |
| 455 | default: abort (); |
| 456 | } |
| 457 | } |
| 458 | |
| 459 | /* |
| 460 | TYPEDEF |
| 461 | arelent_chain |
| 462 | |
| 463 | DESCRIPTION |
| 464 | |
| 465 | How relocs are tied together in an <<asection>>: |
| 466 | |
| 467 | .typedef struct relent_chain { |
| 468 | . arelent relent; |
| 469 | . struct relent_chain *next; |
| 470 | .} arelent_chain; |
| 471 | |
| 472 | */ |
| 473 | |
| 474 | /* N_ONES produces N one bits, without overflowing machine arithmetic. */ |
| 475 | #define N_ONES(n) (((((bfd_vma) 1 << ((n) - 1)) - 1) << 1) | 1) |
| 476 | |
| 477 | /* |
| 478 | FUNCTION |
| 479 | bfd_check_overflow |
| 480 | |
| 481 | SYNOPSIS |
| 482 | bfd_reloc_status_type |
| 483 | bfd_check_overflow |
| 484 | (enum complain_overflow how, |
| 485 | unsigned int bitsize, |
| 486 | unsigned int rightshift, |
| 487 | unsigned int addrsize, |
| 488 | bfd_vma relocation); |
| 489 | |
| 490 | DESCRIPTION |
| 491 | Perform overflow checking on @var{relocation} which has |
| 492 | @var{bitsize} significant bits and will be shifted right by |
| 493 | @var{rightshift} bits, on a machine with addresses containing |
| 494 | @var{addrsize} significant bits. The result is either of |
| 495 | @code{bfd_reloc_ok} or @code{bfd_reloc_overflow}. |
| 496 | |
| 497 | */ |
| 498 | |
| 499 | bfd_reloc_status_type |
| 500 | bfd_check_overflow (how, bitsize, rightshift, addrsize, relocation) |
| 501 | enum complain_overflow how; |
| 502 | unsigned int bitsize; |
| 503 | unsigned int rightshift; |
| 504 | unsigned int addrsize; |
| 505 | bfd_vma relocation; |
| 506 | { |
| 507 | bfd_vma fieldmask, addrmask, signmask, ss, a; |
| 508 | bfd_reloc_status_type flag = bfd_reloc_ok; |
| 509 | |
| 510 | a = relocation; |
| 511 | |
| 512 | /* Note: BITSIZE should always be <= ADDRSIZE, but in case it's not, |
| 513 | we'll be permissive: extra bits in the field mask will |
| 514 | automatically extend the address mask for purposes of the |
| 515 | overflow check. */ |
| 516 | fieldmask = N_ONES (bitsize); |
| 517 | addrmask = N_ONES (addrsize) | fieldmask; |
| 518 | |
| 519 | switch (how) |
| 520 | { |
| 521 | case complain_overflow_dont: |
| 522 | break; |
| 523 | |
| 524 | case complain_overflow_signed: |
| 525 | /* If any sign bits are set, all sign bits must be set. That |
| 526 | is, A must be a valid negative address after shifting. */ |
| 527 | a = (a & addrmask) >> rightshift; |
| 528 | signmask = ~ (fieldmask >> 1); |
| 529 | ss = a & signmask; |
| 530 | if (ss != 0 && ss != ((addrmask >> rightshift) & signmask)) |
| 531 | flag = bfd_reloc_overflow; |
| 532 | break; |
| 533 | |
| 534 | case complain_overflow_unsigned: |
| 535 | /* We have an overflow if the address does not fit in the field. */ |
| 536 | a = (a & addrmask) >> rightshift; |
| 537 | if ((a & ~ fieldmask) != 0) |
| 538 | flag = bfd_reloc_overflow; |
| 539 | break; |
| 540 | |
| 541 | case complain_overflow_bitfield: |
| 542 | /* Bitfields are sometimes signed, sometimes unsigned. We |
| 543 | explicitly allow an address wrap too, which means a bitfield |
| 544 | of n bits is allowed to store -2**n to 2**n-1. Thus overflow |
| 545 | if the value has some, but not all, bits set outside the |
| 546 | field. */ |
| 547 | a >>= rightshift; |
| 548 | ss = a & ~ fieldmask; |
| 549 | if (ss != 0 && ss != (((bfd_vma) -1 >> rightshift) & ~ fieldmask)) |
| 550 | flag = bfd_reloc_overflow; |
| 551 | break; |
| 552 | |
| 553 | default: |
| 554 | abort (); |
| 555 | } |
| 556 | |
| 557 | return flag; |
| 558 | } |
| 559 | |
| 560 | /* |
| 561 | FUNCTION |
| 562 | bfd_perform_relocation |
| 563 | |
| 564 | SYNOPSIS |
| 565 | bfd_reloc_status_type |
| 566 | bfd_perform_relocation |
| 567 | (bfd *abfd, |
| 568 | arelent *reloc_entry, |
| 569 | PTR data, |
| 570 | asection *input_section, |
| 571 | bfd *output_bfd, |
| 572 | char **error_message); |
| 573 | |
| 574 | DESCRIPTION |
| 575 | If @var{output_bfd} is supplied to this function, the |
| 576 | generated image will be relocatable; the relocations are |
| 577 | copied to the output file after they have been changed to |
| 578 | reflect the new state of the world. There are two ways of |
| 579 | reflecting the results of partial linkage in an output file: |
| 580 | by modifying the output data in place, and by modifying the |
| 581 | relocation record. Some native formats (e.g., basic a.out and |
| 582 | basic coff) have no way of specifying an addend in the |
| 583 | relocation type, so the addend has to go in the output data. |
| 584 | This is no big deal since in these formats the output data |
| 585 | slot will always be big enough for the addend. Complex reloc |
| 586 | types with addends were invented to solve just this problem. |
| 587 | The @var{error_message} argument is set to an error message if |
| 588 | this return @code{bfd_reloc_dangerous}. |
| 589 | |
| 590 | */ |
| 591 | |
| 592 | |
| 593 | bfd_reloc_status_type |
| 594 | bfd_perform_relocation (abfd, reloc_entry, data, input_section, output_bfd, |
| 595 | error_message) |
| 596 | bfd *abfd; |
| 597 | arelent *reloc_entry; |
| 598 | PTR data; |
| 599 | asection *input_section; |
| 600 | bfd *output_bfd; |
| 601 | char **error_message; |
| 602 | { |
| 603 | bfd_vma relocation; |
| 604 | bfd_reloc_status_type flag = bfd_reloc_ok; |
| 605 | bfd_size_type octets = reloc_entry->address * bfd_octets_per_byte (abfd); |
| 606 | bfd_vma output_base = 0; |
| 607 | reloc_howto_type *howto = reloc_entry->howto; |
| 608 | asection *reloc_target_output_section; |
| 609 | asymbol *symbol; |
| 610 | |
| 611 | symbol = *(reloc_entry->sym_ptr_ptr); |
| 612 | if (bfd_is_abs_section (symbol->section) |
| 613 | && output_bfd != (bfd *) NULL) |
| 614 | { |
| 615 | reloc_entry->address += input_section->output_offset; |
| 616 | return bfd_reloc_ok; |
| 617 | } |
| 618 | |
| 619 | /* If we are not producing relocateable output, return an error if |
| 620 | the symbol is not defined. An undefined weak symbol is |
| 621 | considered to have a value of zero (SVR4 ABI, p. 4-27). */ |
| 622 | if (bfd_is_und_section (symbol->section) |
| 623 | && (symbol->flags & BSF_WEAK) == 0 |
| 624 | && output_bfd == (bfd *) NULL) |
| 625 | flag = bfd_reloc_undefined; |
| 626 | |
| 627 | /* If there is a function supplied to handle this relocation type, |
| 628 | call it. It'll return `bfd_reloc_continue' if further processing |
| 629 | can be done. */ |
| 630 | if (howto->special_function) |
| 631 | { |
| 632 | bfd_reloc_status_type cont; |
| 633 | cont = howto->special_function (abfd, reloc_entry, symbol, data, |
| 634 | input_section, output_bfd, |
| 635 | error_message); |
| 636 | if (cont != bfd_reloc_continue) |
| 637 | return cont; |
| 638 | } |
| 639 | |
| 640 | /* Is the address of the relocation really within the section? */ |
| 641 | if (reloc_entry->address > input_section->_cooked_size / |
| 642 | bfd_octets_per_byte (abfd)) |
| 643 | return bfd_reloc_outofrange; |
| 644 | |
| 645 | /* Work out which section the relocation is targetted at and the |
| 646 | initial relocation command value. */ |
| 647 | |
| 648 | /* Get symbol value. (Common symbols are special.) */ |
| 649 | if (bfd_is_com_section (symbol->section)) |
| 650 | relocation = 0; |
| 651 | else |
| 652 | relocation = symbol->value; |
| 653 | |
| 654 | |
| 655 | reloc_target_output_section = symbol->section->output_section; |
| 656 | |
| 657 | /* Convert input-section-relative symbol value to absolute. */ |
| 658 | if (output_bfd && howto->partial_inplace == false) |
| 659 | output_base = 0; |
| 660 | else |
| 661 | output_base = reloc_target_output_section->vma; |
| 662 | |
| 663 | relocation += output_base + symbol->section->output_offset; |
| 664 | |
| 665 | /* Add in supplied addend. */ |
| 666 | relocation += reloc_entry->addend; |
| 667 | |
| 668 | /* Here the variable relocation holds the final address of the |
| 669 | symbol we are relocating against, plus any addend. */ |
| 670 | |
| 671 | if (howto->pc_relative == true) |
| 672 | { |
| 673 | /* This is a PC relative relocation. We want to set RELOCATION |
| 674 | to the distance between the address of the symbol and the |
| 675 | location. RELOCATION is already the address of the symbol. |
| 676 | |
| 677 | We start by subtracting the address of the section containing |
| 678 | the location. |
| 679 | |
| 680 | If pcrel_offset is set, we must further subtract the position |
| 681 | of the location within the section. Some targets arrange for |
| 682 | the addend to be the negative of the position of the location |
| 683 | within the section; for example, i386-aout does this. For |
| 684 | i386-aout, pcrel_offset is false. Some other targets do not |
| 685 | include the position of the location; for example, m88kbcs, |
| 686 | or ELF. For those targets, pcrel_offset is true. |
| 687 | |
| 688 | If we are producing relocateable output, then we must ensure |
| 689 | that this reloc will be correctly computed when the final |
| 690 | relocation is done. If pcrel_offset is false we want to wind |
| 691 | up with the negative of the location within the section, |
| 692 | which means we must adjust the existing addend by the change |
| 693 | in the location within the section. If pcrel_offset is true |
| 694 | we do not want to adjust the existing addend at all. |
| 695 | |
| 696 | FIXME: This seems logical to me, but for the case of |
| 697 | producing relocateable output it is not what the code |
| 698 | actually does. I don't want to change it, because it seems |
| 699 | far too likely that something will break. */ |
| 700 | |
| 701 | relocation -= |
| 702 | input_section->output_section->vma + input_section->output_offset; |
| 703 | |
| 704 | if (howto->pcrel_offset == true) |
| 705 | relocation -= reloc_entry->address; |
| 706 | } |
| 707 | |
| 708 | if (output_bfd != (bfd *) NULL) |
| 709 | { |
| 710 | if (howto->partial_inplace == false) |
| 711 | { |
| 712 | /* This is a partial relocation, and we want to apply the relocation |
| 713 | to the reloc entry rather than the raw data. Modify the reloc |
| 714 | inplace to reflect what we now know. */ |
| 715 | reloc_entry->addend = relocation; |
| 716 | reloc_entry->address += input_section->output_offset; |
| 717 | return flag; |
| 718 | } |
| 719 | else |
| 720 | { |
| 721 | /* This is a partial relocation, but inplace, so modify the |
| 722 | reloc record a bit. |
| 723 | |
| 724 | If we've relocated with a symbol with a section, change |
| 725 | into a ref to the section belonging to the symbol. */ |
| 726 | |
| 727 | reloc_entry->address += input_section->output_offset; |
| 728 | |
| 729 | /* WTF?? */ |
| 730 | if (abfd->xvec->flavour == bfd_target_coff_flavour |
| 731 | && strcmp (abfd->xvec->name, "coff-Intel-little") != 0 |
| 732 | && strcmp (abfd->xvec->name, "coff-Intel-big") != 0) |
| 733 | { |
| 734 | #if 1 |
| 735 | /* For m68k-coff, the addend was being subtracted twice during |
| 736 | relocation with -r. Removing the line below this comment |
| 737 | fixes that problem; see PR 2953. |
| 738 | |
| 739 | However, Ian wrote the following, regarding removing the line below, |
| 740 | which explains why it is still enabled: --djm |
| 741 | |
| 742 | If you put a patch like that into BFD you need to check all the COFF |
| 743 | linkers. I am fairly certain that patch will break coff-i386 (e.g., |
| 744 | SCO); see coff_i386_reloc in coff-i386.c where I worked around the |
| 745 | problem in a different way. There may very well be a reason that the |
| 746 | code works as it does. |
| 747 | |
| 748 | Hmmm. The first obvious point is that bfd_perform_relocation should |
| 749 | not have any tests that depend upon the flavour. It's seem like |
| 750 | entirely the wrong place for such a thing. The second obvious point |
| 751 | is that the current code ignores the reloc addend when producing |
| 752 | relocateable output for COFF. That's peculiar. In fact, I really |
| 753 | have no idea what the point of the line you want to remove is. |
| 754 | |
| 755 | A typical COFF reloc subtracts the old value of the symbol and adds in |
| 756 | the new value to the location in the object file (if it's a pc |
| 757 | relative reloc it adds the difference between the symbol value and the |
| 758 | location). When relocating we need to preserve that property. |
| 759 | |
| 760 | BFD handles this by setting the addend to the negative of the old |
| 761 | value of the symbol. Unfortunately it handles common symbols in a |
| 762 | non-standard way (it doesn't subtract the old value) but that's a |
| 763 | different story (we can't change it without losing backward |
| 764 | compatibility with old object files) (coff-i386 does subtract the old |
| 765 | value, to be compatible with existing coff-i386 targets, like SCO). |
| 766 | |
| 767 | So everything works fine when not producing relocateable output. When |
| 768 | we are producing relocateable output, logically we should do exactly |
| 769 | what we do when not producing relocateable output. Therefore, your |
| 770 | patch is correct. In fact, it should probably always just set |
| 771 | reloc_entry->addend to 0 for all cases, since it is, in fact, going to |
| 772 | add the value into the object file. This won't hurt the COFF code, |
| 773 | which doesn't use the addend; I'm not sure what it will do to other |
| 774 | formats (the thing to check for would be whether any formats both use |
| 775 | the addend and set partial_inplace). |
| 776 | |
| 777 | When I wanted to make coff-i386 produce relocateable output, I ran |
| 778 | into the problem that you are running into: I wanted to remove that |
| 779 | line. Rather than risk it, I made the coff-i386 relocs use a special |
| 780 | function; it's coff_i386_reloc in coff-i386.c. The function |
| 781 | specifically adds the addend field into the object file, knowing that |
| 782 | bfd_perform_relocation is not going to. If you remove that line, then |
| 783 | coff-i386.c will wind up adding the addend field in twice. It's |
| 784 | trivial to fix; it just needs to be done. |
| 785 | |
| 786 | The problem with removing the line is just that it may break some |
| 787 | working code. With BFD it's hard to be sure of anything. The right |
| 788 | way to deal with this is simply to build and test at least all the |
| 789 | supported COFF targets. It should be straightforward if time and disk |
| 790 | space consuming. For each target: |
| 791 | 1) build the linker |
| 792 | 2) generate some executable, and link it using -r (I would |
| 793 | probably use paranoia.o and link against newlib/libc.a, which |
| 794 | for all the supported targets would be available in |
| 795 | /usr/cygnus/progressive/H-host/target/lib/libc.a). |
| 796 | 3) make the change to reloc.c |
| 797 | 4) rebuild the linker |
| 798 | 5) repeat step 2 |
| 799 | 6) if the resulting object files are the same, you have at least |
| 800 | made it no worse |
| 801 | 7) if they are different you have to figure out which version is |
| 802 | right |
| 803 | */ |
| 804 | relocation -= reloc_entry->addend; |
| 805 | #endif |
| 806 | reloc_entry->addend = 0; |
| 807 | } |
| 808 | else |
| 809 | { |
| 810 | reloc_entry->addend = relocation; |
| 811 | } |
| 812 | } |
| 813 | } |
| 814 | else |
| 815 | { |
| 816 | reloc_entry->addend = 0; |
| 817 | } |
| 818 | |
| 819 | /* FIXME: This overflow checking is incomplete, because the value |
| 820 | might have overflowed before we get here. For a correct check we |
| 821 | need to compute the value in a size larger than bitsize, but we |
| 822 | can't reasonably do that for a reloc the same size as a host |
| 823 | machine word. |
| 824 | FIXME: We should also do overflow checking on the result after |
| 825 | adding in the value contained in the object file. */ |
| 826 | if (howto->complain_on_overflow != complain_overflow_dont |
| 827 | && flag == bfd_reloc_ok) |
| 828 | flag = bfd_check_overflow (howto->complain_on_overflow, |
| 829 | howto->bitsize, |
| 830 | howto->rightshift, |
| 831 | bfd_arch_bits_per_address (abfd), |
| 832 | relocation); |
| 833 | |
| 834 | /* |
| 835 | Either we are relocating all the way, or we don't want to apply |
| 836 | the relocation to the reloc entry (probably because there isn't |
| 837 | any room in the output format to describe addends to relocs) |
| 838 | */ |
| 839 | |
| 840 | /* The cast to bfd_vma avoids a bug in the Alpha OSF/1 C compiler |
| 841 | (OSF version 1.3, compiler version 3.11). It miscompiles the |
| 842 | following program: |
| 843 | |
| 844 | struct str |
| 845 | { |
| 846 | unsigned int i0; |
| 847 | } s = { 0 }; |
| 848 | |
| 849 | int |
| 850 | main () |
| 851 | { |
| 852 | unsigned long x; |
| 853 | |
| 854 | x = 0x100000000; |
| 855 | x <<= (unsigned long) s.i0; |
| 856 | if (x == 0) |
| 857 | printf ("failed\n"); |
| 858 | else |
| 859 | printf ("succeeded (%lx)\n", x); |
| 860 | } |
| 861 | */ |
| 862 | |
| 863 | relocation >>= (bfd_vma) howto->rightshift; |
| 864 | |
| 865 | /* Shift everything up to where it's going to be used */ |
| 866 | |
| 867 | relocation <<= (bfd_vma) howto->bitpos; |
| 868 | |
| 869 | /* Wait for the day when all have the mask in them */ |
| 870 | |
| 871 | /* What we do: |
| 872 | i instruction to be left alone |
| 873 | o offset within instruction |
| 874 | r relocation offset to apply |
| 875 | S src mask |
| 876 | D dst mask |
| 877 | N ~dst mask |
| 878 | A part 1 |
| 879 | B part 2 |
| 880 | R result |
| 881 | |
| 882 | Do this: |
| 883 | (( i i i i i o o o o o from bfd_get<size> |
| 884 | and S S S S S) to get the size offset we want |
| 885 | + r r r r r r r r r r) to get the final value to place |
| 886 | and D D D D D to chop to right size |
| 887 | ----------------------- |
| 888 | = A A A A A |
| 889 | And this: |
| 890 | ( i i i i i o o o o o from bfd_get<size> |
| 891 | and N N N N N ) get instruction |
| 892 | ----------------------- |
| 893 | = B B B B B |
| 894 | |
| 895 | And then: |
| 896 | ( B B B B B |
| 897 | or A A A A A) |
| 898 | ----------------------- |
| 899 | = R R R R R R R R R R put into bfd_put<size> |
| 900 | */ |
| 901 | |
| 902 | #define DOIT(x) \ |
| 903 | x = ( (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask)) |
| 904 | |
| 905 | switch (howto->size) |
| 906 | { |
| 907 | case 0: |
| 908 | { |
| 909 | char x = bfd_get_8 (abfd, (char *) data + octets); |
| 910 | DOIT (x); |
| 911 | bfd_put_8 (abfd, x, (unsigned char *) data + octets); |
| 912 | } |
| 913 | break; |
| 914 | |
| 915 | case 1: |
| 916 | { |
| 917 | short x = bfd_get_16 (abfd, (bfd_byte *) data + octets); |
| 918 | DOIT (x); |
| 919 | bfd_put_16 (abfd, x, (unsigned char *) data + octets); |
| 920 | } |
| 921 | break; |
| 922 | case 2: |
| 923 | { |
| 924 | long x = bfd_get_32 (abfd, (bfd_byte *) data + octets); |
| 925 | DOIT (x); |
| 926 | bfd_put_32 (abfd, x, (bfd_byte *) data + octets); |
| 927 | } |
| 928 | break; |
| 929 | case -2: |
| 930 | { |
| 931 | long x = bfd_get_32 (abfd, (bfd_byte *) data + octets); |
| 932 | relocation = -relocation; |
| 933 | DOIT (x); |
| 934 | bfd_put_32 (abfd, x, (bfd_byte *) data + octets); |
| 935 | } |
| 936 | break; |
| 937 | |
| 938 | case -1: |
| 939 | { |
| 940 | long x = bfd_get_16 (abfd, (bfd_byte *) data + octets); |
| 941 | relocation = -relocation; |
| 942 | DOIT (x); |
| 943 | bfd_put_16 (abfd, x, (bfd_byte *) data + octets); |
| 944 | } |
| 945 | break; |
| 946 | |
| 947 | case 3: |
| 948 | /* Do nothing */ |
| 949 | break; |
| 950 | |
| 951 | case 4: |
| 952 | #ifdef BFD64 |
| 953 | { |
| 954 | bfd_vma x = bfd_get_64 (abfd, (bfd_byte *) data + octets); |
| 955 | DOIT (x); |
| 956 | bfd_put_64 (abfd, x, (bfd_byte *) data + octets); |
| 957 | } |
| 958 | #else |
| 959 | abort (); |
| 960 | #endif |
| 961 | break; |
| 962 | default: |
| 963 | return bfd_reloc_other; |
| 964 | } |
| 965 | |
| 966 | return flag; |
| 967 | } |
| 968 | |
| 969 | /* |
| 970 | FUNCTION |
| 971 | bfd_install_relocation |
| 972 | |
| 973 | SYNOPSIS |
| 974 | bfd_reloc_status_type |
| 975 | bfd_install_relocation |
| 976 | (bfd *abfd, |
| 977 | arelent *reloc_entry, |
| 978 | PTR data, bfd_vma data_start, |
| 979 | asection *input_section, |
| 980 | char **error_message); |
| 981 | |
| 982 | DESCRIPTION |
| 983 | This looks remarkably like <<bfd_perform_relocation>>, except it |
| 984 | does not expect that the section contents have been filled in. |
| 985 | I.e., it's suitable for use when creating, rather than applying |
| 986 | a relocation. |
| 987 | |
| 988 | For now, this function should be considered reserved for the |
| 989 | assembler. |
| 990 | |
| 991 | */ |
| 992 | |
| 993 | |
| 994 | bfd_reloc_status_type |
| 995 | bfd_install_relocation (abfd, reloc_entry, data_start, data_start_offset, |
| 996 | input_section, error_message) |
| 997 | bfd *abfd; |
| 998 | arelent *reloc_entry; |
| 999 | PTR data_start; |
| 1000 | bfd_vma data_start_offset; |
| 1001 | asection *input_section; |
| 1002 | char **error_message; |
| 1003 | { |
| 1004 | bfd_vma relocation; |
| 1005 | bfd_reloc_status_type flag = bfd_reloc_ok; |
| 1006 | bfd_size_type octets = reloc_entry->address * bfd_octets_per_byte (abfd); |
| 1007 | bfd_vma output_base = 0; |
| 1008 | reloc_howto_type *howto = reloc_entry->howto; |
| 1009 | asection *reloc_target_output_section; |
| 1010 | asymbol *symbol; |
| 1011 | bfd_byte *data; |
| 1012 | |
| 1013 | symbol = *(reloc_entry->sym_ptr_ptr); |
| 1014 | if (bfd_is_abs_section (symbol->section)) |
| 1015 | { |
| 1016 | reloc_entry->address += input_section->output_offset; |
| 1017 | return bfd_reloc_ok; |
| 1018 | } |
| 1019 | |
| 1020 | /* If there is a function supplied to handle this relocation type, |
| 1021 | call it. It'll return `bfd_reloc_continue' if further processing |
| 1022 | can be done. */ |
| 1023 | if (howto->special_function) |
| 1024 | { |
| 1025 | bfd_reloc_status_type cont; |
| 1026 | |
| 1027 | /* XXX - The special_function calls haven't been fixed up to deal |
| 1028 | with creating new relocations and section contents. */ |
| 1029 | cont = howto->special_function (abfd, reloc_entry, symbol, |
| 1030 | /* XXX - Non-portable! */ |
| 1031 | ((bfd_byte *) data_start |
| 1032 | - data_start_offset), |
| 1033 | input_section, abfd, error_message); |
| 1034 | if (cont != bfd_reloc_continue) |
| 1035 | return cont; |
| 1036 | } |
| 1037 | |
| 1038 | /* Is the address of the relocation really within the section? */ |
| 1039 | if (reloc_entry->address > input_section->_cooked_size) |
| 1040 | return bfd_reloc_outofrange; |
| 1041 | |
| 1042 | /* Work out which section the relocation is targetted at and the |
| 1043 | initial relocation command value. */ |
| 1044 | |
| 1045 | /* Get symbol value. (Common symbols are special.) */ |
| 1046 | if (bfd_is_com_section (symbol->section)) |
| 1047 | relocation = 0; |
| 1048 | else |
| 1049 | relocation = symbol->value; |
| 1050 | |
| 1051 | reloc_target_output_section = symbol->section->output_section; |
| 1052 | |
| 1053 | /* Convert input-section-relative symbol value to absolute. */ |
| 1054 | if (howto->partial_inplace == false) |
| 1055 | output_base = 0; |
| 1056 | else |
| 1057 | output_base = reloc_target_output_section->vma; |
| 1058 | |
| 1059 | relocation += output_base + symbol->section->output_offset; |
| 1060 | |
| 1061 | /* Add in supplied addend. */ |
| 1062 | relocation += reloc_entry->addend; |
| 1063 | |
| 1064 | /* Here the variable relocation holds the final address of the |
| 1065 | symbol we are relocating against, plus any addend. */ |
| 1066 | |
| 1067 | if (howto->pc_relative == true) |
| 1068 | { |
| 1069 | /* This is a PC relative relocation. We want to set RELOCATION |
| 1070 | to the distance between the address of the symbol and the |
| 1071 | location. RELOCATION is already the address of the symbol. |
| 1072 | |
| 1073 | We start by subtracting the address of the section containing |
| 1074 | the location. |
| 1075 | |
| 1076 | If pcrel_offset is set, we must further subtract the position |
| 1077 | of the location within the section. Some targets arrange for |
| 1078 | the addend to be the negative of the position of the location |
| 1079 | within the section; for example, i386-aout does this. For |
| 1080 | i386-aout, pcrel_offset is false. Some other targets do not |
| 1081 | include the position of the location; for example, m88kbcs, |
| 1082 | or ELF. For those targets, pcrel_offset is true. |
| 1083 | |
| 1084 | If we are producing relocateable output, then we must ensure |
| 1085 | that this reloc will be correctly computed when the final |
| 1086 | relocation is done. If pcrel_offset is false we want to wind |
| 1087 | up with the negative of the location within the section, |
| 1088 | which means we must adjust the existing addend by the change |
| 1089 | in the location within the section. If pcrel_offset is true |
| 1090 | we do not want to adjust the existing addend at all. |
| 1091 | |
| 1092 | FIXME: This seems logical to me, but for the case of |
| 1093 | producing relocateable output it is not what the code |
| 1094 | actually does. I don't want to change it, because it seems |
| 1095 | far too likely that something will break. */ |
| 1096 | |
| 1097 | relocation -= |
| 1098 | input_section->output_section->vma + input_section->output_offset; |
| 1099 | |
| 1100 | if (howto->pcrel_offset == true && howto->partial_inplace == true) |
| 1101 | relocation -= reloc_entry->address; |
| 1102 | } |
| 1103 | |
| 1104 | if (howto->partial_inplace == false) |
| 1105 | { |
| 1106 | /* This is a partial relocation, and we want to apply the relocation |
| 1107 | to the reloc entry rather than the raw data. Modify the reloc |
| 1108 | inplace to reflect what we now know. */ |
| 1109 | reloc_entry->addend = relocation; |
| 1110 | reloc_entry->address += input_section->output_offset; |
| 1111 | return flag; |
| 1112 | } |
| 1113 | else |
| 1114 | { |
| 1115 | /* This is a partial relocation, but inplace, so modify the |
| 1116 | reloc record a bit. |
| 1117 | |
| 1118 | If we've relocated with a symbol with a section, change |
| 1119 | into a ref to the section belonging to the symbol. */ |
| 1120 | |
| 1121 | reloc_entry->address += input_section->output_offset; |
| 1122 | |
| 1123 | /* WTF?? */ |
| 1124 | if (abfd->xvec->flavour == bfd_target_coff_flavour |
| 1125 | && strcmp (abfd->xvec->name, "coff-Intel-little") != 0 |
| 1126 | && strcmp (abfd->xvec->name, "coff-Intel-big") != 0) |
| 1127 | { |
| 1128 | #if 1 |
| 1129 | /* For m68k-coff, the addend was being subtracted twice during |
| 1130 | relocation with -r. Removing the line below this comment |
| 1131 | fixes that problem; see PR 2953. |
| 1132 | |
| 1133 | However, Ian wrote the following, regarding removing the line below, |
| 1134 | which explains why it is still enabled: --djm |
| 1135 | |
| 1136 | If you put a patch like that into BFD you need to check all the COFF |
| 1137 | linkers. I am fairly certain that patch will break coff-i386 (e.g., |
| 1138 | SCO); see coff_i386_reloc in coff-i386.c where I worked around the |
| 1139 | problem in a different way. There may very well be a reason that the |
| 1140 | code works as it does. |
| 1141 | |
| 1142 | Hmmm. The first obvious point is that bfd_install_relocation should |
| 1143 | not have any tests that depend upon the flavour. It's seem like |
| 1144 | entirely the wrong place for such a thing. The second obvious point |
| 1145 | is that the current code ignores the reloc addend when producing |
| 1146 | relocateable output for COFF. That's peculiar. In fact, I really |
| 1147 | have no idea what the point of the line you want to remove is. |
| 1148 | |
| 1149 | A typical COFF reloc subtracts the old value of the symbol and adds in |
| 1150 | the new value to the location in the object file (if it's a pc |
| 1151 | relative reloc it adds the difference between the symbol value and the |
| 1152 | location). When relocating we need to preserve that property. |
| 1153 | |
| 1154 | BFD handles this by setting the addend to the negative of the old |
| 1155 | value of the symbol. Unfortunately it handles common symbols in a |
| 1156 | non-standard way (it doesn't subtract the old value) but that's a |
| 1157 | different story (we can't change it without losing backward |
| 1158 | compatibility with old object files) (coff-i386 does subtract the old |
| 1159 | value, to be compatible with existing coff-i386 targets, like SCO). |
| 1160 | |
| 1161 | So everything works fine when not producing relocateable output. When |
| 1162 | we are producing relocateable output, logically we should do exactly |
| 1163 | what we do when not producing relocateable output. Therefore, your |
| 1164 | patch is correct. In fact, it should probably always just set |
| 1165 | reloc_entry->addend to 0 for all cases, since it is, in fact, going to |
| 1166 | add the value into the object file. This won't hurt the COFF code, |
| 1167 | which doesn't use the addend; I'm not sure what it will do to other |
| 1168 | formats (the thing to check for would be whether any formats both use |
| 1169 | the addend and set partial_inplace). |
| 1170 | |
| 1171 | When I wanted to make coff-i386 produce relocateable output, I ran |
| 1172 | into the problem that you are running into: I wanted to remove that |
| 1173 | line. Rather than risk it, I made the coff-i386 relocs use a special |
| 1174 | function; it's coff_i386_reloc in coff-i386.c. The function |
| 1175 | specifically adds the addend field into the object file, knowing that |
| 1176 | bfd_install_relocation is not going to. If you remove that line, then |
| 1177 | coff-i386.c will wind up adding the addend field in twice. It's |
| 1178 | trivial to fix; it just needs to be done. |
| 1179 | |
| 1180 | The problem with removing the line is just that it may break some |
| 1181 | working code. With BFD it's hard to be sure of anything. The right |
| 1182 | way to deal with this is simply to build and test at least all the |
| 1183 | supported COFF targets. It should be straightforward if time and disk |
| 1184 | space consuming. For each target: |
| 1185 | 1) build the linker |
| 1186 | 2) generate some executable, and link it using -r (I would |
| 1187 | probably use paranoia.o and link against newlib/libc.a, which |
| 1188 | for all the supported targets would be available in |
| 1189 | /usr/cygnus/progressive/H-host/target/lib/libc.a). |
| 1190 | 3) make the change to reloc.c |
| 1191 | 4) rebuild the linker |
| 1192 | 5) repeat step 2 |
| 1193 | 6) if the resulting object files are the same, you have at least |
| 1194 | made it no worse |
| 1195 | 7) if they are different you have to figure out which version is |
| 1196 | right |
| 1197 | */ |
| 1198 | relocation -= reloc_entry->addend; |
| 1199 | #endif |
| 1200 | reloc_entry->addend = 0; |
| 1201 | } |
| 1202 | else |
| 1203 | { |
| 1204 | reloc_entry->addend = relocation; |
| 1205 | } |
| 1206 | } |
| 1207 | |
| 1208 | /* FIXME: This overflow checking is incomplete, because the value |
| 1209 | might have overflowed before we get here. For a correct check we |
| 1210 | need to compute the value in a size larger than bitsize, but we |
| 1211 | can't reasonably do that for a reloc the same size as a host |
| 1212 | machine word. |
| 1213 | FIXME: We should also do overflow checking on the result after |
| 1214 | adding in the value contained in the object file. */ |
| 1215 | if (howto->complain_on_overflow != complain_overflow_dont) |
| 1216 | flag = bfd_check_overflow (howto->complain_on_overflow, |
| 1217 | howto->bitsize, |
| 1218 | howto->rightshift, |
| 1219 | bfd_arch_bits_per_address (abfd), |
| 1220 | relocation); |
| 1221 | |
| 1222 | /* |
| 1223 | Either we are relocating all the way, or we don't want to apply |
| 1224 | the relocation to the reloc entry (probably because there isn't |
| 1225 | any room in the output format to describe addends to relocs) |
| 1226 | */ |
| 1227 | |
| 1228 | /* The cast to bfd_vma avoids a bug in the Alpha OSF/1 C compiler |
| 1229 | (OSF version 1.3, compiler version 3.11). It miscompiles the |
| 1230 | following program: |
| 1231 | |
| 1232 | struct str |
| 1233 | { |
| 1234 | unsigned int i0; |
| 1235 | } s = { 0 }; |
| 1236 | |
| 1237 | int |
| 1238 | main () |
| 1239 | { |
| 1240 | unsigned long x; |
| 1241 | |
| 1242 | x = 0x100000000; |
| 1243 | x <<= (unsigned long) s.i0; |
| 1244 | if (x == 0) |
| 1245 | printf ("failed\n"); |
| 1246 | else |
| 1247 | printf ("succeeded (%lx)\n", x); |
| 1248 | } |
| 1249 | */ |
| 1250 | |
| 1251 | relocation >>= (bfd_vma) howto->rightshift; |
| 1252 | |
| 1253 | /* Shift everything up to where it's going to be used */ |
| 1254 | |
| 1255 | relocation <<= (bfd_vma) howto->bitpos; |
| 1256 | |
| 1257 | /* Wait for the day when all have the mask in them */ |
| 1258 | |
| 1259 | /* What we do: |
| 1260 | i instruction to be left alone |
| 1261 | o offset within instruction |
| 1262 | r relocation offset to apply |
| 1263 | S src mask |
| 1264 | D dst mask |
| 1265 | N ~dst mask |
| 1266 | A part 1 |
| 1267 | B part 2 |
| 1268 | R result |
| 1269 | |
| 1270 | Do this: |
| 1271 | (( i i i i i o o o o o from bfd_get<size> |
| 1272 | and S S S S S) to get the size offset we want |
| 1273 | + r r r r r r r r r r) to get the final value to place |
| 1274 | and D D D D D to chop to right size |
| 1275 | ----------------------- |
| 1276 | = A A A A A |
| 1277 | And this: |
| 1278 | ( i i i i i o o o o o from bfd_get<size> |
| 1279 | and N N N N N ) get instruction |
| 1280 | ----------------------- |
| 1281 | = B B B B B |
| 1282 | |
| 1283 | And then: |
| 1284 | ( B B B B B |
| 1285 | or A A A A A) |
| 1286 | ----------------------- |
| 1287 | = R R R R R R R R R R put into bfd_put<size> |
| 1288 | */ |
| 1289 | |
| 1290 | #define DOIT(x) \ |
| 1291 | x = ( (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask)) |
| 1292 | |
| 1293 | data = (bfd_byte *) data_start + (octets - data_start_offset); |
| 1294 | |
| 1295 | switch (howto->size) |
| 1296 | { |
| 1297 | case 0: |
| 1298 | { |
| 1299 | char x = bfd_get_8 (abfd, (char *) data); |
| 1300 | DOIT (x); |
| 1301 | bfd_put_8 (abfd, x, (unsigned char *) data); |
| 1302 | } |
| 1303 | break; |
| 1304 | |
| 1305 | case 1: |
| 1306 | { |
| 1307 | short x = bfd_get_16 (abfd, (bfd_byte *) data); |
| 1308 | DOIT (x); |
| 1309 | bfd_put_16 (abfd, x, (unsigned char *) data); |
| 1310 | } |
| 1311 | break; |
| 1312 | case 2: |
| 1313 | { |
| 1314 | long x = bfd_get_32 (abfd, (bfd_byte *) data); |
| 1315 | DOIT (x); |
| 1316 | bfd_put_32 (abfd, x, (bfd_byte *) data); |
| 1317 | } |
| 1318 | break; |
| 1319 | case -2: |
| 1320 | { |
| 1321 | long x = bfd_get_32 (abfd, (bfd_byte *) data); |
| 1322 | relocation = -relocation; |
| 1323 | DOIT (x); |
| 1324 | bfd_put_32 (abfd, x, (bfd_byte *) data); |
| 1325 | } |
| 1326 | break; |
| 1327 | |
| 1328 | case 3: |
| 1329 | /* Do nothing */ |
| 1330 | break; |
| 1331 | |
| 1332 | case 4: |
| 1333 | { |
| 1334 | bfd_vma x = bfd_get_64 (abfd, (bfd_byte *) data); |
| 1335 | DOIT (x); |
| 1336 | bfd_put_64 (abfd, x, (bfd_byte *) data); |
| 1337 | } |
| 1338 | break; |
| 1339 | default: |
| 1340 | return bfd_reloc_other; |
| 1341 | } |
| 1342 | |
| 1343 | return flag; |
| 1344 | } |
| 1345 | |
| 1346 | /* This relocation routine is used by some of the backend linkers. |
| 1347 | They do not construct asymbol or arelent structures, so there is no |
| 1348 | reason for them to use bfd_perform_relocation. Also, |
| 1349 | bfd_perform_relocation is so hacked up it is easier to write a new |
| 1350 | function than to try to deal with it. |
| 1351 | |
| 1352 | This routine does a final relocation. Whether it is useful for a |
| 1353 | relocateable link depends upon how the object format defines |
| 1354 | relocations. |
| 1355 | |
| 1356 | FIXME: This routine ignores any special_function in the HOWTO, |
| 1357 | since the existing special_function values have been written for |
| 1358 | bfd_perform_relocation. |
| 1359 | |
| 1360 | HOWTO is the reloc howto information. |
| 1361 | INPUT_BFD is the BFD which the reloc applies to. |
| 1362 | INPUT_SECTION is the section which the reloc applies to. |
| 1363 | CONTENTS is the contents of the section. |
| 1364 | ADDRESS is the address of the reloc within INPUT_SECTION. |
| 1365 | VALUE is the value of the symbol the reloc refers to. |
| 1366 | ADDEND is the addend of the reloc. */ |
| 1367 | |
| 1368 | bfd_reloc_status_type |
| 1369 | _bfd_final_link_relocate (howto, input_bfd, input_section, contents, address, |
| 1370 | value, addend) |
| 1371 | reloc_howto_type *howto; |
| 1372 | bfd *input_bfd; |
| 1373 | asection *input_section; |
| 1374 | bfd_byte *contents; |
| 1375 | bfd_vma address; |
| 1376 | bfd_vma value; |
| 1377 | bfd_vma addend; |
| 1378 | { |
| 1379 | bfd_vma relocation; |
| 1380 | |
| 1381 | /* Sanity check the address. */ |
| 1382 | if (address > input_section->_raw_size) |
| 1383 | return bfd_reloc_outofrange; |
| 1384 | |
| 1385 | /* This function assumes that we are dealing with a basic relocation |
| 1386 | against a symbol. We want to compute the value of the symbol to |
| 1387 | relocate to. This is just VALUE, the value of the symbol, plus |
| 1388 | ADDEND, any addend associated with the reloc. */ |
| 1389 | relocation = value + addend; |
| 1390 | |
| 1391 | /* If the relocation is PC relative, we want to set RELOCATION to |
| 1392 | the distance between the symbol (currently in RELOCATION) and the |
| 1393 | location we are relocating. Some targets (e.g., i386-aout) |
| 1394 | arrange for the contents of the section to be the negative of the |
| 1395 | offset of the location within the section; for such targets |
| 1396 | pcrel_offset is false. Other targets (e.g., m88kbcs or ELF) |
| 1397 | simply leave the contents of the section as zero; for such |
| 1398 | targets pcrel_offset is true. If pcrel_offset is false we do not |
| 1399 | need to subtract out the offset of the location within the |
| 1400 | section (which is just ADDRESS). */ |
| 1401 | if (howto->pc_relative) |
| 1402 | { |
| 1403 | relocation -= (input_section->output_section->vma |
| 1404 | + input_section->output_offset); |
| 1405 | if (howto->pcrel_offset) |
| 1406 | relocation -= address; |
| 1407 | } |
| 1408 | |
| 1409 | return _bfd_relocate_contents (howto, input_bfd, relocation, |
| 1410 | contents + address); |
| 1411 | } |
| 1412 | |
| 1413 | /* Relocate a given location using a given value and howto. */ |
| 1414 | |
| 1415 | bfd_reloc_status_type |
| 1416 | _bfd_relocate_contents (howto, input_bfd, relocation, location) |
| 1417 | reloc_howto_type *howto; |
| 1418 | bfd *input_bfd; |
| 1419 | bfd_vma relocation; |
| 1420 | bfd_byte *location; |
| 1421 | { |
| 1422 | int size; |
| 1423 | bfd_vma x = 0; |
| 1424 | bfd_reloc_status_type flag; |
| 1425 | unsigned int rightshift = howto->rightshift; |
| 1426 | unsigned int bitpos = howto->bitpos; |
| 1427 | |
| 1428 | /* If the size is negative, negate RELOCATION. This isn't very |
| 1429 | general. */ |
| 1430 | if (howto->size < 0) |
| 1431 | relocation = -relocation; |
| 1432 | |
| 1433 | /* Get the value we are going to relocate. */ |
| 1434 | size = bfd_get_reloc_size (howto); |
| 1435 | switch (size) |
| 1436 | { |
| 1437 | default: |
| 1438 | case 0: |
| 1439 | abort (); |
| 1440 | case 1: |
| 1441 | x = bfd_get_8 (input_bfd, location); |
| 1442 | break; |
| 1443 | case 2: |
| 1444 | x = bfd_get_16 (input_bfd, location); |
| 1445 | break; |
| 1446 | case 4: |
| 1447 | x = bfd_get_32 (input_bfd, location); |
| 1448 | break; |
| 1449 | case 8: |
| 1450 | #ifdef BFD64 |
| 1451 | x = bfd_get_64 (input_bfd, location); |
| 1452 | #else |
| 1453 | abort (); |
| 1454 | #endif |
| 1455 | break; |
| 1456 | } |
| 1457 | |
| 1458 | /* Check for overflow. FIXME: We may drop bits during the addition |
| 1459 | which we don't check for. We must either check at every single |
| 1460 | operation, which would be tedious, or we must do the computations |
| 1461 | in a type larger than bfd_vma, which would be inefficient. */ |
| 1462 | flag = bfd_reloc_ok; |
| 1463 | if (howto->complain_on_overflow != complain_overflow_dont) |
| 1464 | { |
| 1465 | bfd_vma addrmask, fieldmask, signmask, ss; |
| 1466 | bfd_vma a, b, sum; |
| 1467 | |
| 1468 | /* Get the values to be added together. For signed and unsigned |
| 1469 | relocations, we assume that all values should be truncated to |
| 1470 | the size of an address. For bitfields, all the bits matter. |
| 1471 | See also bfd_check_overflow. */ |
| 1472 | fieldmask = N_ONES (howto->bitsize); |
| 1473 | addrmask = N_ONES (bfd_arch_bits_per_address (input_bfd)) | fieldmask; |
| 1474 | a = relocation; |
| 1475 | b = x & howto->src_mask; |
| 1476 | |
| 1477 | switch (howto->complain_on_overflow) |
| 1478 | { |
| 1479 | case complain_overflow_signed: |
| 1480 | a = (a & addrmask) >> rightshift; |
| 1481 | |
| 1482 | /* If any sign bits are set, all sign bits must be set. |
| 1483 | That is, A must be a valid negative address after |
| 1484 | shifting. */ |
| 1485 | signmask = ~ (fieldmask >> 1); |
| 1486 | ss = a & signmask; |
| 1487 | if (ss != 0 && ss != ((addrmask >> rightshift) & signmask)) |
| 1488 | flag = bfd_reloc_overflow; |
| 1489 | |
| 1490 | /* We only need this next bit of code if the sign bit of B |
| 1491 | is below the sign bit of A. This would only happen if |
| 1492 | SRC_MASK had fewer bits than BITSIZE. Note that if |
| 1493 | SRC_MASK has more bits than BITSIZE, we can get into |
| 1494 | trouble; we would need to verify that B is in range, as |
| 1495 | we do for A above. */ |
| 1496 | signmask = ((~ howto->src_mask) >> 1) & howto->src_mask; |
| 1497 | |
| 1498 | /* Set all the bits above the sign bit. */ |
| 1499 | b = (b ^ signmask) - signmask; |
| 1500 | |
| 1501 | b = (b & addrmask) >> bitpos; |
| 1502 | |
| 1503 | /* Now we can do the addition. */ |
| 1504 | sum = a + b; |
| 1505 | |
| 1506 | /* See if the result has the correct sign. Bits above the |
| 1507 | sign bit are junk now; ignore them. If the sum is |
| 1508 | positive, make sure we did not have all negative inputs; |
| 1509 | if the sum is negative, make sure we did not have all |
| 1510 | positive inputs. The test below looks only at the sign |
| 1511 | bits, and it really just |
| 1512 | SIGN (A) == SIGN (B) && SIGN (A) != SIGN (SUM) |
| 1513 | */ |
| 1514 | signmask = (fieldmask >> 1) + 1; |
| 1515 | if (((~ (a ^ b)) & (a ^ sum)) & signmask) |
| 1516 | flag = bfd_reloc_overflow; |
| 1517 | |
| 1518 | break; |
| 1519 | |
| 1520 | case complain_overflow_unsigned: |
| 1521 | /* Checking for an unsigned overflow is relatively easy: |
| 1522 | trim the addresses and add, and trim the result as well. |
| 1523 | Overflow is normally indicated when the result does not |
| 1524 | fit in the field. However, we also need to consider the |
| 1525 | case when, e.g., fieldmask is 0x7fffffff or smaller, an |
| 1526 | input is 0x80000000, and bfd_vma is only 32 bits; then we |
| 1527 | will get sum == 0, but there is an overflow, since the |
| 1528 | inputs did not fit in the field. Instead of doing a |
| 1529 | separate test, we can check for this by or-ing in the |
| 1530 | operands when testing for the sum overflowing its final |
| 1531 | field. */ |
| 1532 | a = (a & addrmask) >> rightshift; |
| 1533 | b = (b & addrmask) >> bitpos; |
| 1534 | sum = (a + b) & addrmask; |
| 1535 | if ((a | b | sum) & ~ fieldmask) |
| 1536 | flag = bfd_reloc_overflow; |
| 1537 | |
| 1538 | break; |
| 1539 | |
| 1540 | case complain_overflow_bitfield: |
| 1541 | /* Much like the signed check, but for a field one bit |
| 1542 | wider, and no trimming inputs with addrmask. We allow a |
| 1543 | bitfield to represent numbers in the range -2**n to |
| 1544 | 2**n-1, where n is the number of bits in the field. |
| 1545 | Note that when bfd_vma is 32 bits, a 32-bit reloc can't |
| 1546 | overflow, which is exactly what we want. */ |
| 1547 | a >>= rightshift; |
| 1548 | |
| 1549 | signmask = ~ fieldmask; |
| 1550 | ss = a & signmask; |
| 1551 | if (ss != 0 && ss != (((bfd_vma) -1 >> rightshift) & signmask)) |
| 1552 | flag = bfd_reloc_overflow; |
| 1553 | |
| 1554 | signmask = ((~ howto->src_mask) >> 1) & howto->src_mask; |
| 1555 | b = (b ^ signmask) - signmask; |
| 1556 | |
| 1557 | b >>= bitpos; |
| 1558 | |
| 1559 | sum = a + b; |
| 1560 | |
| 1561 | /* We mask with addrmask here to explicitly allow an address |
| 1562 | wrap-around. The Linux kernel relies on it, and it is |
| 1563 | the only way to write assembler code which can run when |
| 1564 | loaded at a location 0x80000000 away from the location at |
| 1565 | which it is linked. */ |
| 1566 | signmask = fieldmask + 1; |
| 1567 | if (((~ (a ^ b)) & (a ^ sum)) & signmask & addrmask) |
| 1568 | flag = bfd_reloc_overflow; |
| 1569 | |
| 1570 | break; |
| 1571 | |
| 1572 | default: |
| 1573 | abort (); |
| 1574 | } |
| 1575 | } |
| 1576 | |
| 1577 | /* Put RELOCATION in the right bits. */ |
| 1578 | relocation >>= (bfd_vma) rightshift; |
| 1579 | relocation <<= (bfd_vma) bitpos; |
| 1580 | |
| 1581 | /* Add RELOCATION to the right bits of X. */ |
| 1582 | x = ((x & ~howto->dst_mask) |
| 1583 | | (((x & howto->src_mask) + relocation) & howto->dst_mask)); |
| 1584 | |
| 1585 | /* Put the relocated value back in the object file. */ |
| 1586 | switch (size) |
| 1587 | { |
| 1588 | default: |
| 1589 | case 0: |
| 1590 | abort (); |
| 1591 | case 1: |
| 1592 | bfd_put_8 (input_bfd, x, location); |
| 1593 | break; |
| 1594 | case 2: |
| 1595 | bfd_put_16 (input_bfd, x, location); |
| 1596 | break; |
| 1597 | case 4: |
| 1598 | bfd_put_32 (input_bfd, x, location); |
| 1599 | break; |
| 1600 | case 8: |
| 1601 | #ifdef BFD64 |
| 1602 | bfd_put_64 (input_bfd, x, location); |
| 1603 | #else |
| 1604 | abort (); |
| 1605 | #endif |
| 1606 | break; |
| 1607 | } |
| 1608 | |
| 1609 | return flag; |
| 1610 | } |
| 1611 | |
| 1612 | /* |
| 1613 | DOCDD |
| 1614 | INODE |
| 1615 | howto manager, , typedef arelent, Relocations |
| 1616 | |
| 1617 | SECTION |
| 1618 | The howto manager |
| 1619 | |
| 1620 | When an application wants to create a relocation, but doesn't |
| 1621 | know what the target machine might call it, it can find out by |
| 1622 | using this bit of code. |
| 1623 | |
| 1624 | */ |
| 1625 | |
| 1626 | /* |
| 1627 | TYPEDEF |
| 1628 | bfd_reloc_code_type |
| 1629 | |
| 1630 | DESCRIPTION |
| 1631 | The insides of a reloc code. The idea is that, eventually, there |
| 1632 | will be one enumerator for every type of relocation we ever do. |
| 1633 | Pass one of these values to <<bfd_reloc_type_lookup>>, and it'll |
| 1634 | return a howto pointer. |
| 1635 | |
| 1636 | This does mean that the application must determine the correct |
| 1637 | enumerator value; you can't get a howto pointer from a random set |
| 1638 | of attributes. |
| 1639 | |
| 1640 | SENUM |
| 1641 | bfd_reloc_code_real |
| 1642 | |
| 1643 | ENUM |
| 1644 | BFD_RELOC_64 |
| 1645 | ENUMX |
| 1646 | BFD_RELOC_32 |
| 1647 | ENUMX |
| 1648 | BFD_RELOC_26 |
| 1649 | ENUMX |
| 1650 | BFD_RELOC_24 |
| 1651 | ENUMX |
| 1652 | BFD_RELOC_16 |
| 1653 | ENUMX |
| 1654 | BFD_RELOC_14 |
| 1655 | ENUMX |
| 1656 | BFD_RELOC_8 |
| 1657 | ENUMDOC |
| 1658 | Basic absolute relocations of N bits. |
| 1659 | |
| 1660 | ENUM |
| 1661 | BFD_RELOC_64_PCREL |
| 1662 | ENUMX |
| 1663 | BFD_RELOC_32_PCREL |
| 1664 | ENUMX |
| 1665 | BFD_RELOC_24_PCREL |
| 1666 | ENUMX |
| 1667 | BFD_RELOC_16_PCREL |
| 1668 | ENUMX |
| 1669 | BFD_RELOC_12_PCREL |
| 1670 | ENUMX |
| 1671 | BFD_RELOC_8_PCREL |
| 1672 | ENUMDOC |
| 1673 | PC-relative relocations. Sometimes these are relative to the address |
| 1674 | of the relocation itself; sometimes they are relative to the start of |
| 1675 | the section containing the relocation. It depends on the specific target. |
| 1676 | |
| 1677 | The 24-bit relocation is used in some Intel 960 configurations. |
| 1678 | |
| 1679 | ENUM |
| 1680 | BFD_RELOC_32_GOT_PCREL |
| 1681 | ENUMX |
| 1682 | BFD_RELOC_16_GOT_PCREL |
| 1683 | ENUMX |
| 1684 | BFD_RELOC_8_GOT_PCREL |
| 1685 | ENUMX |
| 1686 | BFD_RELOC_32_GOTOFF |
| 1687 | ENUMX |
| 1688 | BFD_RELOC_16_GOTOFF |
| 1689 | ENUMX |
| 1690 | BFD_RELOC_LO16_GOTOFF |
| 1691 | ENUMX |
| 1692 | BFD_RELOC_HI16_GOTOFF |
| 1693 | ENUMX |
| 1694 | BFD_RELOC_HI16_S_GOTOFF |
| 1695 | ENUMX |
| 1696 | BFD_RELOC_8_GOTOFF |
| 1697 | ENUMX |
| 1698 | BFD_RELOC_32_PLT_PCREL |
| 1699 | ENUMX |
| 1700 | BFD_RELOC_24_PLT_PCREL |
| 1701 | ENUMX |
| 1702 | BFD_RELOC_16_PLT_PCREL |
| 1703 | ENUMX |
| 1704 | BFD_RELOC_8_PLT_PCREL |
| 1705 | ENUMX |
| 1706 | BFD_RELOC_32_PLTOFF |
| 1707 | ENUMX |
| 1708 | BFD_RELOC_16_PLTOFF |
| 1709 | ENUMX |
| 1710 | BFD_RELOC_LO16_PLTOFF |
| 1711 | ENUMX |
| 1712 | BFD_RELOC_HI16_PLTOFF |
| 1713 | ENUMX |
| 1714 | BFD_RELOC_HI16_S_PLTOFF |
| 1715 | ENUMX |
| 1716 | BFD_RELOC_8_PLTOFF |
| 1717 | ENUMDOC |
| 1718 | For ELF. |
| 1719 | |
| 1720 | ENUM |
| 1721 | BFD_RELOC_68K_GLOB_DAT |
| 1722 | ENUMX |
| 1723 | BFD_RELOC_68K_JMP_SLOT |
| 1724 | ENUMX |
| 1725 | BFD_RELOC_68K_RELATIVE |
| 1726 | ENUMDOC |
| 1727 | Relocations used by 68K ELF. |
| 1728 | |
| 1729 | ENUM |
| 1730 | BFD_RELOC_32_BASEREL |
| 1731 | ENUMX |
| 1732 | BFD_RELOC_16_BASEREL |
| 1733 | ENUMX |
| 1734 | BFD_RELOC_LO16_BASEREL |
| 1735 | ENUMX |
| 1736 | BFD_RELOC_HI16_BASEREL |
| 1737 | ENUMX |
| 1738 | BFD_RELOC_HI16_S_BASEREL |
| 1739 | ENUMX |
| 1740 | BFD_RELOC_8_BASEREL |
| 1741 | ENUMX |
| 1742 | BFD_RELOC_RVA |
| 1743 | ENUMDOC |
| 1744 | Linkage-table relative. |
| 1745 | |
| 1746 | ENUM |
| 1747 | BFD_RELOC_8_FFnn |
| 1748 | ENUMDOC |
| 1749 | Absolute 8-bit relocation, but used to form an address like 0xFFnn. |
| 1750 | |
| 1751 | ENUM |
| 1752 | BFD_RELOC_32_PCREL_S2 |
| 1753 | ENUMX |
| 1754 | BFD_RELOC_16_PCREL_S2 |
| 1755 | ENUMX |
| 1756 | BFD_RELOC_23_PCREL_S2 |
| 1757 | ENUMDOC |
| 1758 | These PC-relative relocations are stored as word displacements -- |
| 1759 | i.e., byte displacements shifted right two bits. The 30-bit word |
| 1760 | displacement (<<32_PCREL_S2>> -- 32 bits, shifted 2) is used on the |
| 1761 | SPARC. (SPARC tools generally refer to this as <<WDISP30>>.) The |
| 1762 | signed 16-bit displacement is used on the MIPS, and the 23-bit |
| 1763 | displacement is used on the Alpha. |
| 1764 | |
| 1765 | ENUM |
| 1766 | BFD_RELOC_HI22 |
| 1767 | ENUMX |
| 1768 | BFD_RELOC_LO10 |
| 1769 | ENUMDOC |
| 1770 | High 22 bits and low 10 bits of 32-bit value, placed into lower bits of |
| 1771 | the target word. These are used on the SPARC. |
| 1772 | |
| 1773 | ENUM |
| 1774 | BFD_RELOC_GPREL16 |
| 1775 | ENUMX |
| 1776 | BFD_RELOC_GPREL32 |
| 1777 | ENUMDOC |
| 1778 | For systems that allocate a Global Pointer register, these are |
| 1779 | displacements off that register. These relocation types are |
| 1780 | handled specially, because the value the register will have is |
| 1781 | decided relatively late. |
| 1782 | |
| 1783 | |
| 1784 | ENUM |
| 1785 | BFD_RELOC_I960_CALLJ |
| 1786 | ENUMDOC |
| 1787 | Reloc types used for i960/b.out. |
| 1788 | |
| 1789 | ENUM |
| 1790 | BFD_RELOC_NONE |
| 1791 | ENUMX |
| 1792 | BFD_RELOC_SPARC_WDISP22 |
| 1793 | ENUMX |
| 1794 | BFD_RELOC_SPARC22 |
| 1795 | ENUMX |
| 1796 | BFD_RELOC_SPARC13 |
| 1797 | ENUMX |
| 1798 | BFD_RELOC_SPARC_GOT10 |
| 1799 | ENUMX |
| 1800 | BFD_RELOC_SPARC_GOT13 |
| 1801 | ENUMX |
| 1802 | BFD_RELOC_SPARC_GOT22 |
| 1803 | ENUMX |
| 1804 | BFD_RELOC_SPARC_PC10 |
| 1805 | ENUMX |
| 1806 | BFD_RELOC_SPARC_PC22 |
| 1807 | ENUMX |
| 1808 | BFD_RELOC_SPARC_WPLT30 |
| 1809 | ENUMX |
| 1810 | BFD_RELOC_SPARC_COPY |
| 1811 | ENUMX |
| 1812 | BFD_RELOC_SPARC_GLOB_DAT |
| 1813 | ENUMX |
| 1814 | BFD_RELOC_SPARC_JMP_SLOT |
| 1815 | ENUMX |
| 1816 | BFD_RELOC_SPARC_RELATIVE |
| 1817 | ENUMX |
| 1818 | BFD_RELOC_SPARC_UA32 |
| 1819 | ENUMDOC |
| 1820 | SPARC ELF relocations. There is probably some overlap with other |
| 1821 | relocation types already defined. |
| 1822 | |
| 1823 | ENUM |
| 1824 | BFD_RELOC_SPARC_BASE13 |
| 1825 | ENUMX |
| 1826 | BFD_RELOC_SPARC_BASE22 |
| 1827 | ENUMDOC |
| 1828 | I think these are specific to SPARC a.out (e.g., Sun 4). |
| 1829 | |
| 1830 | ENUMEQ |
| 1831 | BFD_RELOC_SPARC_64 |
| 1832 | BFD_RELOC_64 |
| 1833 | ENUMX |
| 1834 | BFD_RELOC_SPARC_10 |
| 1835 | ENUMX |
| 1836 | BFD_RELOC_SPARC_11 |
| 1837 | ENUMX |
| 1838 | BFD_RELOC_SPARC_OLO10 |
| 1839 | ENUMX |
| 1840 | BFD_RELOC_SPARC_HH22 |
| 1841 | ENUMX |
| 1842 | BFD_RELOC_SPARC_HM10 |
| 1843 | ENUMX |
| 1844 | BFD_RELOC_SPARC_LM22 |
| 1845 | ENUMX |
| 1846 | BFD_RELOC_SPARC_PC_HH22 |
| 1847 | ENUMX |
| 1848 | BFD_RELOC_SPARC_PC_HM10 |
| 1849 | ENUMX |
| 1850 | BFD_RELOC_SPARC_PC_LM22 |
| 1851 | ENUMX |
| 1852 | BFD_RELOC_SPARC_WDISP16 |
| 1853 | ENUMX |
| 1854 | BFD_RELOC_SPARC_WDISP19 |
| 1855 | ENUMX |
| 1856 | BFD_RELOC_SPARC_7 |
| 1857 | ENUMX |
| 1858 | BFD_RELOC_SPARC_6 |
| 1859 | ENUMX |
| 1860 | BFD_RELOC_SPARC_5 |
| 1861 | ENUMEQX |
| 1862 | BFD_RELOC_SPARC_DISP64 |
| 1863 | BFD_RELOC_64_PCREL |
| 1864 | ENUMX |
| 1865 | BFD_RELOC_SPARC_PLT64 |
| 1866 | ENUMX |
| 1867 | BFD_RELOC_SPARC_HIX22 |
| 1868 | ENUMX |
| 1869 | BFD_RELOC_SPARC_LOX10 |
| 1870 | ENUMX |
| 1871 | BFD_RELOC_SPARC_H44 |
| 1872 | ENUMX |
| 1873 | BFD_RELOC_SPARC_M44 |
| 1874 | ENUMX |
| 1875 | BFD_RELOC_SPARC_L44 |
| 1876 | ENUMX |
| 1877 | BFD_RELOC_SPARC_REGISTER |
| 1878 | ENUMDOC |
| 1879 | SPARC64 relocations |
| 1880 | |
| 1881 | ENUM |
| 1882 | BFD_RELOC_SPARC_REV32 |
| 1883 | ENUMDOC |
| 1884 | SPARC little endian relocation |
| 1885 | |
| 1886 | ENUM |
| 1887 | BFD_RELOC_ALPHA_GPDISP_HI16 |
| 1888 | ENUMDOC |
| 1889 | Alpha ECOFF and ELF relocations. Some of these treat the symbol or |
| 1890 | "addend" in some special way. |
| 1891 | For GPDISP_HI16 ("gpdisp") relocations, the symbol is ignored when |
| 1892 | writing; when reading, it will be the absolute section symbol. The |
| 1893 | addend is the displacement in bytes of the "lda" instruction from |
| 1894 | the "ldah" instruction (which is at the address of this reloc). |
| 1895 | ENUM |
| 1896 | BFD_RELOC_ALPHA_GPDISP_LO16 |
| 1897 | ENUMDOC |
| 1898 | For GPDISP_LO16 ("ignore") relocations, the symbol is handled as |
| 1899 | with GPDISP_HI16 relocs. The addend is ignored when writing the |
| 1900 | relocations out, and is filled in with the file's GP value on |
| 1901 | reading, for convenience. |
| 1902 | |
| 1903 | ENUM |
| 1904 | BFD_RELOC_ALPHA_GPDISP |
| 1905 | ENUMDOC |
| 1906 | The ELF GPDISP relocation is exactly the same as the GPDISP_HI16 |
| 1907 | relocation except that there is no accompanying GPDISP_LO16 |
| 1908 | relocation. |
| 1909 | |
| 1910 | ENUM |
| 1911 | BFD_RELOC_ALPHA_LITERAL |
| 1912 | ENUMX |
| 1913 | BFD_RELOC_ALPHA_ELF_LITERAL |
| 1914 | ENUMX |
| 1915 | BFD_RELOC_ALPHA_LITUSE |
| 1916 | ENUMDOC |
| 1917 | The Alpha LITERAL/LITUSE relocs are produced by a symbol reference; |
| 1918 | the assembler turns it into a LDQ instruction to load the address of |
| 1919 | the symbol, and then fills in a register in the real instruction. |
| 1920 | |
| 1921 | The LITERAL reloc, at the LDQ instruction, refers to the .lita |
| 1922 | section symbol. The addend is ignored when writing, but is filled |
| 1923 | in with the file's GP value on reading, for convenience, as with the |
| 1924 | GPDISP_LO16 reloc. |
| 1925 | |
| 1926 | The ELF_LITERAL reloc is somewhere between 16_GOTOFF and GPDISP_LO16. |
| 1927 | It should refer to the symbol to be referenced, as with 16_GOTOFF, |
| 1928 | but it generates output not based on the position within the .got |
| 1929 | section, but relative to the GP value chosen for the file during the |
| 1930 | final link stage. |
| 1931 | |
| 1932 | The LITUSE reloc, on the instruction using the loaded address, gives |
| 1933 | information to the linker that it might be able to use to optimize |
| 1934 | away some literal section references. The symbol is ignored (read |
| 1935 | as the absolute section symbol), and the "addend" indicates the type |
| 1936 | of instruction using the register: |
| 1937 | 1 - "memory" fmt insn |
| 1938 | 2 - byte-manipulation (byte offset reg) |
| 1939 | 3 - jsr (target of branch) |
| 1940 | |
| 1941 | The GNU linker currently doesn't do any of this optimizing. |
| 1942 | |
| 1943 | ENUM |
| 1944 | BFD_RELOC_ALPHA_USER_LITERAL |
| 1945 | ENUMX |
| 1946 | BFD_RELOC_ALPHA_USER_LITUSE_BASE |
| 1947 | ENUMX |
| 1948 | BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF |
| 1949 | ENUMX |
| 1950 | BFD_RELOC_ALPHA_USER_LITUSE_JSR |
| 1951 | ENUMX |
| 1952 | BFD_RELOC_ALPHA_USER_GPDISP |
| 1953 | ENUMX |
| 1954 | BFD_RELOC_ALPHA_USER_GPRELHIGH |
| 1955 | ENUMX |
| 1956 | BFD_RELOC_ALPHA_USER_GPRELLOW |
| 1957 | ENUMDOC |
| 1958 | The BFD_RELOC_ALPHA_USER_* relocations are used by the assembler to |
| 1959 | process the explicit !<reloc>!sequence relocations, and are mapped |
| 1960 | into the normal relocations at the end of processing. |
| 1961 | |
| 1962 | ENUM |
| 1963 | BFD_RELOC_ALPHA_HINT |
| 1964 | ENUMDOC |
| 1965 | The HINT relocation indicates a value that should be filled into the |
| 1966 | "hint" field of a jmp/jsr/ret instruction, for possible branch- |
| 1967 | prediction logic which may be provided on some processors. |
| 1968 | |
| 1969 | ENUM |
| 1970 | BFD_RELOC_ALPHA_LINKAGE |
| 1971 | ENUMDOC |
| 1972 | The LINKAGE relocation outputs a linkage pair in the object file, |
| 1973 | which is filled by the linker. |
| 1974 | |
| 1975 | ENUM |
| 1976 | BFD_RELOC_ALPHA_CODEADDR |
| 1977 | ENUMDOC |
| 1978 | The CODEADDR relocation outputs a STO_CA in the object file, |
| 1979 | which is filled by the linker. |
| 1980 | |
| 1981 | ENUM |
| 1982 | BFD_RELOC_MIPS_JMP |
| 1983 | ENUMDOC |
| 1984 | Bits 27..2 of the relocation address shifted right 2 bits; |
| 1985 | simple reloc otherwise. |
| 1986 | |
| 1987 | ENUM |
| 1988 | BFD_RELOC_MIPS16_JMP |
| 1989 | ENUMDOC |
| 1990 | The MIPS16 jump instruction. |
| 1991 | |
| 1992 | ENUM |
| 1993 | BFD_RELOC_MIPS16_GPREL |
| 1994 | ENUMDOC |
| 1995 | MIPS16 GP relative reloc. |
| 1996 | |
| 1997 | ENUM |
| 1998 | BFD_RELOC_HI16 |
| 1999 | ENUMDOC |
| 2000 | High 16 bits of 32-bit value; simple reloc. |
| 2001 | ENUM |
| 2002 | BFD_RELOC_HI16_S |
| 2003 | ENUMDOC |
| 2004 | High 16 bits of 32-bit value but the low 16 bits will be sign |
| 2005 | extended and added to form the final result. If the low 16 |
| 2006 | bits form a negative number, we need to add one to the high value |
| 2007 | to compensate for the borrow when the low bits are added. |
| 2008 | ENUM |
| 2009 | BFD_RELOC_LO16 |
| 2010 | ENUMDOC |
| 2011 | Low 16 bits. |
| 2012 | ENUM |
| 2013 | BFD_RELOC_PCREL_HI16_S |
| 2014 | ENUMDOC |
| 2015 | Like BFD_RELOC_HI16_S, but PC relative. |
| 2016 | ENUM |
| 2017 | BFD_RELOC_PCREL_LO16 |
| 2018 | ENUMDOC |
| 2019 | Like BFD_RELOC_LO16, but PC relative. |
| 2020 | |
| 2021 | ENUMEQ |
| 2022 | BFD_RELOC_MIPS_GPREL |
| 2023 | BFD_RELOC_GPREL16 |
| 2024 | ENUMDOC |
| 2025 | Relocation relative to the global pointer. |
| 2026 | |
| 2027 | ENUM |
| 2028 | BFD_RELOC_MIPS_LITERAL |
| 2029 | ENUMDOC |
| 2030 | Relocation against a MIPS literal section. |
| 2031 | |
| 2032 | ENUM |
| 2033 | BFD_RELOC_MIPS_GOT16 |
| 2034 | ENUMX |
| 2035 | BFD_RELOC_MIPS_CALL16 |
| 2036 | ENUMEQX |
| 2037 | BFD_RELOC_MIPS_GPREL32 |
| 2038 | BFD_RELOC_GPREL32 |
| 2039 | ENUMX |
| 2040 | BFD_RELOC_MIPS_GOT_HI16 |
| 2041 | ENUMX |
| 2042 | BFD_RELOC_MIPS_GOT_LO16 |
| 2043 | ENUMX |
| 2044 | BFD_RELOC_MIPS_CALL_HI16 |
| 2045 | ENUMX |
| 2046 | BFD_RELOC_MIPS_CALL_LO16 |
| 2047 | ENUMX |
| 2048 | BFD_RELOC_MIPS_SUB |
| 2049 | ENUMX |
| 2050 | BFD_RELOC_MIPS_GOT_PAGE |
| 2051 | ENUMX |
| 2052 | BFD_RELOC_MIPS_GOT_OFST |
| 2053 | ENUMX |
| 2054 | BFD_RELOC_MIPS_GOT_DISP |
| 2055 | COMMENT |
| 2056 | ENUMDOC |
| 2057 | MIPS ELF relocations. |
| 2058 | |
| 2059 | COMMENT |
| 2060 | |
| 2061 | ENUM |
| 2062 | BFD_RELOC_386_GOT32 |
| 2063 | ENUMX |
| 2064 | BFD_RELOC_386_PLT32 |
| 2065 | ENUMX |
| 2066 | BFD_RELOC_386_COPY |
| 2067 | ENUMX |
| 2068 | BFD_RELOC_386_GLOB_DAT |
| 2069 | ENUMX |
| 2070 | BFD_RELOC_386_JUMP_SLOT |
| 2071 | ENUMX |
| 2072 | BFD_RELOC_386_RELATIVE |
| 2073 | ENUMX |
| 2074 | BFD_RELOC_386_GOTOFF |
| 2075 | ENUMX |
| 2076 | BFD_RELOC_386_GOTPC |
| 2077 | ENUMDOC |
| 2078 | i386/elf relocations |
| 2079 | |
| 2080 | ENUM |
| 2081 | BFD_RELOC_NS32K_IMM_8 |
| 2082 | ENUMX |
| 2083 | BFD_RELOC_NS32K_IMM_16 |
| 2084 | ENUMX |
| 2085 | BFD_RELOC_NS32K_IMM_32 |
| 2086 | ENUMX |
| 2087 | BFD_RELOC_NS32K_IMM_8_PCREL |
| 2088 | ENUMX |
| 2089 | BFD_RELOC_NS32K_IMM_16_PCREL |
| 2090 | ENUMX |
| 2091 | BFD_RELOC_NS32K_IMM_32_PCREL |
| 2092 | ENUMX |
| 2093 | BFD_RELOC_NS32K_DISP_8 |
| 2094 | ENUMX |
| 2095 | BFD_RELOC_NS32K_DISP_16 |
| 2096 | ENUMX |
| 2097 | BFD_RELOC_NS32K_DISP_32 |
| 2098 | ENUMX |
| 2099 | BFD_RELOC_NS32K_DISP_8_PCREL |
| 2100 | ENUMX |
| 2101 | BFD_RELOC_NS32K_DISP_16_PCREL |
| 2102 | ENUMX |
| 2103 | BFD_RELOC_NS32K_DISP_32_PCREL |
| 2104 | ENUMDOC |
| 2105 | ns32k relocations |
| 2106 | |
| 2107 | ENUM |
| 2108 | BFD_RELOC_PJ_CODE_HI16 |
| 2109 | ENUMX |
| 2110 | BFD_RELOC_PJ_CODE_LO16 |
| 2111 | ENUMX |
| 2112 | BFD_RELOC_PJ_CODE_DIR16 |
| 2113 | ENUMX |
| 2114 | BFD_RELOC_PJ_CODE_DIR32 |
| 2115 | ENUMX |
| 2116 | BFD_RELOC_PJ_CODE_REL16 |
| 2117 | ENUMX |
| 2118 | BFD_RELOC_PJ_CODE_REL32 |
| 2119 | ENUMDOC |
| 2120 | Picojava relocs. Not all of these appear in object files. |
| 2121 | |
| 2122 | ENUM |
| 2123 | BFD_RELOC_PPC_B26 |
| 2124 | ENUMX |
| 2125 | BFD_RELOC_PPC_BA26 |
| 2126 | ENUMX |
| 2127 | BFD_RELOC_PPC_TOC16 |
| 2128 | ENUMX |
| 2129 | BFD_RELOC_PPC_B16 |
| 2130 | ENUMX |
| 2131 | BFD_RELOC_PPC_B16_BRTAKEN |
| 2132 | ENUMX |
| 2133 | BFD_RELOC_PPC_B16_BRNTAKEN |
| 2134 | ENUMX |
| 2135 | BFD_RELOC_PPC_BA16 |
| 2136 | ENUMX |
| 2137 | BFD_RELOC_PPC_BA16_BRTAKEN |
| 2138 | ENUMX |
| 2139 | BFD_RELOC_PPC_BA16_BRNTAKEN |
| 2140 | ENUMX |
| 2141 | BFD_RELOC_PPC_COPY |
| 2142 | ENUMX |
| 2143 | BFD_RELOC_PPC_GLOB_DAT |
| 2144 | ENUMX |
| 2145 | BFD_RELOC_PPC_JMP_SLOT |
| 2146 | ENUMX |
| 2147 | BFD_RELOC_PPC_RELATIVE |
| 2148 | ENUMX |
| 2149 | BFD_RELOC_PPC_LOCAL24PC |
| 2150 | ENUMX |
| 2151 | BFD_RELOC_PPC_EMB_NADDR32 |
| 2152 | ENUMX |
| 2153 | BFD_RELOC_PPC_EMB_NADDR16 |
| 2154 | ENUMX |
| 2155 | BFD_RELOC_PPC_EMB_NADDR16_LO |
| 2156 | ENUMX |
| 2157 | BFD_RELOC_PPC_EMB_NADDR16_HI |
| 2158 | ENUMX |
| 2159 | BFD_RELOC_PPC_EMB_NADDR16_HA |
| 2160 | ENUMX |
| 2161 | BFD_RELOC_PPC_EMB_SDAI16 |
| 2162 | ENUMX |
| 2163 | BFD_RELOC_PPC_EMB_SDA2I16 |
| 2164 | ENUMX |
| 2165 | BFD_RELOC_PPC_EMB_SDA2REL |
| 2166 | ENUMX |
| 2167 | BFD_RELOC_PPC_EMB_SDA21 |
| 2168 | ENUMX |
| 2169 | BFD_RELOC_PPC_EMB_MRKREF |
| 2170 | ENUMX |
| 2171 | BFD_RELOC_PPC_EMB_RELSEC16 |
| 2172 | ENUMX |
| 2173 | BFD_RELOC_PPC_EMB_RELST_LO |
| 2174 | ENUMX |
| 2175 | BFD_RELOC_PPC_EMB_RELST_HI |
| 2176 | ENUMX |
| 2177 | BFD_RELOC_PPC_EMB_RELST_HA |
| 2178 | ENUMX |
| 2179 | BFD_RELOC_PPC_EMB_BIT_FLD |
| 2180 | ENUMX |
| 2181 | BFD_RELOC_PPC_EMB_RELSDA |
| 2182 | ENUMDOC |
| 2183 | Power(rs6000) and PowerPC relocations. |
| 2184 | |
| 2185 | ENUM |
| 2186 | BFD_RELOC_I370_D12 |
| 2187 | ENUMDOC |
| 2188 | IBM 370/390 relocations |
| 2189 | |
| 2190 | ENUM |
| 2191 | BFD_RELOC_CTOR |
| 2192 | ENUMDOC |
| 2193 | The type of reloc used to build a contructor table - at the moment |
| 2194 | probably a 32 bit wide absolute relocation, but the target can choose. |
| 2195 | It generally does map to one of the other relocation types. |
| 2196 | |
| 2197 | ENUM |
| 2198 | BFD_RELOC_ARM_PCREL_BRANCH |
| 2199 | ENUMDOC |
| 2200 | ARM 26 bit pc-relative branch. The lowest two bits must be zero and are |
| 2201 | not stored in the instruction. |
| 2202 | ENUM |
| 2203 | BFD_RELOC_ARM_PCREL_BLX |
| 2204 | ENUMDOC |
| 2205 | ARM 26 bit pc-relative branch. The lowest bit must be zero and is |
| 2206 | not stored in the instruction. The 2nd lowest bit comes from a 1 bit |
| 2207 | field in the instruction. |
| 2208 | ENUM |
| 2209 | BFD_RELOC_THUMB_PCREL_BLX |
| 2210 | ENUMDOC |
| 2211 | Thumb 22 bit pc-relative branch. The lowest bit must be zero and is |
| 2212 | not stored in the instruction. The 2nd lowest bit comes from a 1 bit |
| 2213 | field in the instruction. |
| 2214 | ENUM |
| 2215 | BFD_RELOC_ARM_IMMEDIATE |
| 2216 | ENUMX |
| 2217 | BFD_RELOC_ARM_ADRL_IMMEDIATE |
| 2218 | ENUMX |
| 2219 | BFD_RELOC_ARM_OFFSET_IMM |
| 2220 | ENUMX |
| 2221 | BFD_RELOC_ARM_SHIFT_IMM |
| 2222 | ENUMX |
| 2223 | BFD_RELOC_ARM_SWI |
| 2224 | ENUMX |
| 2225 | BFD_RELOC_ARM_MULTI |
| 2226 | ENUMX |
| 2227 | BFD_RELOC_ARM_CP_OFF_IMM |
| 2228 | ENUMX |
| 2229 | BFD_RELOC_ARM_ADR_IMM |
| 2230 | ENUMX |
| 2231 | BFD_RELOC_ARM_LDR_IMM |
| 2232 | ENUMX |
| 2233 | BFD_RELOC_ARM_LITERAL |
| 2234 | ENUMX |
| 2235 | BFD_RELOC_ARM_IN_POOL |
| 2236 | ENUMX |
| 2237 | BFD_RELOC_ARM_OFFSET_IMM8 |
| 2238 | ENUMX |
| 2239 | BFD_RELOC_ARM_HWLITERAL |
| 2240 | ENUMX |
| 2241 | BFD_RELOC_ARM_THUMB_ADD |
| 2242 | ENUMX |
| 2243 | BFD_RELOC_ARM_THUMB_IMM |
| 2244 | ENUMX |
| 2245 | BFD_RELOC_ARM_THUMB_SHIFT |
| 2246 | ENUMX |
| 2247 | BFD_RELOC_ARM_THUMB_OFFSET |
| 2248 | ENUMX |
| 2249 | BFD_RELOC_ARM_GOT12 |
| 2250 | ENUMX |
| 2251 | BFD_RELOC_ARM_GOT32 |
| 2252 | ENUMX |
| 2253 | BFD_RELOC_ARM_JUMP_SLOT |
| 2254 | ENUMX |
| 2255 | BFD_RELOC_ARM_COPY |
| 2256 | ENUMX |
| 2257 | BFD_RELOC_ARM_GLOB_DAT |
| 2258 | ENUMX |
| 2259 | BFD_RELOC_ARM_PLT32 |
| 2260 | ENUMX |
| 2261 | BFD_RELOC_ARM_RELATIVE |
| 2262 | ENUMX |
| 2263 | BFD_RELOC_ARM_GOTOFF |
| 2264 | ENUMX |
| 2265 | BFD_RELOC_ARM_GOTPC |
| 2266 | ENUMDOC |
| 2267 | These relocs are only used within the ARM assembler. They are not |
| 2268 | (at present) written to any object files. |
| 2269 | |
| 2270 | ENUM |
| 2271 | BFD_RELOC_SH_PCDISP8BY2 |
| 2272 | ENUMX |
| 2273 | BFD_RELOC_SH_PCDISP12BY2 |
| 2274 | ENUMX |
| 2275 | BFD_RELOC_SH_IMM4 |
| 2276 | ENUMX |
| 2277 | BFD_RELOC_SH_IMM4BY2 |
| 2278 | ENUMX |
| 2279 | BFD_RELOC_SH_IMM4BY4 |
| 2280 | ENUMX |
| 2281 | BFD_RELOC_SH_IMM8 |
| 2282 | ENUMX |
| 2283 | BFD_RELOC_SH_IMM8BY2 |
| 2284 | ENUMX |
| 2285 | BFD_RELOC_SH_IMM8BY4 |
| 2286 | ENUMX |
| 2287 | BFD_RELOC_SH_PCRELIMM8BY2 |
| 2288 | ENUMX |
| 2289 | BFD_RELOC_SH_PCRELIMM8BY4 |
| 2290 | ENUMX |
| 2291 | BFD_RELOC_SH_SWITCH16 |
| 2292 | ENUMX |
| 2293 | BFD_RELOC_SH_SWITCH32 |
| 2294 | ENUMX |
| 2295 | BFD_RELOC_SH_USES |
| 2296 | ENUMX |
| 2297 | BFD_RELOC_SH_COUNT |
| 2298 | ENUMX |
| 2299 | BFD_RELOC_SH_ALIGN |
| 2300 | ENUMX |
| 2301 | BFD_RELOC_SH_CODE |
| 2302 | ENUMX |
| 2303 | BFD_RELOC_SH_DATA |
| 2304 | ENUMX |
| 2305 | BFD_RELOC_SH_LABEL |
| 2306 | ENUMX |
| 2307 | BFD_RELOC_SH_LOOP_START |
| 2308 | ENUMX |
| 2309 | BFD_RELOC_SH_LOOP_END |
| 2310 | ENUMDOC |
| 2311 | Hitachi SH relocs. Not all of these appear in object files. |
| 2312 | |
| 2313 | ENUM |
| 2314 | BFD_RELOC_THUMB_PCREL_BRANCH9 |
| 2315 | ENUMX |
| 2316 | BFD_RELOC_THUMB_PCREL_BRANCH12 |
| 2317 | ENUMX |
| 2318 | BFD_RELOC_THUMB_PCREL_BRANCH23 |
| 2319 | ENUMDOC |
| 2320 | Thumb 23-, 12- and 9-bit pc-relative branches. The lowest bit must |
| 2321 | be zero and is not stored in the instruction. |
| 2322 | |
| 2323 | ENUM |
| 2324 | BFD_RELOC_ARC_B22_PCREL |
| 2325 | ENUMDOC |
| 2326 | Argonaut RISC Core (ARC) relocs. |
| 2327 | ARC 22 bit pc-relative branch. The lowest two bits must be zero and are |
| 2328 | not stored in the instruction. The high 20 bits are installed in bits 26 |
| 2329 | through 7 of the instruction. |
| 2330 | ENUM |
| 2331 | BFD_RELOC_ARC_B26 |
| 2332 | ENUMDOC |
| 2333 | ARC 26 bit absolute branch. The lowest two bits must be zero and are not |
| 2334 | stored in the instruction. The high 24 bits are installed in bits 23 |
| 2335 | through 0. |
| 2336 | |
| 2337 | ENUM |
| 2338 | BFD_RELOC_D10V_10_PCREL_R |
| 2339 | ENUMDOC |
| 2340 | Mitsubishi D10V relocs. |
| 2341 | This is a 10-bit reloc with the right 2 bits |
| 2342 | assumed to be 0. |
| 2343 | ENUM |
| 2344 | BFD_RELOC_D10V_10_PCREL_L |
| 2345 | ENUMDOC |
| 2346 | Mitsubishi D10V relocs. |
| 2347 | This is a 10-bit reloc with the right 2 bits |
| 2348 | assumed to be 0. This is the same as the previous reloc |
| 2349 | except it is in the left container, i.e., |
| 2350 | shifted left 15 bits. |
| 2351 | ENUM |
| 2352 | BFD_RELOC_D10V_18 |
| 2353 | ENUMDOC |
| 2354 | This is an 18-bit reloc with the right 2 bits |
| 2355 | assumed to be 0. |
| 2356 | ENUM |
| 2357 | BFD_RELOC_D10V_18_PCREL |
| 2358 | ENUMDOC |
| 2359 | This is an 18-bit reloc with the right 2 bits |
| 2360 | assumed to be 0. |
| 2361 | |
| 2362 | ENUM |
| 2363 | BFD_RELOC_D30V_6 |
| 2364 | ENUMDOC |
| 2365 | Mitsubishi D30V relocs. |
| 2366 | This is a 6-bit absolute reloc. |
| 2367 | ENUM |
| 2368 | BFD_RELOC_D30V_9_PCREL |
| 2369 | ENUMDOC |
| 2370 | This is a 6-bit pc-relative reloc with |
| 2371 | the right 3 bits assumed to be 0. |
| 2372 | ENUM |
| 2373 | BFD_RELOC_D30V_9_PCREL_R |
| 2374 | ENUMDOC |
| 2375 | This is a 6-bit pc-relative reloc with |
| 2376 | the right 3 bits assumed to be 0. Same |
| 2377 | as the previous reloc but on the right side |
| 2378 | of the container. |
| 2379 | ENUM |
| 2380 | BFD_RELOC_D30V_15 |
| 2381 | ENUMDOC |
| 2382 | This is a 12-bit absolute reloc with the |
| 2383 | right 3 bitsassumed to be 0. |
| 2384 | ENUM |
| 2385 | BFD_RELOC_D30V_15_PCREL |
| 2386 | ENUMDOC |
| 2387 | This is a 12-bit pc-relative reloc with |
| 2388 | the right 3 bits assumed to be 0. |
| 2389 | ENUM |
| 2390 | BFD_RELOC_D30V_15_PCREL_R |
| 2391 | ENUMDOC |
| 2392 | This is a 12-bit pc-relative reloc with |
| 2393 | the right 3 bits assumed to be 0. Same |
| 2394 | as the previous reloc but on the right side |
| 2395 | of the container. |
| 2396 | ENUM |
| 2397 | BFD_RELOC_D30V_21 |
| 2398 | ENUMDOC |
| 2399 | This is an 18-bit absolute reloc with |
| 2400 | the right 3 bits assumed to be 0. |
| 2401 | ENUM |
| 2402 | BFD_RELOC_D30V_21_PCREL |
| 2403 | ENUMDOC |
| 2404 | This is an 18-bit pc-relative reloc with |
| 2405 | the right 3 bits assumed to be 0. |
| 2406 | ENUM |
| 2407 | BFD_RELOC_D30V_21_PCREL_R |
| 2408 | ENUMDOC |
| 2409 | This is an 18-bit pc-relative reloc with |
| 2410 | the right 3 bits assumed to be 0. Same |
| 2411 | as the previous reloc but on the right side |
| 2412 | of the container. |
| 2413 | ENUM |
| 2414 | BFD_RELOC_D30V_32 |
| 2415 | ENUMDOC |
| 2416 | This is a 32-bit absolute reloc. |
| 2417 | ENUM |
| 2418 | BFD_RELOC_D30V_32_PCREL |
| 2419 | ENUMDOC |
| 2420 | This is a 32-bit pc-relative reloc. |
| 2421 | |
| 2422 | ENUM |
| 2423 | BFD_RELOC_M32R_24 |
| 2424 | ENUMDOC |
| 2425 | Mitsubishi M32R relocs. |
| 2426 | This is a 24 bit absolute address. |
| 2427 | ENUM |
| 2428 | BFD_RELOC_M32R_10_PCREL |
| 2429 | ENUMDOC |
| 2430 | This is a 10-bit pc-relative reloc with the right 2 bits assumed to be 0. |
| 2431 | ENUM |
| 2432 | BFD_RELOC_M32R_18_PCREL |
| 2433 | ENUMDOC |
| 2434 | This is an 18-bit reloc with the right 2 bits assumed to be 0. |
| 2435 | ENUM |
| 2436 | BFD_RELOC_M32R_26_PCREL |
| 2437 | ENUMDOC |
| 2438 | This is a 26-bit reloc with the right 2 bits assumed to be 0. |
| 2439 | ENUM |
| 2440 | BFD_RELOC_M32R_HI16_ULO |
| 2441 | ENUMDOC |
| 2442 | This is a 16-bit reloc containing the high 16 bits of an address |
| 2443 | used when the lower 16 bits are treated as unsigned. |
| 2444 | ENUM |
| 2445 | BFD_RELOC_M32R_HI16_SLO |
| 2446 | ENUMDOC |
| 2447 | This is a 16-bit reloc containing the high 16 bits of an address |
| 2448 | used when the lower 16 bits are treated as signed. |
| 2449 | ENUM |
| 2450 | BFD_RELOC_M32R_LO16 |
| 2451 | ENUMDOC |
| 2452 | This is a 16-bit reloc containing the lower 16 bits of an address. |
| 2453 | ENUM |
| 2454 | BFD_RELOC_M32R_SDA16 |
| 2455 | ENUMDOC |
| 2456 | This is a 16-bit reloc containing the small data area offset for use in |
| 2457 | add3, load, and store instructions. |
| 2458 | |
| 2459 | ENUM |
| 2460 | BFD_RELOC_V850_9_PCREL |
| 2461 | ENUMDOC |
| 2462 | This is a 9-bit reloc |
| 2463 | ENUM |
| 2464 | BFD_RELOC_V850_22_PCREL |
| 2465 | ENUMDOC |
| 2466 | This is a 22-bit reloc |
| 2467 | |
| 2468 | ENUM |
| 2469 | BFD_RELOC_V850_SDA_16_16_OFFSET |
| 2470 | ENUMDOC |
| 2471 | This is a 16 bit offset from the short data area pointer. |
| 2472 | ENUM |
| 2473 | BFD_RELOC_V850_SDA_15_16_OFFSET |
| 2474 | ENUMDOC |
| 2475 | This is a 16 bit offset (of which only 15 bits are used) from the |
| 2476 | short data area pointer. |
| 2477 | ENUM |
| 2478 | BFD_RELOC_V850_ZDA_16_16_OFFSET |
| 2479 | ENUMDOC |
| 2480 | This is a 16 bit offset from the zero data area pointer. |
| 2481 | ENUM |
| 2482 | BFD_RELOC_V850_ZDA_15_16_OFFSET |
| 2483 | ENUMDOC |
| 2484 | This is a 16 bit offset (of which only 15 bits are used) from the |
| 2485 | zero data area pointer. |
| 2486 | ENUM |
| 2487 | BFD_RELOC_V850_TDA_6_8_OFFSET |
| 2488 | ENUMDOC |
| 2489 | This is an 8 bit offset (of which only 6 bits are used) from the |
| 2490 | tiny data area pointer. |
| 2491 | ENUM |
| 2492 | BFD_RELOC_V850_TDA_7_8_OFFSET |
| 2493 | ENUMDOC |
| 2494 | This is an 8bit offset (of which only 7 bits are used) from the tiny |
| 2495 | data area pointer. |
| 2496 | ENUM |
| 2497 | BFD_RELOC_V850_TDA_7_7_OFFSET |
| 2498 | ENUMDOC |
| 2499 | This is a 7 bit offset from the tiny data area pointer. |
| 2500 | ENUM |
| 2501 | BFD_RELOC_V850_TDA_16_16_OFFSET |
| 2502 | ENUMDOC |
| 2503 | This is a 16 bit offset from the tiny data area pointer. |
| 2504 | COMMENT |
| 2505 | ENUM |
| 2506 | BFD_RELOC_V850_TDA_4_5_OFFSET |
| 2507 | ENUMDOC |
| 2508 | This is a 5 bit offset (of which only 4 bits are used) from the tiny |
| 2509 | data area pointer. |
| 2510 | ENUM |
| 2511 | BFD_RELOC_V850_TDA_4_4_OFFSET |
| 2512 | ENUMDOC |
| 2513 | This is a 4 bit offset from the tiny data area pointer. |
| 2514 | ENUM |
| 2515 | BFD_RELOC_V850_SDA_16_16_SPLIT_OFFSET |
| 2516 | ENUMDOC |
| 2517 | This is a 16 bit offset from the short data area pointer, with the |
| 2518 | bits placed non-contigously in the instruction. |
| 2519 | ENUM |
| 2520 | BFD_RELOC_V850_ZDA_16_16_SPLIT_OFFSET |
| 2521 | ENUMDOC |
| 2522 | This is a 16 bit offset from the zero data area pointer, with the |
| 2523 | bits placed non-contigously in the instruction. |
| 2524 | ENUM |
| 2525 | BFD_RELOC_V850_CALLT_6_7_OFFSET |
| 2526 | ENUMDOC |
| 2527 | This is a 6 bit offset from the call table base pointer. |
| 2528 | ENUM |
| 2529 | BFD_RELOC_V850_CALLT_16_16_OFFSET |
| 2530 | ENUMDOC |
| 2531 | This is a 16 bit offset from the call table base pointer. |
| 2532 | COMMENT |
| 2533 | |
| 2534 | ENUM |
| 2535 | BFD_RELOC_MN10300_32_PCREL |
| 2536 | ENUMDOC |
| 2537 | This is a 32bit pcrel reloc for the mn10300, offset by two bytes in the |
| 2538 | instruction. |
| 2539 | ENUM |
| 2540 | BFD_RELOC_MN10300_16_PCREL |
| 2541 | ENUMDOC |
| 2542 | This is a 16bit pcrel reloc for the mn10300, offset by two bytes in the |
| 2543 | instruction. |
| 2544 | |
| 2545 | ENUM |
| 2546 | BFD_RELOC_TIC30_LDP |
| 2547 | ENUMDOC |
| 2548 | This is a 8bit DP reloc for the tms320c30, where the most |
| 2549 | significant 8 bits of a 24 bit word are placed into the least |
| 2550 | significant 8 bits of the opcode. |
| 2551 | |
| 2552 | ENUM |
| 2553 | BFD_RELOC_TIC54X_PARTLS7 |
| 2554 | ENUMDOC |
| 2555 | This is a 7bit reloc for the tms320c54x, where the least |
| 2556 | significant 7 bits of a 16 bit word are placed into the least |
| 2557 | significant 7 bits of the opcode. |
| 2558 | |
| 2559 | ENUM |
| 2560 | BFD_RELOC_TIC54X_PARTMS9 |
| 2561 | ENUMDOC |
| 2562 | This is a 9bit DP reloc for the tms320c54x, where the most |
| 2563 | significant 9 bits of a 16 bit word are placed into the least |
| 2564 | significant 9 bits of the opcode. |
| 2565 | |
| 2566 | ENUM |
| 2567 | BFD_RELOC_TIC54X_23 |
| 2568 | ENUMDOC |
| 2569 | This is an extended address 23-bit reloc for the tms320c54x. |
| 2570 | |
| 2571 | ENUM |
| 2572 | BFD_RELOC_TIC54X_16_OF_23 |
| 2573 | ENUMDOC |
| 2574 | This is a 16-bit reloc for the tms320c54x, where the least |
| 2575 | significant 16 bits of a 23-bit extended address are placed into |
| 2576 | the opcode. |
| 2577 | |
| 2578 | ENUM |
| 2579 | BFD_RELOC_TIC54X_MS7_OF_23 |
| 2580 | ENUMDOC |
| 2581 | This is a reloc for the tms320c54x, where the most |
| 2582 | significant 7 bits of a 23-bit extended address are placed into |
| 2583 | the opcode. |
| 2584 | |
| 2585 | ENUM |
| 2586 | BFD_RELOC_FR30_48 |
| 2587 | ENUMDOC |
| 2588 | This is a 48 bit reloc for the FR30 that stores 32 bits. |
| 2589 | ENUM |
| 2590 | BFD_RELOC_FR30_20 |
| 2591 | ENUMDOC |
| 2592 | This is a 32 bit reloc for the FR30 that stores 20 bits split up into |
| 2593 | two sections. |
| 2594 | ENUM |
| 2595 | BFD_RELOC_FR30_6_IN_4 |
| 2596 | ENUMDOC |
| 2597 | This is a 16 bit reloc for the FR30 that stores a 6 bit word offset in |
| 2598 | 4 bits. |
| 2599 | ENUM |
| 2600 | BFD_RELOC_FR30_8_IN_8 |
| 2601 | ENUMDOC |
| 2602 | This is a 16 bit reloc for the FR30 that stores an 8 bit byte offset |
| 2603 | into 8 bits. |
| 2604 | ENUM |
| 2605 | BFD_RELOC_FR30_9_IN_8 |
| 2606 | ENUMDOC |
| 2607 | This is a 16 bit reloc for the FR30 that stores a 9 bit short offset |
| 2608 | into 8 bits. |
| 2609 | ENUM |
| 2610 | BFD_RELOC_FR30_10_IN_8 |
| 2611 | ENUMDOC |
| 2612 | This is a 16 bit reloc for the FR30 that stores a 10 bit word offset |
| 2613 | into 8 bits. |
| 2614 | ENUM |
| 2615 | BFD_RELOC_FR30_9_PCREL |
| 2616 | ENUMDOC |
| 2617 | This is a 16 bit reloc for the FR30 that stores a 9 bit pc relative |
| 2618 | short offset into 8 bits. |
| 2619 | ENUM |
| 2620 | BFD_RELOC_FR30_12_PCREL |
| 2621 | ENUMDOC |
| 2622 | This is a 16 bit reloc for the FR30 that stores a 12 bit pc relative |
| 2623 | short offset into 11 bits. |
| 2624 | |
| 2625 | ENUM |
| 2626 | BFD_RELOC_MCORE_PCREL_IMM8BY4 |
| 2627 | ENUMX |
| 2628 | BFD_RELOC_MCORE_PCREL_IMM11BY2 |
| 2629 | ENUMX |
| 2630 | BFD_RELOC_MCORE_PCREL_IMM4BY2 |
| 2631 | ENUMX |
| 2632 | BFD_RELOC_MCORE_PCREL_32 |
| 2633 | ENUMX |
| 2634 | BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2 |
| 2635 | ENUMX |
| 2636 | BFD_RELOC_MCORE_RVA |
| 2637 | ENUMDOC |
| 2638 | Motorola Mcore relocations. |
| 2639 | |
| 2640 | ENUM |
| 2641 | BFD_RELOC_AVR_7_PCREL |
| 2642 | ENUMDOC |
| 2643 | This is a 16 bit reloc for the AVR that stores 8 bit pc relative |
| 2644 | short offset into 7 bits. |
| 2645 | ENUM |
| 2646 | BFD_RELOC_AVR_13_PCREL |
| 2647 | ENUMDOC |
| 2648 | This is a 16 bit reloc for the AVR that stores 13 bit pc relative |
| 2649 | short offset into 12 bits. |
| 2650 | ENUM |
| 2651 | BFD_RELOC_AVR_16_PM |
| 2652 | ENUMDOC |
| 2653 | This is a 16 bit reloc for the AVR that stores 17 bit value (usually |
| 2654 | program memory address) into 16 bits. |
| 2655 | ENUM |
| 2656 | BFD_RELOC_AVR_LO8_LDI |
| 2657 | ENUMDOC |
| 2658 | This is a 16 bit reloc for the AVR that stores 8 bit value (usually |
| 2659 | data memory address) into 8 bit immediate value of LDI insn. |
| 2660 | ENUM |
| 2661 | BFD_RELOC_AVR_HI8_LDI |
| 2662 | ENUMDOC |
| 2663 | This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit |
| 2664 | of data memory address) into 8 bit immediate value of LDI insn. |
| 2665 | ENUM |
| 2666 | BFD_RELOC_AVR_HH8_LDI |
| 2667 | ENUMDOC |
| 2668 | This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit |
| 2669 | of program memory address) into 8 bit immediate value of LDI insn. |
| 2670 | ENUM |
| 2671 | BFD_RELOC_AVR_LO8_LDI_NEG |
| 2672 | ENUMDOC |
| 2673 | This is a 16 bit reloc for the AVR that stores negated 8 bit value |
| 2674 | (usually data memory address) into 8 bit immediate value of SUBI insn. |
| 2675 | ENUM |
| 2676 | BFD_RELOC_AVR_HI8_LDI_NEG |
| 2677 | ENUMDOC |
| 2678 | This is a 16 bit reloc for the AVR that stores negated 8 bit value |
| 2679 | (high 8 bit of data memory address) into 8 bit immediate value of |
| 2680 | SUBI insn. |
| 2681 | ENUM |
| 2682 | BFD_RELOC_AVR_HH8_LDI_NEG |
| 2683 | ENUMDOC |
| 2684 | This is a 16 bit reloc for the AVR that stores negated 8 bit value |
| 2685 | (most high 8 bit of program memory address) into 8 bit immediate value |
| 2686 | of LDI or SUBI insn. |
| 2687 | ENUM |
| 2688 | BFD_RELOC_AVR_LO8_LDI_PM |
| 2689 | ENUMDOC |
| 2690 | This is a 16 bit reloc for the AVR that stores 8 bit value (usually |
| 2691 | command address) into 8 bit immediate value of LDI insn. |
| 2692 | ENUM |
| 2693 | BFD_RELOC_AVR_HI8_LDI_PM |
| 2694 | ENUMDOC |
| 2695 | This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit |
| 2696 | of command address) into 8 bit immediate value of LDI insn. |
| 2697 | ENUM |
| 2698 | BFD_RELOC_AVR_HH8_LDI_PM |
| 2699 | ENUMDOC |
| 2700 | This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit |
| 2701 | of command address) into 8 bit immediate value of LDI insn. |
| 2702 | ENUM |
| 2703 | BFD_RELOC_AVR_LO8_LDI_PM_NEG |
| 2704 | ENUMDOC |
| 2705 | This is a 16 bit reloc for the AVR that stores negated 8 bit value |
| 2706 | (usually command address) into 8 bit immediate value of SUBI insn. |
| 2707 | ENUM |
| 2708 | BFD_RELOC_AVR_HI8_LDI_PM_NEG |
| 2709 | ENUMDOC |
| 2710 | This is a 16 bit reloc for the AVR that stores negated 8 bit value |
| 2711 | (high 8 bit of 16 bit command address) into 8 bit immediate value |
| 2712 | of SUBI insn. |
| 2713 | ENUM |
| 2714 | BFD_RELOC_AVR_HH8_LDI_PM_NEG |
| 2715 | ENUMDOC |
| 2716 | This is a 16 bit reloc for the AVR that stores negated 8 bit value |
| 2717 | (high 6 bit of 22 bit command address) into 8 bit immediate |
| 2718 | value of SUBI insn. |
| 2719 | ENUM |
| 2720 | BFD_RELOC_AVR_CALL |
| 2721 | ENUMDOC |
| 2722 | This is a 32 bit reloc for the AVR that stores 23 bit value |
| 2723 | into 22 bits. |
| 2724 | |
| 2725 | ENUM |
| 2726 | BFD_RELOC_VTABLE_INHERIT |
| 2727 | ENUMX |
| 2728 | BFD_RELOC_VTABLE_ENTRY |
| 2729 | ENUMDOC |
| 2730 | These two relocations are used by the linker to determine which of |
| 2731 | the entries in a C++ virtual function table are actually used. When |
| 2732 | the --gc-sections option is given, the linker will zero out the entries |
| 2733 | that are not used, so that the code for those functions need not be |
| 2734 | included in the output. |
| 2735 | |
| 2736 | VTABLE_INHERIT is a zero-space relocation used to describe to the |
| 2737 | linker the inheritence tree of a C++ virtual function table. The |
| 2738 | relocation's symbol should be the parent class' vtable, and the |
| 2739 | relocation should be located at the child vtable. |
| 2740 | |
| 2741 | VTABLE_ENTRY is a zero-space relocation that describes the use of a |
| 2742 | virtual function table entry. The reloc's symbol should refer to the |
| 2743 | table of the class mentioned in the code. Off of that base, an offset |
| 2744 | describes the entry that is being used. For Rela hosts, this offset |
| 2745 | is stored in the reloc's addend. For Rel hosts, we are forced to put |
| 2746 | this offset in the reloc's section offset. |
| 2747 | |
| 2748 | ENUM |
| 2749 | BFD_RELOC_IA64_IMM14 |
| 2750 | ENUMX |
| 2751 | BFD_RELOC_IA64_IMM22 |
| 2752 | ENUMX |
| 2753 | BFD_RELOC_IA64_IMM64 |
| 2754 | ENUMX |
| 2755 | BFD_RELOC_IA64_DIR32MSB |
| 2756 | ENUMX |
| 2757 | BFD_RELOC_IA64_DIR32LSB |
| 2758 | ENUMX |
| 2759 | BFD_RELOC_IA64_DIR64MSB |
| 2760 | ENUMX |
| 2761 | BFD_RELOC_IA64_DIR64LSB |
| 2762 | ENUMX |
| 2763 | BFD_RELOC_IA64_GPREL22 |
| 2764 | ENUMX |
| 2765 | BFD_RELOC_IA64_GPREL64I |
| 2766 | ENUMX |
| 2767 | BFD_RELOC_IA64_GPREL32MSB |
| 2768 | ENUMX |
| 2769 | BFD_RELOC_IA64_GPREL32LSB |
| 2770 | ENUMX |
| 2771 | BFD_RELOC_IA64_GPREL64MSB |
| 2772 | ENUMX |
| 2773 | BFD_RELOC_IA64_GPREL64LSB |
| 2774 | ENUMX |
| 2775 | BFD_RELOC_IA64_LTOFF22 |
| 2776 | ENUMX |
| 2777 | BFD_RELOC_IA64_LTOFF64I |
| 2778 | ENUMX |
| 2779 | BFD_RELOC_IA64_PLTOFF22 |
| 2780 | ENUMX |
| 2781 | BFD_RELOC_IA64_PLTOFF64I |
| 2782 | ENUMX |
| 2783 | BFD_RELOC_IA64_PLTOFF64MSB |
| 2784 | ENUMX |
| 2785 | BFD_RELOC_IA64_PLTOFF64LSB |
| 2786 | ENUMX |
| 2787 | BFD_RELOC_IA64_FPTR64I |
| 2788 | ENUMX |
| 2789 | BFD_RELOC_IA64_FPTR32MSB |
| 2790 | ENUMX |
| 2791 | BFD_RELOC_IA64_FPTR32LSB |
| 2792 | ENUMX |
| 2793 | BFD_RELOC_IA64_FPTR64MSB |
| 2794 | ENUMX |
| 2795 | BFD_RELOC_IA64_FPTR64LSB |
| 2796 | ENUMX |
| 2797 | BFD_RELOC_IA64_PCREL21B |
| 2798 | ENUMX |
| 2799 | BFD_RELOC_IA64_PCREL21BI |
| 2800 | ENUMX |
| 2801 | BFD_RELOC_IA64_PCREL21M |
| 2802 | ENUMX |
| 2803 | BFD_RELOC_IA64_PCREL21F |
| 2804 | ENUMX |
| 2805 | BFD_RELOC_IA64_PCREL22 |
| 2806 | ENUMX |
| 2807 | BFD_RELOC_IA64_PCREL60B |
| 2808 | ENUMX |
| 2809 | BFD_RELOC_IA64_PCREL64I |
| 2810 | ENUMX |
| 2811 | BFD_RELOC_IA64_PCREL32MSB |
| 2812 | ENUMX |
| 2813 | BFD_RELOC_IA64_PCREL32LSB |
| 2814 | ENUMX |
| 2815 | BFD_RELOC_IA64_PCREL64MSB |
| 2816 | ENUMX |
| 2817 | BFD_RELOC_IA64_PCREL64LSB |
| 2818 | ENUMX |
| 2819 | BFD_RELOC_IA64_LTOFF_FPTR22 |
| 2820 | ENUMX |
| 2821 | BFD_RELOC_IA64_LTOFF_FPTR64I |
| 2822 | ENUMX |
| 2823 | BFD_RELOC_IA64_LTOFF_FPTR64MSB |
| 2824 | ENUMX |
| 2825 | BFD_RELOC_IA64_LTOFF_FPTR64LSB |
| 2826 | ENUMX |
| 2827 | BFD_RELOC_IA64_SEGBASE |
| 2828 | ENUMX |
| 2829 | BFD_RELOC_IA64_SEGREL32MSB |
| 2830 | ENUMX |
| 2831 | BFD_RELOC_IA64_SEGREL32LSB |
| 2832 | ENUMX |
| 2833 | BFD_RELOC_IA64_SEGREL64MSB |
| 2834 | ENUMX |
| 2835 | BFD_RELOC_IA64_SEGREL64LSB |
| 2836 | ENUMX |
| 2837 | BFD_RELOC_IA64_SECREL32MSB |
| 2838 | ENUMX |
| 2839 | BFD_RELOC_IA64_SECREL32LSB |
| 2840 | ENUMX |
| 2841 | BFD_RELOC_IA64_SECREL64MSB |
| 2842 | ENUMX |
| 2843 | BFD_RELOC_IA64_SECREL64LSB |
| 2844 | ENUMX |
| 2845 | BFD_RELOC_IA64_REL32MSB |
| 2846 | ENUMX |
| 2847 | BFD_RELOC_IA64_REL32LSB |
| 2848 | ENUMX |
| 2849 | BFD_RELOC_IA64_REL64MSB |
| 2850 | ENUMX |
| 2851 | BFD_RELOC_IA64_REL64LSB |
| 2852 | ENUMX |
| 2853 | BFD_RELOC_IA64_LTV32MSB |
| 2854 | ENUMX |
| 2855 | BFD_RELOC_IA64_LTV32LSB |
| 2856 | ENUMX |
| 2857 | BFD_RELOC_IA64_LTV64MSB |
| 2858 | ENUMX |
| 2859 | BFD_RELOC_IA64_LTV64LSB |
| 2860 | ENUMX |
| 2861 | BFD_RELOC_IA64_IPLTMSB |
| 2862 | ENUMX |
| 2863 | BFD_RELOC_IA64_IPLTLSB |
| 2864 | ENUMX |
| 2865 | BFD_RELOC_IA64_EPLTMSB |
| 2866 | ENUMX |
| 2867 | BFD_RELOC_IA64_EPLTLSB |
| 2868 | ENUMX |
| 2869 | BFD_RELOC_IA64_COPY |
| 2870 | ENUMX |
| 2871 | BFD_RELOC_IA64_TPREL22 |
| 2872 | ENUMX |
| 2873 | BFD_RELOC_IA64_TPREL64MSB |
| 2874 | ENUMX |
| 2875 | BFD_RELOC_IA64_TPREL64LSB |
| 2876 | ENUMX |
| 2877 | BFD_RELOC_IA64_LTOFF_TP22 |
| 2878 | ENUMX |
| 2879 | BFD_RELOC_IA64_LTOFF22X |
| 2880 | ENUMX |
| 2881 | BFD_RELOC_IA64_LDXMOV |
| 2882 | ENUMDOC |
| 2883 | Intel IA64 Relocations. |
| 2884 | |
| 2885 | ENUM |
| 2886 | BFD_RELOC_M68HC11_HI8 |
| 2887 | ENUMDOC |
| 2888 | Motorola 68HC11 reloc. |
| 2889 | This is the 8 bits high part of an absolute address. |
| 2890 | ENUM |
| 2891 | BFD_RELOC_M68HC11_LO8 |
| 2892 | ENUMDOC |
| 2893 | Motorola 68HC11 reloc. |
| 2894 | This is the 8 bits low part of an absolute address. |
| 2895 | ENUM |
| 2896 | BFD_RELOC_M68HC11_3B |
| 2897 | ENUMDOC |
| 2898 | Motorola 68HC11 reloc. |
| 2899 | This is the 3 bits of a value. |
| 2900 | |
| 2901 | ENDSENUM |
| 2902 | BFD_RELOC_UNUSED |
| 2903 | CODE_FRAGMENT |
| 2904 | . |
| 2905 | .typedef enum bfd_reloc_code_real bfd_reloc_code_real_type; |
| 2906 | */ |
| 2907 | |
| 2908 | |
| 2909 | /* |
| 2910 | FUNCTION |
| 2911 | bfd_reloc_type_lookup |
| 2912 | |
| 2913 | SYNOPSIS |
| 2914 | reloc_howto_type * |
| 2915 | bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code); |
| 2916 | |
| 2917 | DESCRIPTION |
| 2918 | Return a pointer to a howto structure which, when |
| 2919 | invoked, will perform the relocation @var{code} on data from the |
| 2920 | architecture noted. |
| 2921 | |
| 2922 | */ |
| 2923 | |
| 2924 | |
| 2925 | reloc_howto_type * |
| 2926 | bfd_reloc_type_lookup (abfd, code) |
| 2927 | bfd *abfd; |
| 2928 | bfd_reloc_code_real_type code; |
| 2929 | { |
| 2930 | return BFD_SEND (abfd, reloc_type_lookup, (abfd, code)); |
| 2931 | } |
| 2932 | |
| 2933 | static reloc_howto_type bfd_howto_32 = |
| 2934 | HOWTO (0, 00, 2, 32, false, 0, complain_overflow_bitfield, 0, "VRT32", false, 0xffffffff, 0xffffffff, true); |
| 2935 | |
| 2936 | |
| 2937 | /* |
| 2938 | INTERNAL_FUNCTION |
| 2939 | bfd_default_reloc_type_lookup |
| 2940 | |
| 2941 | SYNOPSIS |
| 2942 | reloc_howto_type *bfd_default_reloc_type_lookup |
| 2943 | (bfd *abfd, bfd_reloc_code_real_type code); |
| 2944 | |
| 2945 | DESCRIPTION |
| 2946 | Provides a default relocation lookup routine for any architecture. |
| 2947 | |
| 2948 | |
| 2949 | */ |
| 2950 | |
| 2951 | reloc_howto_type * |
| 2952 | bfd_default_reloc_type_lookup (abfd, code) |
| 2953 | bfd *abfd; |
| 2954 | bfd_reloc_code_real_type code; |
| 2955 | { |
| 2956 | switch (code) |
| 2957 | { |
| 2958 | case BFD_RELOC_CTOR: |
| 2959 | /* The type of reloc used in a ctor, which will be as wide as the |
| 2960 | address - so either a 64, 32, or 16 bitter. */ |
| 2961 | switch (bfd_get_arch_info (abfd)->bits_per_address) |
| 2962 | { |
| 2963 | case 64: |
| 2964 | BFD_FAIL (); |
| 2965 | case 32: |
| 2966 | return &bfd_howto_32; |
| 2967 | case 16: |
| 2968 | BFD_FAIL (); |
| 2969 | default: |
| 2970 | BFD_FAIL (); |
| 2971 | } |
| 2972 | default: |
| 2973 | BFD_FAIL (); |
| 2974 | } |
| 2975 | return (reloc_howto_type *) NULL; |
| 2976 | } |
| 2977 | |
| 2978 | /* |
| 2979 | FUNCTION |
| 2980 | bfd_get_reloc_code_name |
| 2981 | |
| 2982 | SYNOPSIS |
| 2983 | const char *bfd_get_reloc_code_name (bfd_reloc_code_real_type code); |
| 2984 | |
| 2985 | DESCRIPTION |
| 2986 | Provides a printable name for the supplied relocation code. |
| 2987 | Useful mainly for printing error messages. |
| 2988 | */ |
| 2989 | |
| 2990 | const char * |
| 2991 | bfd_get_reloc_code_name (code) |
| 2992 | bfd_reloc_code_real_type code; |
| 2993 | { |
| 2994 | if (code > BFD_RELOC_UNUSED) |
| 2995 | return 0; |
| 2996 | return bfd_reloc_code_real_names[(int)code]; |
| 2997 | } |
| 2998 | |
| 2999 | /* |
| 3000 | INTERNAL_FUNCTION |
| 3001 | bfd_generic_relax_section |
| 3002 | |
| 3003 | SYNOPSIS |
| 3004 | boolean bfd_generic_relax_section |
| 3005 | (bfd *abfd, |
| 3006 | asection *section, |
| 3007 | struct bfd_link_info *, |
| 3008 | boolean *); |
| 3009 | |
| 3010 | DESCRIPTION |
| 3011 | Provides default handling for relaxing for back ends which |
| 3012 | don't do relaxing -- i.e., does nothing. |
| 3013 | */ |
| 3014 | |
| 3015 | /*ARGSUSED*/ |
| 3016 | boolean |
| 3017 | bfd_generic_relax_section (abfd, section, link_info, again) |
| 3018 | bfd *abfd ATTRIBUTE_UNUSED; |
| 3019 | asection *section ATTRIBUTE_UNUSED; |
| 3020 | struct bfd_link_info *link_info ATTRIBUTE_UNUSED; |
| 3021 | boolean *again; |
| 3022 | { |
| 3023 | *again = false; |
| 3024 | return true; |
| 3025 | } |
| 3026 | |
| 3027 | /* |
| 3028 | INTERNAL_FUNCTION |
| 3029 | bfd_generic_gc_sections |
| 3030 | |
| 3031 | SYNOPSIS |
| 3032 | boolean bfd_generic_gc_sections |
| 3033 | (bfd *, struct bfd_link_info *); |
| 3034 | |
| 3035 | DESCRIPTION |
| 3036 | Provides default handling for relaxing for back ends which |
| 3037 | don't do section gc -- i.e., does nothing. |
| 3038 | */ |
| 3039 | |
| 3040 | /*ARGSUSED*/ |
| 3041 | boolean |
| 3042 | bfd_generic_gc_sections (abfd, link_info) |
| 3043 | bfd *abfd ATTRIBUTE_UNUSED; |
| 3044 | struct bfd_link_info *link_info ATTRIBUTE_UNUSED; |
| 3045 | { |
| 3046 | return true; |
| 3047 | } |
| 3048 | |
| 3049 | /* |
| 3050 | INTERNAL_FUNCTION |
| 3051 | bfd_generic_get_relocated_section_contents |
| 3052 | |
| 3053 | SYNOPSIS |
| 3054 | bfd_byte * |
| 3055 | bfd_generic_get_relocated_section_contents (bfd *abfd, |
| 3056 | struct bfd_link_info *link_info, |
| 3057 | struct bfd_link_order *link_order, |
| 3058 | bfd_byte *data, |
| 3059 | boolean relocateable, |
| 3060 | asymbol **symbols); |
| 3061 | |
| 3062 | DESCRIPTION |
| 3063 | Provides default handling of relocation effort for back ends |
| 3064 | which can't be bothered to do it efficiently. |
| 3065 | |
| 3066 | */ |
| 3067 | |
| 3068 | bfd_byte * |
| 3069 | bfd_generic_get_relocated_section_contents (abfd, link_info, link_order, data, |
| 3070 | relocateable, symbols) |
| 3071 | bfd *abfd; |
| 3072 | struct bfd_link_info *link_info; |
| 3073 | struct bfd_link_order *link_order; |
| 3074 | bfd_byte *data; |
| 3075 | boolean relocateable; |
| 3076 | asymbol **symbols; |
| 3077 | { |
| 3078 | /* Get enough memory to hold the stuff */ |
| 3079 | bfd *input_bfd = link_order->u.indirect.section->owner; |
| 3080 | asection *input_section = link_order->u.indirect.section; |
| 3081 | |
| 3082 | long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section); |
| 3083 | arelent **reloc_vector = NULL; |
| 3084 | long reloc_count; |
| 3085 | |
| 3086 | if (reloc_size < 0) |
| 3087 | goto error_return; |
| 3088 | |
| 3089 | reloc_vector = (arelent **) bfd_malloc ((size_t) reloc_size); |
| 3090 | if (reloc_vector == NULL && reloc_size != 0) |
| 3091 | goto error_return; |
| 3092 | |
| 3093 | /* read in the section */ |
| 3094 | if (!bfd_get_section_contents (input_bfd, |
| 3095 | input_section, |
| 3096 | (PTR) data, |
| 3097 | 0, |
| 3098 | input_section->_raw_size)) |
| 3099 | goto error_return; |
| 3100 | |
| 3101 | /* We're not relaxing the section, so just copy the size info */ |
| 3102 | input_section->_cooked_size = input_section->_raw_size; |
| 3103 | input_section->reloc_done = true; |
| 3104 | |
| 3105 | reloc_count = bfd_canonicalize_reloc (input_bfd, |
| 3106 | input_section, |
| 3107 | reloc_vector, |
| 3108 | symbols); |
| 3109 | if (reloc_count < 0) |
| 3110 | goto error_return; |
| 3111 | |
| 3112 | if (reloc_count > 0) |
| 3113 | { |
| 3114 | arelent **parent; |
| 3115 | for (parent = reloc_vector; *parent != (arelent *) NULL; |
| 3116 | parent++) |
| 3117 | { |
| 3118 | char *error_message = (char *) NULL; |
| 3119 | bfd_reloc_status_type r = |
| 3120 | bfd_perform_relocation (input_bfd, |
| 3121 | *parent, |
| 3122 | (PTR) data, |
| 3123 | input_section, |
| 3124 | relocateable ? abfd : (bfd *) NULL, |
| 3125 | &error_message); |
| 3126 | |
| 3127 | if (relocateable) |
| 3128 | { |
| 3129 | asection *os = input_section->output_section; |
| 3130 | |
| 3131 | /* A partial link, so keep the relocs */ |
| 3132 | os->orelocation[os->reloc_count] = *parent; |
| 3133 | os->reloc_count++; |
| 3134 | } |
| 3135 | |
| 3136 | if (r != bfd_reloc_ok) |
| 3137 | { |
| 3138 | switch (r) |
| 3139 | { |
| 3140 | case bfd_reloc_undefined: |
| 3141 | if (!((*link_info->callbacks->undefined_symbol) |
| 3142 | (link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr), |
| 3143 | input_bfd, input_section, (*parent)->address, |
| 3144 | true))) |
| 3145 | goto error_return; |
| 3146 | break; |
| 3147 | case bfd_reloc_dangerous: |
| 3148 | BFD_ASSERT (error_message != (char *) NULL); |
| 3149 | if (!((*link_info->callbacks->reloc_dangerous) |
| 3150 | (link_info, error_message, input_bfd, input_section, |
| 3151 | (*parent)->address))) |
| 3152 | goto error_return; |
| 3153 | break; |
| 3154 | case bfd_reloc_overflow: |
| 3155 | if (!((*link_info->callbacks->reloc_overflow) |
| 3156 | (link_info, bfd_asymbol_name (*(*parent)->sym_ptr_ptr), |
| 3157 | (*parent)->howto->name, (*parent)->addend, |
| 3158 | input_bfd, input_section, (*parent)->address))) |
| 3159 | goto error_return; |
| 3160 | break; |
| 3161 | case bfd_reloc_outofrange: |
| 3162 | default: |
| 3163 | abort (); |
| 3164 | break; |
| 3165 | } |
| 3166 | |
| 3167 | } |
| 3168 | } |
| 3169 | } |
| 3170 | if (reloc_vector != NULL) |
| 3171 | free (reloc_vector); |
| 3172 | return data; |
| 3173 | |
| 3174 | error_return: |
| 3175 | if (reloc_vector != NULL) |
| 3176 | free (reloc_vector); |
| 3177 | return NULL; |
| 3178 | } |