Changeset 609 for branches/GNU/src/binutils/bfd/elf32-ppc.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/bfd/elf32-ppc.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* PowerPC-specific support for 32-bit ELF 2 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 2 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 3 3 Free Software Foundation, Inc. 4 4 Written by Ian Lance Taylor, Cygnus Support. 5 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. */ 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 20 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 Boston, MA 02111-1307, USA. */ 21 22 22 23 /* This file is based on a preliminary PowerPC ELF ABI. The … … 31 32 #include "elf-bfd.h" 32 33 #include "elf/ppc.h" 33 34 #define USE_RELA /* we want RELA relocations, not REL */ 35 34 #include "elf32-ppc.h" 35 36 /* RELA relocations are used here. */ 37 38 static struct bfd_hash_entry *ppc_elf_link_hash_newfunc 39 PARAMS ((struct bfd_hash_entry *entry, struct bfd_hash_table *table, 40 const char *string)); 41 static struct bfd_link_hash_table *ppc_elf_link_hash_table_create 42 PARAMS ((bfd *abfd)); 43 static void ppc_elf_copy_indirect_symbol 44 PARAMS ((struct elf_backend_data *bed, struct elf_link_hash_entry *dir, 45 struct elf_link_hash_entry *ind)); 36 46 static reloc_howto_type *ppc_elf_reloc_type_lookup 37 47 PARAMS ((bfd *abfd, bfd_reloc_code_real_type code)); 38 48 static void ppc_elf_info_to_howto 39 PARAMS ((bfd *abfd, arelent *cache_ptr, Elf32_Internal_Rela *dst)); 40 static void ppc_elf_howto_init PARAMS ((void)); 49 PARAMS ((bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)); 50 static void ppc_elf_howto_init 51 PARAMS ((void)); 52 static int ppc_elf_sort_rela 53 PARAMS ((const PTR, const PTR)); 54 static bfd_boolean ppc_elf_relax_section 55 PARAMS ((bfd *, asection *, struct bfd_link_info *, bfd_boolean *)); 41 56 static bfd_reloc_status_type ppc_elf_addr16_ha_reloc 42 57 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); 43 static boolean ppc_elf_set_private_flags PARAMS ((bfd *, flagword)); 44 static boolean ppc_elf_copy_private_bfd_data PARAMS ((bfd *, bfd *)); 45 static boolean ppc_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *)); 46 47 static int ppc_elf_additional_program_headers PARAMS ((bfd *)); 48 static boolean ppc_elf_modify_segment_map PARAMS ((bfd *)); 49 50 static boolean ppc_elf_create_dynamic_sections 58 static bfd_reloc_status_type ppc_elf_unhandled_reloc 59 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); 60 static bfd_boolean ppc_elf_object_p 61 PARAMS ((bfd *)); 62 static bfd_boolean ppc_elf_set_private_flags 63 PARAMS ((bfd *, flagword)); 64 static bfd_boolean ppc_elf_merge_private_bfd_data 65 PARAMS ((bfd *, bfd *)); 66 static int ppc_elf_additional_program_headers 67 PARAMS ((bfd *)); 68 static bfd_boolean ppc_elf_modify_segment_map 69 PARAMS ((bfd *)); 70 static bfd_boolean ppc_elf_create_got 51 71 PARAMS ((bfd *, struct bfd_link_info *)); 52 53 static boolean ppc_elf_section_from_shdr PARAMS ((bfd *, 54 Elf32_Internal_Shdr *, 55 char *)); 56 static boolean ppc_elf_fake_sections 57 PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *)); 58 72 static bfd_boolean ppc_elf_create_dynamic_sections 73 PARAMS ((bfd *, struct bfd_link_info *)); 74 static bfd_boolean ppc_elf_section_from_shdr 75 PARAMS ((bfd *, Elf_Internal_Shdr *, const char *)); 76 static bfd_boolean ppc_elf_fake_sections 77 PARAMS ((bfd *, Elf_Internal_Shdr *, asection *)); 59 78 static elf_linker_section_t *ppc_elf_create_linker_section 60 PARAMS ((bfd *abfd, 61 struct bfd_link_info *info, 79 PARAMS ((bfd *abfd, struct bfd_link_info *info, 62 80 enum elf_linker_section_enum)); 63 64 static boolean ppc_elf_check_relocs PARAMS ((bfd *, 65 struct bfd_link_info *, 66 asection *, 67 const Elf_Internal_Rela *)); 68 69 static asection * ppc_elf_gc_mark_hook PARAMS ((bfd *abfd, 70 struct bfd_link_info *info, 71 Elf_Internal_Rela *rel, 72 struct elf_link_hash_entry *h, 73 Elf_Internal_Sym *sym)); 74 75 static boolean ppc_elf_gc_sweep_hook PARAMS ((bfd *abfd, 76 struct bfd_link_info *info, 77 asection *sec, 78 const Elf_Internal_Rela *relocs)); 79 80 static boolean ppc_elf_adjust_dynamic_symbol PARAMS ((struct bfd_link_info *, 81 struct elf_link_hash_entry *)); 82 83 static boolean ppc_elf_size_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *)); 84 85 static boolean ppc_elf_relocate_section PARAMS ((bfd *, 86 struct bfd_link_info *info, 87 bfd *, 88 asection *, 89 bfd_byte *, 90 Elf_Internal_Rela *relocs, 91 Elf_Internal_Sym *local_syms, 92 asection **)); 93 94 static boolean ppc_elf_add_symbol_hook PARAMS ((bfd *, 95 struct bfd_link_info *, 96 const Elf_Internal_Sym *, 97 const char **, 98 flagword *, 99 asection **, 100 bfd_vma *)); 101 102 static boolean ppc_elf_finish_dynamic_symbol PARAMS ((bfd *, 103 struct bfd_link_info *, 104 struct elf_link_hash_entry *, 105 Elf_Internal_Sym *)); 106 107 static boolean ppc_elf_finish_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *)); 108 109 #define BRANCH_PREDICT_BIT 0x200000 /* branch prediction bit for branch taken relocs */ 110 #define RA_REGISTER_MASK 0x001f0000 /* mask to set RA in memory instructions */ 111 #define RA_REGISTER_SHIFT 16 /* value to shift register by to insert RA */ 81 static bfd_boolean update_local_sym_info 82 PARAMS ((bfd *, Elf_Internal_Shdr *, unsigned long, int)); 83 static void bad_shared_reloc 84 PARAMS ((bfd *, enum elf_ppc_reloc_type)); 85 static bfd_boolean ppc_elf_check_relocs 86 PARAMS ((bfd *, struct bfd_link_info *, asection *, 87 const Elf_Internal_Rela *)); 88 static asection *ppc_elf_gc_mark_hook 89 PARAMS ((asection *sec, struct bfd_link_info *info, Elf_Internal_Rela *rel, 90 struct elf_link_hash_entry *h, Elf_Internal_Sym *sym)); 91 static bfd_boolean ppc_elf_gc_sweep_hook 92 PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *sec, 93 const Elf_Internal_Rela *relocs)); 94 static bfd_boolean ppc_elf_adjust_dynamic_symbol 95 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *)); 96 static bfd_boolean allocate_dynrelocs 97 PARAMS ((struct elf_link_hash_entry *, PTR)); 98 static bfd_boolean readonly_dynrelocs 99 PARAMS ((struct elf_link_hash_entry *, PTR)); 100 static bfd_boolean ppc_elf_size_dynamic_sections 101 PARAMS ((bfd *, struct bfd_link_info *)); 102 static bfd_boolean ppc_elf_relocate_section 103 PARAMS ((bfd *, struct bfd_link_info *info, bfd *, asection *, bfd_byte *, 104 Elf_Internal_Rela *relocs, Elf_Internal_Sym *local_syms, 105 asection **)); 106 static bfd_boolean ppc_elf_add_symbol_hook 107 PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, 108 const char **, flagword *, asection **, bfd_vma *)); 109 static bfd_boolean ppc_elf_finish_dynamic_symbol 110 PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, 111 Elf_Internal_Sym *)); 112 static bfd_boolean ppc_elf_finish_dynamic_sections 113 PARAMS ((bfd *, struct bfd_link_info *)); 114 static enum elf_reloc_type_class ppc_elf_reloc_type_class 115 PARAMS ((const Elf_Internal_Rela *)); 116 static bfd_boolean ppc_elf_grok_prstatus 117 PARAMS ((bfd *abfd, Elf_Internal_Note *note)); 118 static bfd_boolean ppc_elf_grok_psinfo 119 PARAMS ((bfd *abfd, Elf_Internal_Note *note)); 120 121 /* Branch prediction bit for branch taken relocs. */ 122 #define BRANCH_PREDICT_BIT 0x200000 123 /* Mask to set RA in memory instructions. */ 124 #define RA_REGISTER_MASK 0x001f0000 125 /* Value to shift register by to insert RA. */ 126 #define RA_REGISTER_SHIFT 16 112 127 113 128 /* The name of the dynamic interpreter. This is put in the .interp 114 129 section. */ 115 116 130 #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1" 117 131 … … 125 139 #define PLT_NUM_SINGLE_ENTRIES 8192 126 140 141 /* Some nop instructions. */ 142 #define NOP 0x60000000 143 #define CROR_151515 0x4def7b82 144 #define CROR_313131 0x4ffffb82 145 146 /* Offset of tp and dtp pointers from start of TLS block. */ 147 #define TP_OFFSET 0x7000 148 #define DTP_OFFSET 0x8000 149 127 150 /* Will references to this symbol always reference the symbol 128 in this object? */ 151 in this object? STV_PROTECTED is excluded from the visibility test 152 here so that function pointer comparisons work properly. Since 153 function symbols not defined in an app are set to their .plt entry, 154 it's necessary for shared libs to also reference the .plt even 155 though the symbol is really local to the shared lib. */ 129 156 #define SYMBOL_REFERENCES_LOCAL(INFO, H) \ 130 157 ((! INFO->shared \ … … 136 163 137 164 /* Will _calls_ to this symbol always call the version in this object? */ 138 #define SYMBOL_CALLS_LOCAL(INFO, H) \165 #define SYMBOL_CALLS_LOCAL(INFO, H) \ 139 166 ((! INFO->shared \ 140 167 || INFO->symbolic \ … … 142 169 || ELF_ST_VISIBILITY (H->other) != STV_DEFAULT) \ 143 170 && (H->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0) 171 172 173 /* The PPC linker needs to keep track of the number of relocs that it 174 decides to copy as dynamic relocs in check_relocs for each symbol. 175 This is so that it can later discard them if they are found to be 176 unnecessary. We store the information in a field extending the 177 regular ELF linker hash table. */ 178 179 struct ppc_elf_dyn_relocs 180 { 181 struct ppc_elf_dyn_relocs *next; 182 183 /* The input section of the reloc. */ 184 asection *sec; 185 186 /* Total number of relocs copied for the input section. */ 187 bfd_size_type count; 188 189 /* Number of pc-relative relocs copied for the input section. */ 190 bfd_size_type pc_count; 191 }; 192 193 /* PPC ELF linker hash entry. */ 194 195 struct ppc_elf_link_hash_entry 196 { 197 struct elf_link_hash_entry elf; 198 199 /* Track dynamic relocs copied for this symbol. */ 200 struct ppc_elf_dyn_relocs *dyn_relocs; 201 202 /* Contexts in which symbol is used in the GOT (or TOC). 203 TLS_GD .. TLS_TLS bits are or'd into the mask as the 204 corresponding relocs are encountered during check_relocs. 205 tls_optimize clears TLS_GD .. TLS_TPREL when optimizing to 206 indicate the corresponding GOT entry type is not needed. */ 207 #define TLS_GD 1 /* GD reloc. */ 208 #define TLS_LD 2 /* LD reloc. */ 209 #define TLS_TPREL 4 /* TPREL reloc, => IE. */ 210 #define TLS_DTPREL 8 /* DTPREL reloc, => LD. */ 211 #define TLS_TLS 16 /* Any TLS reloc. */ 212 #define TLS_TPRELGD 32 /* TPREL reloc resulting from GD->IE. */ 213 char tls_mask; 214 }; 215 216 #define ppc_elf_hash_entry(ent) ((struct ppc_elf_link_hash_entry *) (ent)) 217 218 /* PPC ELF linker hash table. */ 219 220 struct ppc_elf_link_hash_table 221 { 222 struct elf_link_hash_table elf; 223 224 /* Short-cuts to get to dynamic linker sections. */ 225 asection *got; 226 asection *relgot; 227 asection *plt; 228 asection *relplt; 229 asection *dynbss; 230 asection *relbss; 231 asection *dynsbss; 232 asection *relsbss; 233 elf_linker_section_t *sdata; 234 elf_linker_section_t *sdata2; 235 236 /* Short-cut to first output tls section. */ 237 asection *tls_sec; 238 239 /* Shortcut to .__tls_get_addr. */ 240 struct elf_link_hash_entry *tls_get_addr; 241 242 /* TLS local dynamic got entry handling. */ 243 union { 244 bfd_signed_vma refcount; 245 bfd_vma offset; 246 } tlsld_got; 247 248 /* Small local sym to section mapping cache. */ 249 struct sym_sec_cache sym_sec; 250 }; 251 252 /* Get the PPC ELF linker hash table from a link_info structure. */ 253 254 #define ppc_elf_hash_table(p) \ 255 ((struct ppc_elf_link_hash_table *) (p)->hash) 256 257 /* Create an entry in a PPC ELF linker hash table. */ 258 259 static struct bfd_hash_entry * 260 ppc_elf_link_hash_newfunc (entry, table, string) 261 struct bfd_hash_entry *entry; 262 struct bfd_hash_table *table; 263 const char *string; 264 { 265 /* Allocate the structure if it has not already been allocated by a 266 subclass. */ 267 if (entry == NULL) 268 { 269 entry = bfd_hash_allocate (table, 270 sizeof (struct ppc_elf_link_hash_entry)); 271 if (entry == NULL) 272 return entry; 273 } 274 275 /* Call the allocation method of the superclass. */ 276 entry = _bfd_elf_link_hash_newfunc (entry, table, string); 277 if (entry != NULL) 278 { 279 ppc_elf_hash_entry (entry)->dyn_relocs = NULL; 280 ppc_elf_hash_entry (entry)->tls_mask = 0; 281 } 282 283 return entry; 284 } 285 286 /* Create a PPC ELF linker hash table. */ 287 288 static struct bfd_link_hash_table * 289 ppc_elf_link_hash_table_create (abfd) 290 bfd *abfd; 291 { 292 struct ppc_elf_link_hash_table *ret; 293 294 ret = ((struct ppc_elf_link_hash_table *) 295 bfd_malloc (sizeof (struct ppc_elf_link_hash_table))); 296 if (ret == NULL) 297 return NULL; 298 299 if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, 300 ppc_elf_link_hash_newfunc)) 301 { 302 free (ret); 303 return NULL; 304 } 305 306 ret->got = NULL; 307 ret->relgot = NULL; 308 ret->plt = NULL; 309 ret->relplt = NULL; 310 ret->dynbss = NULL; 311 ret->relbss = NULL; 312 ret->dynsbss = NULL; 313 ret->relsbss = NULL; 314 ret->sdata = NULL; 315 ret->sdata2 = NULL; 316 ret->tls_sec = NULL; 317 ret->tls_get_addr = NULL; 318 ret->tlsld_got.refcount = 0; 319 ret->sym_sec.abfd = NULL; 320 321 return &ret->elf.root; 322 } 323 324 /* If ELIMINATE_COPY_RELOCS is non-zero, the linker will try to avoid 325 copying dynamic variables from a shared lib into an app's dynbss 326 section, and instead use a dynamic relocation to point into the 327 shared lib. */ 328 #define ELIMINATE_COPY_RELOCS 1 329 330 /* Copy the extra info we tack onto an elf_link_hash_entry. */ 331 332 static void 333 ppc_elf_copy_indirect_symbol (bed, dir, ind) 334 struct elf_backend_data *bed; 335 struct elf_link_hash_entry *dir, *ind; 336 { 337 struct ppc_elf_link_hash_entry *edir, *eind; 338 339 edir = (struct ppc_elf_link_hash_entry *) dir; 340 eind = (struct ppc_elf_link_hash_entry *) ind; 341 342 if (eind->dyn_relocs != NULL) 343 { 344 if (edir->dyn_relocs != NULL) 345 { 346 struct ppc_elf_dyn_relocs **pp; 347 struct ppc_elf_dyn_relocs *p; 348 349 if (ind->root.type == bfd_link_hash_indirect) 350 abort (); 351 352 /* Add reloc counts against the weak sym to the strong sym 353 list. Merge any entries against the same section. */ 354 for (pp = &eind->dyn_relocs; (p = *pp) != NULL; ) 355 { 356 struct ppc_elf_dyn_relocs *q; 357 358 for (q = edir->dyn_relocs; q != NULL; q = q->next) 359 if (q->sec == p->sec) 360 { 361 q->pc_count += p->pc_count; 362 q->count += p->count; 363 *pp = p->next; 364 break; 365 } 366 if (q == NULL) 367 pp = &p->next; 368 } 369 *pp = edir->dyn_relocs; 370 } 371 372 edir->dyn_relocs = eind->dyn_relocs; 373 eind->dyn_relocs = NULL; 374 } 375 376 edir->tls_mask |= eind->tls_mask; 377 378 if (ELIMINATE_COPY_RELOCS 379 && ind->root.type != bfd_link_hash_indirect 380 && (dir->elf_link_hash_flags & ELF_LINK_HASH_DYNAMIC_ADJUSTED) != 0) 381 /* If called to transfer flags for a weakdef during processing 382 of elf_adjust_dynamic_symbol, don't copy ELF_LINK_NON_GOT_REF. 383 We clear it ourselves for ELIMINATE_COPY_RELOCS. */ 384 dir->elf_link_hash_flags |= 385 (ind->elf_link_hash_flags & (ELF_LINK_HASH_REF_DYNAMIC 386 | ELF_LINK_HASH_REF_REGULAR 387 | ELF_LINK_HASH_REF_REGULAR_NONWEAK)); 388 else 389 _bfd_elf_link_hash_copy_indirect (bed, dir, ind); 390 } 144 391 145 392 … … 152 399 2, /* size (0 = byte, 1 = short, 2 = long) */ 153 400 32, /* bitsize */ 154 false, /* pc_relative */401 FALSE, /* pc_relative */ 155 402 0, /* bitpos */ 156 403 complain_overflow_bitfield, /* complain_on_overflow */ 157 404 bfd_elf_generic_reloc, /* special_function */ 158 405 "R_PPC_NONE", /* name */ 159 false, /* partial_inplace */406 FALSE, /* partial_inplace */ 160 407 0, /* src_mask */ 161 408 0, /* dst_mask */ 162 false), /* pcrel_offset */409 FALSE), /* pcrel_offset */ 163 410 164 411 /* A standard 32 bit relocation. */ … … 167 414 2, /* size (0 = byte, 1 = short, 2 = long) */ 168 415 32, /* bitsize */ 169 false, /* pc_relative */416 FALSE, /* pc_relative */ 170 417 0, /* bitpos */ 171 418 complain_overflow_bitfield, /* complain_on_overflow */ 172 419 bfd_elf_generic_reloc, /* special_function */ 173 420 "R_PPC_ADDR32", /* name */ 174 false, /* partial_inplace */421 FALSE, /* partial_inplace */ 175 422 0, /* src_mask */ 176 423 0xffffffff, /* dst_mask */ 177 false), /* pcrel_offset */424 FALSE), /* pcrel_offset */ 178 425 179 426 /* An absolute 26 bit branch; the lower two bits must be zero. … … 183 430 2, /* size (0 = byte, 1 = short, 2 = long) */ 184 431 26, /* bitsize */ 185 false, /* pc_relative */432 FALSE, /* pc_relative */ 186 433 0, /* bitpos */ 187 434 complain_overflow_bitfield, /* complain_on_overflow */ 188 435 bfd_elf_generic_reloc, /* special_function */ 189 436 "R_PPC_ADDR24", /* name */ 190 false, /* partial_inplace */437 FALSE, /* partial_inplace */ 191 438 0, /* src_mask */ 192 439 0x3fffffc, /* dst_mask */ 193 false), /* pcrel_offset */440 FALSE), /* pcrel_offset */ 194 441 195 442 /* A standard 16 bit relocation. */ … … 198 445 1, /* size (0 = byte, 1 = short, 2 = long) */ 199 446 16, /* bitsize */ 200 false, /* pc_relative */447 FALSE, /* pc_relative */ 201 448 0, /* bitpos */ 202 449 complain_overflow_bitfield, /* complain_on_overflow */ 203 450 bfd_elf_generic_reloc, /* special_function */ 204 451 "R_PPC_ADDR16", /* name */ 205 false, /* partial_inplace */452 FALSE, /* partial_inplace */ 206 453 0, /* src_mask */ 207 454 0xffff, /* dst_mask */ 208 false), /* pcrel_offset */455 FALSE), /* pcrel_offset */ 209 456 210 457 /* A 16 bit relocation without overflow. */ … … 213 460 1, /* size (0 = byte, 1 = short, 2 = long) */ 214 461 16, /* bitsize */ 215 false, /* pc_relative */462 FALSE, /* pc_relative */ 216 463 0, /* bitpos */ 217 464 complain_overflow_dont,/* complain_on_overflow */ 218 465 bfd_elf_generic_reloc, /* special_function */ 219 466 "R_PPC_ADDR16_LO", /* name */ 220 false, /* partial_inplace */467 FALSE, /* partial_inplace */ 221 468 0, /* src_mask */ 222 469 0xffff, /* dst_mask */ 223 false), /* pcrel_offset */470 FALSE), /* pcrel_offset */ 224 471 225 472 /* The high order 16 bits of an address. */ … … 228 475 1, /* size (0 = byte, 1 = short, 2 = long) */ 229 476 16, /* bitsize */ 230 false, /* pc_relative */477 FALSE, /* pc_relative */ 231 478 0, /* bitpos */ 232 479 complain_overflow_dont, /* complain_on_overflow */ 233 480 bfd_elf_generic_reloc, /* special_function */ 234 481 "R_PPC_ADDR16_HI", /* name */ 235 false, /* partial_inplace */482 FALSE, /* partial_inplace */ 236 483 0, /* src_mask */ 237 484 0xffff, /* dst_mask */ 238 false), /* pcrel_offset */485 FALSE), /* pcrel_offset */ 239 486 240 487 /* The high order 16 bits of an address, plus 1 if the contents of … … 244 491 1, /* size (0 = byte, 1 = short, 2 = long) */ 245 492 16, /* bitsize */ 246 false, /* pc_relative */493 FALSE, /* pc_relative */ 247 494 0, /* bitpos */ 248 495 complain_overflow_dont, /* complain_on_overflow */ 249 496 ppc_elf_addr16_ha_reloc, /* special_function */ 250 497 "R_PPC_ADDR16_HA", /* name */ 251 false, /* partial_inplace */498 FALSE, /* partial_inplace */ 252 499 0, /* src_mask */ 253 500 0xffff, /* dst_mask */ 254 false), /* pcrel_offset */501 FALSE), /* pcrel_offset */ 255 502 256 503 /* An absolute 16 bit branch; the lower two bits must be zero. … … 260 507 2, /* size (0 = byte, 1 = short, 2 = long) */ 261 508 16, /* bitsize */ 262 false, /* pc_relative */509 FALSE, /* pc_relative */ 263 510 0, /* bitpos */ 264 511 complain_overflow_bitfield, /* complain_on_overflow */ 265 512 bfd_elf_generic_reloc, /* special_function */ 266 513 "R_PPC_ADDR14", /* name */ 267 false, /* partial_inplace */514 FALSE, /* partial_inplace */ 268 515 0, /* src_mask */ 269 516 0xfffc, /* dst_mask */ 270 false), /* pcrel_offset */517 FALSE), /* pcrel_offset */ 271 518 272 519 /* An absolute 16 bit branch, for which bit 10 should be set to … … 277 524 2, /* size (0 = byte, 1 = short, 2 = long) */ 278 525 16, /* bitsize */ 279 false, /* pc_relative */526 FALSE, /* pc_relative */ 280 527 0, /* bitpos */ 281 528 complain_overflow_bitfield, /* complain_on_overflow */ 282 529 bfd_elf_generic_reloc, /* special_function */ 283 530 "R_PPC_ADDR14_BRTAKEN",/* name */ 284 false, /* partial_inplace */531 FALSE, /* partial_inplace */ 285 532 0, /* src_mask */ 286 533 0xfffc, /* dst_mask */ 287 false), /* pcrel_offset */534 FALSE), /* pcrel_offset */ 288 535 289 536 /* An absolute 16 bit branch, for which bit 10 should be set to … … 294 541 2, /* size (0 = byte, 1 = short, 2 = long) */ 295 542 16, /* bitsize */ 296 false, /* pc_relative */543 FALSE, /* pc_relative */ 297 544 0, /* bitpos */ 298 545 complain_overflow_bitfield, /* complain_on_overflow */ 299 546 bfd_elf_generic_reloc, /* special_function */ 300 547 "R_PPC_ADDR14_BRNTAKEN",/* name */ 301 false, /* partial_inplace */548 FALSE, /* partial_inplace */ 302 549 0, /* src_mask */ 303 550 0xfffc, /* dst_mask */ 304 false), /* pcrel_offset */551 FALSE), /* pcrel_offset */ 305 552 306 553 /* A relative 26 bit branch; the lower two bits must be zero. */ … … 309 556 2, /* size (0 = byte, 1 = short, 2 = long) */ 310 557 26, /* bitsize */ 311 true, /* pc_relative */558 TRUE, /* pc_relative */ 312 559 0, /* bitpos */ 313 560 complain_overflow_signed, /* complain_on_overflow */ 314 561 bfd_elf_generic_reloc, /* special_function */ 315 562 "R_PPC_REL24", /* name */ 316 false, /* partial_inplace */563 FALSE, /* partial_inplace */ 317 564 0, /* src_mask */ 318 565 0x3fffffc, /* dst_mask */ 319 true), /* pcrel_offset */566 TRUE), /* pcrel_offset */ 320 567 321 568 /* A relative 16 bit branch; the lower two bits must be zero. */ … … 324 571 2, /* size (0 = byte, 1 = short, 2 = long) */ 325 572 16, /* bitsize */ 326 true, /* pc_relative */573 TRUE, /* pc_relative */ 327 574 0, /* bitpos */ 328 575 complain_overflow_signed, /* complain_on_overflow */ 329 576 bfd_elf_generic_reloc, /* special_function */ 330 577 "R_PPC_REL14", /* name */ 331 false, /* partial_inplace */578 FALSE, /* partial_inplace */ 332 579 0, /* src_mask */ 333 580 0xfffc, /* dst_mask */ 334 true), /* pcrel_offset */581 TRUE), /* pcrel_offset */ 335 582 336 583 /* A relative 16 bit branch. Bit 10 should be set to indicate that … … 341 588 2, /* size (0 = byte, 1 = short, 2 = long) */ 342 589 16, /* bitsize */ 343 true, /* pc_relative */590 TRUE, /* pc_relative */ 344 591 0, /* bitpos */ 345 592 complain_overflow_signed, /* complain_on_overflow */ 346 593 bfd_elf_generic_reloc, /* special_function */ 347 594 "R_PPC_REL14_BRTAKEN", /* name */ 348 false, /* partial_inplace */595 FALSE, /* partial_inplace */ 349 596 0, /* src_mask */ 350 597 0xfffc, /* dst_mask */ 351 true), /* pcrel_offset */598 TRUE), /* pcrel_offset */ 352 599 353 600 /* A relative 16 bit branch. Bit 10 should be set to indicate that … … 358 605 2, /* size (0 = byte, 1 = short, 2 = long) */ 359 606 16, /* bitsize */ 360 true, /* pc_relative */607 TRUE, /* pc_relative */ 361 608 0, /* bitpos */ 362 609 complain_overflow_signed, /* complain_on_overflow */ 363 610 bfd_elf_generic_reloc, /* special_function */ 364 611 "R_PPC_REL14_BRNTAKEN",/* name */ 365 false, /* partial_inplace */612 FALSE, /* partial_inplace */ 366 613 0, /* src_mask */ 367 614 0xfffc, /* dst_mask */ 368 true), /* pcrel_offset */615 TRUE), /* pcrel_offset */ 369 616 370 617 /* Like R_PPC_ADDR16, but referring to the GOT table entry for the … … 374 621 1, /* size (0 = byte, 1 = short, 2 = long) */ 375 622 16, /* bitsize */ 376 false, /* pc_relative */623 FALSE, /* pc_relative */ 377 624 0, /* bitpos */ 378 625 complain_overflow_signed, /* complain_on_overflow */ 379 626 bfd_elf_generic_reloc, /* special_function */ 380 627 "R_PPC_GOT16", /* name */ 381 false, /* partial_inplace */628 FALSE, /* partial_inplace */ 382 629 0, /* src_mask */ 383 630 0xffff, /* dst_mask */ 384 false), /* pcrel_offset */631 FALSE), /* pcrel_offset */ 385 632 386 633 /* Like R_PPC_ADDR16_LO, but referring to the GOT table entry for … … 390 637 1, /* size (0 = byte, 1 = short, 2 = long) */ 391 638 16, /* bitsize */ 392 false, /* pc_relative */639 FALSE, /* pc_relative */ 393 640 0, /* bitpos */ 394 641 complain_overflow_dont, /* complain_on_overflow */ 395 642 bfd_elf_generic_reloc, /* special_function */ 396 643 "R_PPC_GOT16_LO", /* name */ 397 false, /* partial_inplace */644 FALSE, /* partial_inplace */ 398 645 0, /* src_mask */ 399 646 0xffff, /* dst_mask */ 400 false), /* pcrel_offset */647 FALSE), /* pcrel_offset */ 401 648 402 649 /* Like R_PPC_ADDR16_HI, but referring to the GOT table entry for … … 406 653 1, /* size (0 = byte, 1 = short, 2 = long) */ 407 654 16, /* bitsize */ 408 false, /* pc_relative */655 FALSE, /* pc_relative */ 409 656 0, /* bitpos */ 410 657 complain_overflow_bitfield, /* complain_on_overflow */ 411 658 bfd_elf_generic_reloc, /* special_function */ 412 659 "R_PPC_GOT16_HI", /* name */ 413 false, /* partial_inplace */660 FALSE, /* partial_inplace */ 414 661 0, /* src_mask */ 415 662 0xffff, /* dst_mask */ 416 false), /* pcrel_offset */663 FALSE), /* pcrel_offset */ 417 664 418 665 /* Like R_PPC_ADDR16_HA, but referring to the GOT table entry for … … 422 669 1, /* size (0 = byte, 1 = short, 2 = long) */ 423 670 16, /* bitsize */ 424 false, /* pc_relative */671 FALSE, /* pc_relative */ 425 672 0, /* bitpos */ 426 673 complain_overflow_bitfield, /* complain_on_overflow */ 427 674 ppc_elf_addr16_ha_reloc, /* special_function */ 428 675 "R_PPC_GOT16_HA", /* name */ 429 false, /* partial_inplace */676 FALSE, /* partial_inplace */ 430 677 0, /* src_mask */ 431 678 0xffff, /* dst_mask */ 432 false), /* pcrel_offset */679 FALSE), /* pcrel_offset */ 433 680 434 681 /* Like R_PPC_REL24, but referring to the procedure linkage table … … 438 685 2, /* size (0 = byte, 1 = short, 2 = long) */ 439 686 26, /* bitsize */ 440 true, /* pc_relative */687 TRUE, /* pc_relative */ 441 688 0, /* bitpos */ 442 689 complain_overflow_signed, /* complain_on_overflow */ 443 690 bfd_elf_generic_reloc, /* special_function */ 444 691 "R_PPC_PLTREL24", /* name */ 445 false, /* partial_inplace */692 FALSE, /* partial_inplace */ 446 693 0, /* src_mask */ 447 694 0x3fffffc, /* dst_mask */ 448 true), /* pcrel_offset */695 TRUE), /* pcrel_offset */ 449 696 450 697 /* This is used only by the dynamic linker. The symbol should exist … … 457 704 2, /* size (0 = byte, 1 = short, 2 = long) */ 458 705 32, /* bitsize */ 459 false, /* pc_relative */706 FALSE, /* pc_relative */ 460 707 0, /* bitpos */ 461 708 complain_overflow_bitfield, /* complain_on_overflow */ 462 709 bfd_elf_generic_reloc, /* special_function */ 463 710 "R_PPC_COPY", /* name */ 464 false, /* partial_inplace */711 FALSE, /* partial_inplace */ 465 712 0, /* src_mask */ 466 713 0, /* dst_mask */ 467 false), /* pcrel_offset */714 FALSE), /* pcrel_offset */ 468 715 469 716 /* Like R_PPC_ADDR32, but used when setting global offset table … … 473 720 2, /* size (0 = byte, 1 = short, 2 = long) */ 474 721 32, /* bitsize */ 475 false, /* pc_relative */722 FALSE, /* pc_relative */ 476 723 0, /* bitpos */ 477 724 complain_overflow_bitfield, /* complain_on_overflow */ 478 725 bfd_elf_generic_reloc, /* special_function */ 479 726 "R_PPC_GLOB_DAT", /* name */ 480 false, /* partial_inplace */727 FALSE, /* partial_inplace */ 481 728 0, /* src_mask */ 482 729 0xffffffff, /* dst_mask */ 483 false), /* pcrel_offset */730 FALSE), /* pcrel_offset */ 484 731 485 732 /* Marks a procedure linkage table entry for a symbol. */ … … 488 735 2, /* size (0 = byte, 1 = short, 2 = long) */ 489 736 32, /* bitsize */ 490 false, /* pc_relative */737 FALSE, /* pc_relative */ 491 738 0, /* bitpos */ 492 739 complain_overflow_bitfield, /* complain_on_overflow */ 493 740 bfd_elf_generic_reloc, /* special_function */ 494 741 "R_PPC_JMP_SLOT", /* name */ 495 false, /* partial_inplace */742 FALSE, /* partial_inplace */ 496 743 0, /* src_mask */ 497 744 0, /* dst_mask */ 498 false), /* pcrel_offset */745 FALSE), /* pcrel_offset */ 499 746 500 747 /* Used only by the dynamic linker. When the object is run, this … … 505 752 2, /* size (0 = byte, 1 = short, 2 = long) */ 506 753 32, /* bitsize */ 507 false, /* pc_relative */754 FALSE, /* pc_relative */ 508 755 0, /* bitpos */ 509 756 complain_overflow_bitfield, /* complain_on_overflow */ 510 757 bfd_elf_generic_reloc, /* special_function */ 511 758 "R_PPC_RELATIVE", /* name */ 512 false, /* partial_inplace */759 FALSE, /* partial_inplace */ 513 760 0, /* src_mask */ 514 761 0xffffffff, /* dst_mask */ 515 false), /* pcrel_offset */762 FALSE), /* pcrel_offset */ 516 763 517 764 /* Like R_PPC_REL24, but uses the value of the symbol within the … … 522 769 2, /* size (0 = byte, 1 = short, 2 = long) */ 523 770 26, /* bitsize */ 524 true, /* pc_relative */771 TRUE, /* pc_relative */ 525 772 0, /* bitpos */ 526 773 complain_overflow_signed, /* complain_on_overflow */ 527 774 bfd_elf_generic_reloc, /* special_function */ 528 775 "R_PPC_LOCAL24PC", /* name */ 529 false, /* partial_inplace */776 FALSE, /* partial_inplace */ 530 777 0, /* src_mask */ 531 778 0x3fffffc, /* dst_mask */ 532 true), /* pcrel_offset */779 TRUE), /* pcrel_offset */ 533 780 534 781 /* Like R_PPC_ADDR32, but may be unaligned. */ … … 537 784 2, /* size (0 = byte, 1 = short, 2 = long) */ 538 785 32, /* bitsize */ 539 false, /* pc_relative */786 FALSE, /* pc_relative */ 540 787 0, /* bitpos */ 541 788 complain_overflow_bitfield, /* complain_on_overflow */ 542 789 bfd_elf_generic_reloc, /* special_function */ 543 790 "R_PPC_UADDR32", /* name */ 544 false, /* partial_inplace */791 FALSE, /* partial_inplace */ 545 792 0, /* src_mask */ 546 793 0xffffffff, /* dst_mask */ 547 false), /* pcrel_offset */794 FALSE), /* pcrel_offset */ 548 795 549 796 /* Like R_PPC_ADDR16, but may be unaligned. */ … … 552 799 1, /* size (0 = byte, 1 = short, 2 = long) */ 553 800 16, /* bitsize */ 554 false, /* pc_relative */801 FALSE, /* pc_relative */ 555 802 0, /* bitpos */ 556 803 complain_overflow_bitfield, /* complain_on_overflow */ 557 804 bfd_elf_generic_reloc, /* special_function */ 558 805 "R_PPC_UADDR16", /* name */ 559 false, /* partial_inplace */806 FALSE, /* partial_inplace */ 560 807 0, /* src_mask */ 561 808 0xffff, /* dst_mask */ 562 false), /* pcrel_offset */809 FALSE), /* pcrel_offset */ 563 810 564 811 /* 32-bit PC relative */ … … 567 814 2, /* size (0 = byte, 1 = short, 2 = long) */ 568 815 32, /* bitsize */ 569 true, /* pc_relative */816 TRUE, /* pc_relative */ 570 817 0, /* bitpos */ 571 818 complain_overflow_bitfield, /* complain_on_overflow */ 572 819 bfd_elf_generic_reloc, /* special_function */ 573 820 "R_PPC_REL32", /* name */ 574 false, /* partial_inplace */821 FALSE, /* partial_inplace */ 575 822 0, /* src_mask */ 576 823 0xffffffff, /* dst_mask */ 577 true), /* pcrel_offset */824 TRUE), /* pcrel_offset */ 578 825 579 826 /* 32-bit relocation to the symbol's procedure linkage table. … … 583 830 2, /* size (0 = byte, 1 = short, 2 = long) */ 584 831 32, /* bitsize */ 585 false, /* pc_relative */832 FALSE, /* pc_relative */ 586 833 0, /* bitpos */ 587 834 complain_overflow_bitfield, /* complain_on_overflow */ 588 835 bfd_elf_generic_reloc, /* special_function */ 589 836 "R_PPC_PLT32", /* name */ 590 false, /* partial_inplace */837 FALSE, /* partial_inplace */ 591 838 0, /* src_mask */ 592 839 0, /* dst_mask */ 593 false), /* pcrel_offset */840 FALSE), /* pcrel_offset */ 594 841 595 842 /* 32-bit PC relative relocation to the symbol's procedure linkage table. … … 599 846 2, /* size (0 = byte, 1 = short, 2 = long) */ 600 847 32, /* bitsize */ 601 true, /* pc_relative */848 TRUE, /* pc_relative */ 602 849 0, /* bitpos */ 603 850 complain_overflow_bitfield, /* complain_on_overflow */ 604 851 bfd_elf_generic_reloc, /* special_function */ 605 852 "R_PPC_PLTREL32", /* name */ 606 false, /* partial_inplace */853 FALSE, /* partial_inplace */ 607 854 0, /* src_mask */ 608 855 0, /* dst_mask */ 609 true), /* pcrel_offset */856 TRUE), /* pcrel_offset */ 610 857 611 858 /* Like R_PPC_ADDR16_LO, but referring to the PLT table entry for … … 615 862 1, /* size (0 = byte, 1 = short, 2 = long) */ 616 863 16, /* bitsize */ 617 false, /* pc_relative */864 FALSE, /* pc_relative */ 618 865 0, /* bitpos */ 619 866 complain_overflow_dont, /* complain_on_overflow */ 620 867 bfd_elf_generic_reloc, /* special_function */ 621 868 "R_PPC_PLT16_LO", /* name */ 622 false, /* partial_inplace */869 FALSE, /* partial_inplace */ 623 870 0, /* src_mask */ 624 871 0xffff, /* dst_mask */ 625 false), /* pcrel_offset */872 FALSE), /* pcrel_offset */ 626 873 627 874 /* Like R_PPC_ADDR16_HI, but referring to the PLT table entry for … … 631 878 1, /* size (0 = byte, 1 = short, 2 = long) */ 632 879 16, /* bitsize */ 633 false, /* pc_relative */880 FALSE, /* pc_relative */ 634 881 0, /* bitpos */ 635 882 complain_overflow_bitfield, /* complain_on_overflow */ 636 883 bfd_elf_generic_reloc, /* special_function */ 637 884 "R_PPC_PLT16_HI", /* name */ 638 false, /* partial_inplace */885 FALSE, /* partial_inplace */ 639 886 0, /* src_mask */ 640 887 0xffff, /* dst_mask */ 641 false), /* pcrel_offset */888 FALSE), /* pcrel_offset */ 642 889 643 890 /* Like R_PPC_ADDR16_HA, but referring to the PLT table entry for … … 647 894 1, /* size (0 = byte, 1 = short, 2 = long) */ 648 895 16, /* bitsize */ 649 false, /* pc_relative */896 FALSE, /* pc_relative */ 650 897 0, /* bitpos */ 651 898 complain_overflow_bitfield, /* complain_on_overflow */ 652 899 ppc_elf_addr16_ha_reloc, /* special_function */ 653 900 "R_PPC_PLT16_HA", /* name */ 654 false, /* partial_inplace */901 FALSE, /* partial_inplace */ 655 902 0, /* src_mask */ 656 903 0xffff, /* dst_mask */ 657 false), /* pcrel_offset */904 FALSE), /* pcrel_offset */ 658 905 659 906 /* A sign-extended 16 bit value relative to _SDA_BASE_, for use with … … 663 910 1, /* size (0 = byte, 1 = short, 2 = long) */ 664 911 16, /* bitsize */ 665 false, /* pc_relative */912 FALSE, /* pc_relative */ 666 913 0, /* bitpos */ 667 914 complain_overflow_signed, /* complain_on_overflow */ 668 915 bfd_elf_generic_reloc, /* special_function */ 669 916 "R_PPC_SDAREL16", /* name */ 670 false, /* partial_inplace */917 FALSE, /* partial_inplace */ 671 918 0, /* src_mask */ 672 919 0xffff, /* dst_mask */ 673 false), /* pcrel_offset */674 675 /* 32-bit section relative relocation. */920 FALSE), /* pcrel_offset */ 921 922 /* 16-bit section relative relocation. */ 676 923 HOWTO (R_PPC_SECTOFF, /* type */ 677 924 0, /* rightshift */ 678 2, /* size (0 = byte, 1 = short, 2 = long) */679 32, /* bitsize */680 true, /* pc_relative */925 1, /* size (0 = byte, 1 = short, 2 = long) */ 926 16, /* bitsize */ 927 FALSE, /* pc_relative */ 681 928 0, /* bitpos */ 682 929 complain_overflow_bitfield, /* complain_on_overflow */ 683 930 bfd_elf_generic_reloc, /* special_function */ 684 931 "R_PPC_SECTOFF", /* name */ 685 false, /* partial_inplace */686 0, /* src_mask */ 687 0 ,/* dst_mask */688 true),/* pcrel_offset */932 FALSE, /* partial_inplace */ 933 0, /* src_mask */ 934 0xffff, /* dst_mask */ 935 FALSE), /* pcrel_offset */ 689 936 690 937 /* 16-bit lower half section relative relocation. */ … … 693 940 1, /* size (0 = byte, 1 = short, 2 = long) */ 694 941 16, /* bitsize */ 695 false, /* pc_relative */942 FALSE, /* pc_relative */ 696 943 0, /* bitpos */ 697 944 complain_overflow_dont, /* complain_on_overflow */ 698 945 bfd_elf_generic_reloc, /* special_function */ 699 946 "R_PPC_SECTOFF_LO", /* name */ 700 false, /* partial_inplace */947 FALSE, /* partial_inplace */ 701 948 0, /* src_mask */ 702 949 0xffff, /* dst_mask */ 703 false), /* pcrel_offset */950 FALSE), /* pcrel_offset */ 704 951 705 952 /* 16-bit upper half section relative relocation. */ … … 708 955 1, /* size (0 = byte, 1 = short, 2 = long) */ 709 956 16, /* bitsize */ 710 false, /* pc_relative */957 FALSE, /* pc_relative */ 711 958 0, /* bitpos */ 712 959 complain_overflow_bitfield, /* complain_on_overflow */ 713 960 bfd_elf_generic_reloc, /* special_function */ 714 961 "R_PPC_SECTOFF_HI", /* name */ 715 false, /* partial_inplace */962 FALSE, /* partial_inplace */ 716 963 0, /* src_mask */ 717 964 0xffff, /* dst_mask */ 718 false), /* pcrel_offset */965 FALSE), /* pcrel_offset */ 719 966 720 967 /* 16-bit upper half adjusted section relative relocation. */ … … 723 970 1, /* size (0 = byte, 1 = short, 2 = long) */ 724 971 16, /* bitsize */ 725 false, /* pc_relative */972 FALSE, /* pc_relative */ 726 973 0, /* bitpos */ 727 974 complain_overflow_bitfield, /* complain_on_overflow */ 728 975 ppc_elf_addr16_ha_reloc, /* special_function */ 729 976 "R_PPC_SECTOFF_HA", /* name */ 730 false, /* partial_inplace */977 FALSE, /* partial_inplace */ 731 978 0, /* src_mask */ 732 979 0xffff, /* dst_mask */ 733 false), /* pcrel_offset */ 980 FALSE), /* pcrel_offset */ 981 982 /* Marker reloc for TLS. */ 983 HOWTO (R_PPC_TLS, 984 0, /* rightshift */ 985 2, /* size (0 = byte, 1 = short, 2 = long) */ 986 32, /* bitsize */ 987 FALSE, /* pc_relative */ 988 0, /* bitpos */ 989 complain_overflow_dont, /* complain_on_overflow */ 990 bfd_elf_generic_reloc, /* special_function */ 991 "R_PPC_TLS", /* name */ 992 FALSE, /* partial_inplace */ 993 0, /* src_mask */ 994 0, /* dst_mask */ 995 FALSE), /* pcrel_offset */ 996 997 /* Computes the load module index of the load module that contains the 998 definition of its TLS sym. */ 999 HOWTO (R_PPC_DTPMOD32, 1000 0, /* rightshift */ 1001 2, /* size (0 = byte, 1 = short, 2 = long) */ 1002 32, /* bitsize */ 1003 FALSE, /* pc_relative */ 1004 0, /* bitpos */ 1005 complain_overflow_dont, /* complain_on_overflow */ 1006 ppc_elf_unhandled_reloc, /* special_function */ 1007 "R_PPC_DTPMOD32", /* name */ 1008 FALSE, /* partial_inplace */ 1009 0, /* src_mask */ 1010 0xffffffff, /* dst_mask */ 1011 FALSE), /* pcrel_offset */ 1012 1013 /* Computes a dtv-relative displacement, the difference between the value 1014 of sym+add and the base address of the thread-local storage block that 1015 contains the definition of sym, minus 0x8000. */ 1016 HOWTO (R_PPC_DTPREL32, 1017 0, /* rightshift */ 1018 2, /* size (0 = byte, 1 = short, 2 = long) */ 1019 32, /* bitsize */ 1020 FALSE, /* pc_relative */ 1021 0, /* bitpos */ 1022 complain_overflow_dont, /* complain_on_overflow */ 1023 ppc_elf_unhandled_reloc, /* special_function */ 1024 "R_PPC_DTPREL32", /* name */ 1025 FALSE, /* partial_inplace */ 1026 0, /* src_mask */ 1027 0xffffffff, /* dst_mask */ 1028 FALSE), /* pcrel_offset */ 1029 1030 /* A 16 bit dtprel reloc. */ 1031 HOWTO (R_PPC_DTPREL16, 1032 0, /* rightshift */ 1033 1, /* size (0 = byte, 1 = short, 2 = long) */ 1034 16, /* bitsize */ 1035 FALSE, /* pc_relative */ 1036 0, /* bitpos */ 1037 complain_overflow_signed, /* complain_on_overflow */ 1038 ppc_elf_unhandled_reloc, /* special_function */ 1039 "R_PPC_DTPREL16", /* name */ 1040 FALSE, /* partial_inplace */ 1041 0, /* src_mask */ 1042 0xffff, /* dst_mask */ 1043 FALSE), /* pcrel_offset */ 1044 1045 /* Like DTPREL16, but no overflow. */ 1046 HOWTO (R_PPC_DTPREL16_LO, 1047 0, /* rightshift */ 1048 1, /* size (0 = byte, 1 = short, 2 = long) */ 1049 16, /* bitsize */ 1050 FALSE, /* pc_relative */ 1051 0, /* bitpos */ 1052 complain_overflow_dont, /* complain_on_overflow */ 1053 ppc_elf_unhandled_reloc, /* special_function */ 1054 "R_PPC_DTPREL16_LO", /* name */ 1055 FALSE, /* partial_inplace */ 1056 0, /* src_mask */ 1057 0xffff, /* dst_mask */ 1058 FALSE), /* pcrel_offset */ 1059 1060 /* Like DTPREL16_LO, but next higher group of 16 bits. */ 1061 HOWTO (R_PPC_DTPREL16_HI, 1062 16, /* rightshift */ 1063 1, /* size (0 = byte, 1 = short, 2 = long) */ 1064 16, /* bitsize */ 1065 FALSE, /* pc_relative */ 1066 0, /* bitpos */ 1067 complain_overflow_dont, /* complain_on_overflow */ 1068 ppc_elf_unhandled_reloc, /* special_function */ 1069 "R_PPC_DTPREL16_HI", /* name */ 1070 FALSE, /* partial_inplace */ 1071 0, /* src_mask */ 1072 0xffff, /* dst_mask */ 1073 FALSE), /* pcrel_offset */ 1074 1075 /* Like DTPREL16_HI, but adjust for low 16 bits. */ 1076 HOWTO (R_PPC_DTPREL16_HA, 1077 16, /* rightshift */ 1078 1, /* size (0 = byte, 1 = short, 2 = long) */ 1079 16, /* bitsize */ 1080 FALSE, /* pc_relative */ 1081 0, /* bitpos */ 1082 complain_overflow_dont, /* complain_on_overflow */ 1083 ppc_elf_unhandled_reloc, /* special_function */ 1084 "R_PPC_DTPREL16_HA", /* name */ 1085 FALSE, /* partial_inplace */ 1086 0, /* src_mask */ 1087 0xffff, /* dst_mask */ 1088 FALSE), /* pcrel_offset */ 1089 1090 /* Computes a tp-relative displacement, the difference between the value of 1091 sym+add and the value of the thread pointer (r13). */ 1092 HOWTO (R_PPC_TPREL32, 1093 0, /* rightshift */ 1094 2, /* size (0 = byte, 1 = short, 2 = long) */ 1095 32, /* bitsize */ 1096 FALSE, /* pc_relative */ 1097 0, /* bitpos */ 1098 complain_overflow_dont, /* complain_on_overflow */ 1099 ppc_elf_unhandled_reloc, /* special_function */ 1100 "R_PPC_TPREL32", /* name */ 1101 FALSE, /* partial_inplace */ 1102 0, /* src_mask */ 1103 0xffffffff, /* dst_mask */ 1104 FALSE), /* pcrel_offset */ 1105 1106 /* A 16 bit tprel reloc. */ 1107 HOWTO (R_PPC_TPREL16, 1108 0, /* rightshift */ 1109 1, /* size (0 = byte, 1 = short, 2 = long) */ 1110 16, /* bitsize */ 1111 FALSE, /* pc_relative */ 1112 0, /* bitpos */ 1113 complain_overflow_signed, /* complain_on_overflow */ 1114 ppc_elf_unhandled_reloc, /* special_function */ 1115 "R_PPC_TPREL16", /* name */ 1116 FALSE, /* partial_inplace */ 1117 0, /* src_mask */ 1118 0xffff, /* dst_mask */ 1119 FALSE), /* pcrel_offset */ 1120 1121 /* Like TPREL16, but no overflow. */ 1122 HOWTO (R_PPC_TPREL16_LO, 1123 0, /* rightshift */ 1124 1, /* size (0 = byte, 1 = short, 2 = long) */ 1125 16, /* bitsize */ 1126 FALSE, /* pc_relative */ 1127 0, /* bitpos */ 1128 complain_overflow_dont, /* complain_on_overflow */ 1129 ppc_elf_unhandled_reloc, /* special_function */ 1130 "R_PPC_TPREL16_LO", /* name */ 1131 FALSE, /* partial_inplace */ 1132 0, /* src_mask */ 1133 0xffff, /* dst_mask */ 1134 FALSE), /* pcrel_offset */ 1135 1136 /* Like TPREL16_LO, but next higher group of 16 bits. */ 1137 HOWTO (R_PPC_TPREL16_HI, 1138 16, /* rightshift */ 1139 1, /* size (0 = byte, 1 = short, 2 = long) */ 1140 16, /* bitsize */ 1141 FALSE, /* pc_relative */ 1142 0, /* bitpos */ 1143 complain_overflow_dont, /* complain_on_overflow */ 1144 ppc_elf_unhandled_reloc, /* special_function */ 1145 "R_PPC_TPREL16_HI", /* name */ 1146 FALSE, /* partial_inplace */ 1147 0, /* src_mask */ 1148 0xffff, /* dst_mask */ 1149 FALSE), /* pcrel_offset */ 1150 1151 /* Like TPREL16_HI, but adjust for low 16 bits. */ 1152 HOWTO (R_PPC_TPREL16_HA, 1153 16, /* rightshift */ 1154 1, /* size (0 = byte, 1 = short, 2 = long) */ 1155 16, /* bitsize */ 1156 FALSE, /* pc_relative */ 1157 0, /* bitpos */ 1158 complain_overflow_dont, /* complain_on_overflow */ 1159 ppc_elf_unhandled_reloc, /* special_function */ 1160 "R_PPC_TPREL16_HA", /* name */ 1161 FALSE, /* partial_inplace */ 1162 0, /* src_mask */ 1163 0xffff, /* dst_mask */ 1164 FALSE), /* pcrel_offset */ 1165 1166 /* Allocates two contiguous entries in the GOT to hold a tls_index structure, 1167 with values (sym+add)@dtpmod and (sym+add)@dtprel, and computes the offset 1168 to the first entry. */ 1169 HOWTO (R_PPC_GOT_TLSGD16, 1170 0, /* rightshift */ 1171 1, /* size (0 = byte, 1 = short, 2 = long) */ 1172 16, /* bitsize */ 1173 FALSE, /* pc_relative */ 1174 0, /* bitpos */ 1175 complain_overflow_signed, /* complain_on_overflow */ 1176 ppc_elf_unhandled_reloc, /* special_function */ 1177 "R_PPC_GOT_TLSGD16", /* name */ 1178 FALSE, /* partial_inplace */ 1179 0, /* src_mask */ 1180 0xffff, /* dst_mask */ 1181 FALSE), /* pcrel_offset */ 1182 1183 /* Like GOT_TLSGD16, but no overflow. */ 1184 HOWTO (R_PPC_GOT_TLSGD16_LO, 1185 0, /* rightshift */ 1186 1, /* size (0 = byte, 1 = short, 2 = long) */ 1187 16, /* bitsize */ 1188 FALSE, /* pc_relative */ 1189 0, /* bitpos */ 1190 complain_overflow_dont, /* complain_on_overflow */ 1191 ppc_elf_unhandled_reloc, /* special_function */ 1192 "R_PPC_GOT_TLSGD16_LO", /* name */ 1193 FALSE, /* partial_inplace */ 1194 0, /* src_mask */ 1195 0xffff, /* dst_mask */ 1196 FALSE), /* pcrel_offset */ 1197 1198 /* Like GOT_TLSGD16_LO, but next higher group of 16 bits. */ 1199 HOWTO (R_PPC_GOT_TLSGD16_HI, 1200 16, /* rightshift */ 1201 1, /* size (0 = byte, 1 = short, 2 = long) */ 1202 16, /* bitsize */ 1203 FALSE, /* pc_relative */ 1204 0, /* bitpos */ 1205 complain_overflow_dont, /* complain_on_overflow */ 1206 ppc_elf_unhandled_reloc, /* special_function */ 1207 "R_PPC_GOT_TLSGD16_HI", /* name */ 1208 FALSE, /* partial_inplace */ 1209 0, /* src_mask */ 1210 0xffff, /* dst_mask */ 1211 FALSE), /* pcrel_offset */ 1212 1213 /* Like GOT_TLSGD16_HI, but adjust for low 16 bits. */ 1214 HOWTO (R_PPC_GOT_TLSGD16_HA, 1215 16, /* rightshift */ 1216 1, /* size (0 = byte, 1 = short, 2 = long) */ 1217 16, /* bitsize */ 1218 FALSE, /* pc_relative */ 1219 0, /* bitpos */ 1220 complain_overflow_dont, /* complain_on_overflow */ 1221 ppc_elf_unhandled_reloc, /* special_function */ 1222 "R_PPC_GOT_TLSGD16_HA", /* name */ 1223 FALSE, /* partial_inplace */ 1224 0, /* src_mask */ 1225 0xffff, /* dst_mask */ 1226 FALSE), /* pcrel_offset */ 1227 1228 /* Allocates two contiguous entries in the GOT to hold a tls_index structure, 1229 with values (sym+add)@dtpmod and zero, and computes the offset to the 1230 first entry. */ 1231 HOWTO (R_PPC_GOT_TLSLD16, 1232 0, /* rightshift */ 1233 1, /* size (0 = byte, 1 = short, 2 = long) */ 1234 16, /* bitsize */ 1235 FALSE, /* pc_relative */ 1236 0, /* bitpos */ 1237 complain_overflow_signed, /* complain_on_overflow */ 1238 ppc_elf_unhandled_reloc, /* special_function */ 1239 "R_PPC_GOT_TLSLD16", /* name */ 1240 FALSE, /* partial_inplace */ 1241 0, /* src_mask */ 1242 0xffff, /* dst_mask */ 1243 FALSE), /* pcrel_offset */ 1244 1245 /* Like GOT_TLSLD16, but no overflow. */ 1246 HOWTO (R_PPC_GOT_TLSLD16_LO, 1247 0, /* rightshift */ 1248 1, /* size (0 = byte, 1 = short, 2 = long) */ 1249 16, /* bitsize */ 1250 FALSE, /* pc_relative */ 1251 0, /* bitpos */ 1252 complain_overflow_dont, /* complain_on_overflow */ 1253 ppc_elf_unhandled_reloc, /* special_function */ 1254 "R_PPC_GOT_TLSLD16_LO", /* name */ 1255 FALSE, /* partial_inplace */ 1256 0, /* src_mask */ 1257 0xffff, /* dst_mask */ 1258 FALSE), /* pcrel_offset */ 1259 1260 /* Like GOT_TLSLD16_LO, but next higher group of 16 bits. */ 1261 HOWTO (R_PPC_GOT_TLSLD16_HI, 1262 16, /* rightshift */ 1263 1, /* size (0 = byte, 1 = short, 2 = long) */ 1264 16, /* bitsize */ 1265 FALSE, /* pc_relative */ 1266 0, /* bitpos */ 1267 complain_overflow_dont, /* complain_on_overflow */ 1268 ppc_elf_unhandled_reloc, /* special_function */ 1269 "R_PPC_GOT_TLSLD16_HI", /* name */ 1270 FALSE, /* partial_inplace */ 1271 0, /* src_mask */ 1272 0xffff, /* dst_mask */ 1273 FALSE), /* pcrel_offset */ 1274 1275 /* Like GOT_TLSLD16_HI, but adjust for low 16 bits. */ 1276 HOWTO (R_PPC_GOT_TLSLD16_HA, 1277 16, /* rightshift */ 1278 1, /* size (0 = byte, 1 = short, 2 = long) */ 1279 16, /* bitsize */ 1280 FALSE, /* pc_relative */ 1281 0, /* bitpos */ 1282 complain_overflow_dont, /* complain_on_overflow */ 1283 ppc_elf_unhandled_reloc, /* special_function */ 1284 "R_PPC_GOT_TLSLD16_HA", /* name */ 1285 FALSE, /* partial_inplace */ 1286 0, /* src_mask */ 1287 0xffff, /* dst_mask */ 1288 FALSE), /* pcrel_offset */ 1289 1290 /* Allocates an entry in the GOT with value (sym+add)@dtprel, and computes 1291 the offset to the entry. */ 1292 HOWTO (R_PPC_GOT_DTPREL16, 1293 0, /* rightshift */ 1294 1, /* size (0 = byte, 1 = short, 2 = long) */ 1295 16, /* bitsize */ 1296 FALSE, /* pc_relative */ 1297 0, /* bitpos */ 1298 complain_overflow_signed, /* complain_on_overflow */ 1299 ppc_elf_unhandled_reloc, /* special_function */ 1300 "R_PPC_GOT_DTPREL16", /* name */ 1301 FALSE, /* partial_inplace */ 1302 0, /* src_mask */ 1303 0xffff, /* dst_mask */ 1304 FALSE), /* pcrel_offset */ 1305 1306 /* Like GOT_DTPREL16, but no overflow. */ 1307 HOWTO (R_PPC_GOT_DTPREL16_LO, 1308 0, /* rightshift */ 1309 1, /* size (0 = byte, 1 = short, 2 = long) */ 1310 16, /* bitsize */ 1311 FALSE, /* pc_relative */ 1312 0, /* bitpos */ 1313 complain_overflow_dont, /* complain_on_overflow */ 1314 ppc_elf_unhandled_reloc, /* special_function */ 1315 "R_PPC_GOT_DTPREL16_LO", /* name */ 1316 FALSE, /* partial_inplace */ 1317 0, /* src_mask */ 1318 0xffff, /* dst_mask */ 1319 FALSE), /* pcrel_offset */ 1320 1321 /* Like GOT_DTPREL16_LO, but next higher group of 16 bits. */ 1322 HOWTO (R_PPC_GOT_DTPREL16_HI, 1323 16, /* rightshift */ 1324 1, /* size (0 = byte, 1 = short, 2 = long) */ 1325 16, /* bitsize */ 1326 FALSE, /* pc_relative */ 1327 0, /* bitpos */ 1328 complain_overflow_dont, /* complain_on_overflow */ 1329 ppc_elf_unhandled_reloc, /* special_function */ 1330 "R_PPC_GOT_DTPREL16_HI", /* name */ 1331 FALSE, /* partial_inplace */ 1332 0, /* src_mask */ 1333 0xffff, /* dst_mask */ 1334 FALSE), /* pcrel_offset */ 1335 1336 /* Like GOT_DTPREL16_HI, but adjust for low 16 bits. */ 1337 HOWTO (R_PPC_GOT_DTPREL16_HA, 1338 16, /* rightshift */ 1339 1, /* size (0 = byte, 1 = short, 2 = long) */ 1340 16, /* bitsize */ 1341 FALSE, /* pc_relative */ 1342 0, /* bitpos */ 1343 complain_overflow_dont, /* complain_on_overflow */ 1344 ppc_elf_unhandled_reloc, /* special_function */ 1345 "R_PPC_GOT_DTPREL16_HA", /* name */ 1346 FALSE, /* partial_inplace */ 1347 0, /* src_mask */ 1348 0xffff, /* dst_mask */ 1349 FALSE), /* pcrel_offset */ 1350 1351 /* Allocates an entry in the GOT with value (sym+add)@tprel, and computes the 1352 offset to the entry. */ 1353 HOWTO (R_PPC_GOT_TPREL16, 1354 0, /* rightshift */ 1355 1, /* size (0 = byte, 1 = short, 2 = long) */ 1356 16, /* bitsize */ 1357 FALSE, /* pc_relative */ 1358 0, /* bitpos */ 1359 complain_overflow_signed, /* complain_on_overflow */ 1360 ppc_elf_unhandled_reloc, /* special_function */ 1361 "R_PPC_GOT_TPREL16", /* name */ 1362 FALSE, /* partial_inplace */ 1363 0, /* src_mask */ 1364 0xffff, /* dst_mask */ 1365 FALSE), /* pcrel_offset */ 1366 1367 /* Like GOT_TPREL16, but no overflow. */ 1368 HOWTO (R_PPC_GOT_TPREL16_LO, 1369 0, /* rightshift */ 1370 1, /* size (0 = byte, 1 = short, 2 = long) */ 1371 16, /* bitsize */ 1372 FALSE, /* pc_relative */ 1373 0, /* bitpos */ 1374 complain_overflow_dont, /* complain_on_overflow */ 1375 ppc_elf_unhandled_reloc, /* special_function */ 1376 "R_PPC_GOT_TPREL16_LO", /* name */ 1377 FALSE, /* partial_inplace */ 1378 0, /* src_mask */ 1379 0xffff, /* dst_mask */ 1380 FALSE), /* pcrel_offset */ 1381 1382 /* Like GOT_TPREL16_LO, but next higher group of 16 bits. */ 1383 HOWTO (R_PPC_GOT_TPREL16_HI, 1384 16, /* rightshift */ 1385 1, /* size (0 = byte, 1 = short, 2 = long) */ 1386 16, /* bitsize */ 1387 FALSE, /* pc_relative */ 1388 0, /* bitpos */ 1389 complain_overflow_dont, /* complain_on_overflow */ 1390 ppc_elf_unhandled_reloc, /* special_function */ 1391 "R_PPC_GOT_TPREL16_HI", /* name */ 1392 FALSE, /* partial_inplace */ 1393 0, /* src_mask */ 1394 0xffff, /* dst_mask */ 1395 FALSE), /* pcrel_offset */ 1396 1397 /* Like GOT_TPREL16_HI, but adjust for low 16 bits. */ 1398 HOWTO (R_PPC_GOT_TPREL16_HA, 1399 16, /* rightshift */ 1400 1, /* size (0 = byte, 1 = short, 2 = long) */ 1401 16, /* bitsize */ 1402 FALSE, /* pc_relative */ 1403 0, /* bitpos */ 1404 complain_overflow_dont, /* complain_on_overflow */ 1405 ppc_elf_unhandled_reloc, /* special_function */ 1406 "R_PPC_GOT_TPREL16_HA", /* name */ 1407 FALSE, /* partial_inplace */ 1408 0, /* src_mask */ 1409 0xffff, /* dst_mask */ 1410 FALSE), /* pcrel_offset */ 734 1411 735 1412 /* The remaining relocs are from the Embedded ELF ABI, and are not 736 1413 in the SVR4 ELF ABI. */ 737 1414 738 /* 32 bit value resulting from the addend minus the symbol */1415 /* 32 bit value resulting from the addend minus the symbol. */ 739 1416 HOWTO (R_PPC_EMB_NADDR32, /* type */ 740 1417 0, /* rightshift */ 741 1418 2, /* size (0 = byte, 1 = short, 2 = long) */ 742 1419 32, /* bitsize */ 743 false, /* pc_relative */1420 FALSE, /* pc_relative */ 744 1421 0, /* bitpos */ 745 1422 complain_overflow_bitfield, /* complain_on_overflow */ 746 1423 bfd_elf_generic_reloc, /* special_function */ 747 1424 "R_PPC_EMB_NADDR32", /* name */ 748 false, /* partial_inplace */1425 FALSE, /* partial_inplace */ 749 1426 0, /* src_mask */ 750 1427 0xffffffff, /* dst_mask */ 751 false), /* pcrel_offset */752 753 /* 16 bit value resulting from the addend minus the symbol */1428 FALSE), /* pcrel_offset */ 1429 1430 /* 16 bit value resulting from the addend minus the symbol. */ 754 1431 HOWTO (R_PPC_EMB_NADDR16, /* type */ 755 1432 0, /* rightshift */ 756 1433 1, /* size (0 = byte, 1 = short, 2 = long) */ 757 1434 16, /* bitsize */ 758 false, /* pc_relative */1435 FALSE, /* pc_relative */ 759 1436 0, /* bitpos */ 760 1437 complain_overflow_bitfield, /* complain_on_overflow */ 761 1438 bfd_elf_generic_reloc, /* special_function */ 762 1439 "R_PPC_EMB_NADDR16", /* name */ 763 false, /* partial_inplace */1440 FALSE, /* partial_inplace */ 764 1441 0, /* src_mask */ 765 1442 0xffff, /* dst_mask */ 766 false), /* pcrel_offset */767 768 /* 16 bit value resulting from the addend minus the symbol */1443 FALSE), /* pcrel_offset */ 1444 1445 /* 16 bit value resulting from the addend minus the symbol. */ 769 1446 HOWTO (R_PPC_EMB_NADDR16_LO, /* type */ 770 1447 0, /* rightshift */ 771 1448 1, /* size (0 = byte, 1 = short, 2 = long) */ 772 1449 16, /* bitsize */ 773 false, /* pc_relative */1450 FALSE, /* pc_relative */ 774 1451 0, /* bitpos */ 775 1452 complain_overflow_dont,/* complain_on_overflow */ 776 1453 bfd_elf_generic_reloc, /* special_function */ 777 1454 "R_PPC_EMB_ADDR16_LO", /* name */ 778 false, /* partial_inplace */1455 FALSE, /* partial_inplace */ 779 1456 0, /* src_mask */ 780 1457 0xffff, /* dst_mask */ 781 false), /* pcrel_offset */782 783 /* The high order 16 bits of the addend minus the symbol */1458 FALSE), /* pcrel_offset */ 1459 1460 /* The high order 16 bits of the addend minus the symbol. */ 784 1461 HOWTO (R_PPC_EMB_NADDR16_HI, /* type */ 785 1462 16, /* rightshift */ 786 1463 1, /* size (0 = byte, 1 = short, 2 = long) */ 787 1464 16, /* bitsize */ 788 false, /* pc_relative */1465 FALSE, /* pc_relative */ 789 1466 0, /* bitpos */ 790 1467 complain_overflow_dont, /* complain_on_overflow */ 791 1468 bfd_elf_generic_reloc, /* special_function */ 792 1469 "R_PPC_EMB_NADDR16_HI", /* name */ 793 false, /* partial_inplace */1470 FALSE, /* partial_inplace */ 794 1471 0, /* src_mask */ 795 1472 0xffff, /* dst_mask */ 796 false), /* pcrel_offset */1473 FALSE), /* pcrel_offset */ 797 1474 798 1475 /* The high order 16 bits of the result of the addend minus the address, … … 803 1480 1, /* size (0 = byte, 1 = short, 2 = long) */ 804 1481 16, /* bitsize */ 805 false, /* pc_relative */1482 FALSE, /* pc_relative */ 806 1483 0, /* bitpos */ 807 1484 complain_overflow_dont, /* complain_on_overflow */ 808 1485 ppc_elf_addr16_ha_reloc, /* special_function */ 809 1486 "R_PPC_EMB_NADDR16_HA", /* name */ 810 false, /* partial_inplace */1487 FALSE, /* partial_inplace */ 811 1488 0, /* src_mask */ 812 1489 0xffff, /* dst_mask */ 813 false), /* pcrel_offset */1490 FALSE), /* pcrel_offset */ 814 1491 815 1492 /* 16 bit value resulting from allocating a 4 byte word to hold an 816 1493 address in the .sdata section, and returning the offset from 817 _SDA_BASE_ for that relocation */1494 _SDA_BASE_ for that relocation. */ 818 1495 HOWTO (R_PPC_EMB_SDAI16, /* type */ 819 1496 0, /* rightshift */ 820 1497 1, /* size (0 = byte, 1 = short, 2 = long) */ 821 1498 16, /* bitsize */ 822 false, /* pc_relative */1499 FALSE, /* pc_relative */ 823 1500 0, /* bitpos */ 824 1501 complain_overflow_bitfield, /* complain_on_overflow */ 825 1502 bfd_elf_generic_reloc, /* special_function */ 826 1503 "R_PPC_EMB_SDAI16", /* name */ 827 false, /* partial_inplace */1504 FALSE, /* partial_inplace */ 828 1505 0, /* src_mask */ 829 1506 0xffff, /* dst_mask */ 830 false), /* pcrel_offset */1507 FALSE), /* pcrel_offset */ 831 1508 832 1509 /* 16 bit value resulting from allocating a 4 byte word to hold an 833 1510 address in the .sdata2 section, and returning the offset from 834 _SDA2_BASE_ for that relocation */1511 _SDA2_BASE_ for that relocation. */ 835 1512 HOWTO (R_PPC_EMB_SDA2I16, /* type */ 836 1513 0, /* rightshift */ 837 1514 1, /* size (0 = byte, 1 = short, 2 = long) */ 838 1515 16, /* bitsize */ 839 false, /* pc_relative */1516 FALSE, /* pc_relative */ 840 1517 0, /* bitpos */ 841 1518 complain_overflow_bitfield, /* complain_on_overflow */ 842 1519 bfd_elf_generic_reloc, /* special_function */ 843 1520 "R_PPC_EMB_SDA2I16", /* name */ 844 false, /* partial_inplace */1521 FALSE, /* partial_inplace */ 845 1522 0, /* src_mask */ 846 1523 0xffff, /* dst_mask */ 847 false), /* pcrel_offset */1524 FALSE), /* pcrel_offset */ 848 1525 849 1526 /* A sign-extended 16 bit value relative to _SDA2_BASE_, for use with … … 853 1530 1, /* size (0 = byte, 1 = short, 2 = long) */ 854 1531 16, /* bitsize */ 855 false, /* pc_relative */1532 FALSE, /* pc_relative */ 856 1533 0, /* bitpos */ 857 1534 complain_overflow_signed, /* complain_on_overflow */ 858 1535 bfd_elf_generic_reloc, /* special_function */ 859 1536 "R_PPC_EMB_SDA2REL", /* name */ 860 false, /* partial_inplace */1537 FALSE, /* partial_inplace */ 861 1538 0, /* src_mask */ 862 1539 0xffff, /* dst_mask */ 863 false), /* pcrel_offset */1540 FALSE), /* pcrel_offset */ 864 1541 865 1542 /* Relocate against either _SDA_BASE_ or _SDA2_BASE_, filling in the 16 bit … … 870 1547 2, /* size (0 = byte, 1 = short, 2 = long) */ 871 1548 16, /* bitsize */ 872 false, /* pc_relative */1549 FALSE, /* pc_relative */ 873 1550 0, /* bitpos */ 874 1551 complain_overflow_signed, /* complain_on_overflow */ 875 1552 bfd_elf_generic_reloc, /* special_function */ 876 1553 "R_PPC_EMB_SDA21", /* name */ 877 false, /* partial_inplace */1554 FALSE, /* partial_inplace */ 878 1555 0, /* src_mask */ 879 1556 0xffff, /* dst_mask */ 880 false), /* pcrel_offset */1557 FALSE), /* pcrel_offset */ 881 1558 882 1559 /* Relocation not handled: R_PPC_EMB_MRKREF */ … … 894 1571 1, /* size (0 = byte, 1 = short, 2 = long) */ 895 1572 16, /* bitsize */ 896 true, /* pc_relative */1573 TRUE, /* pc_relative */ 897 1574 0, /* bitpos */ 898 1575 complain_overflow_signed, /* complain_on_overflow */ 899 1576 bfd_elf_generic_reloc, /* special_function */ 900 1577 "R_PPC_EMB_RELSDA", /* name */ 901 false, /* partial_inplace */1578 FALSE, /* partial_inplace */ 902 1579 0, /* src_mask */ 903 1580 0xffff, /* dst_mask */ 904 false), /* pcrel_offset */905 906 /* GNU extension to record C++ vtable hierarchy */1581 FALSE), /* pcrel_offset */ 1582 1583 /* GNU extension to record C++ vtable hierarchy. */ 907 1584 HOWTO (R_PPC_GNU_VTINHERIT, /* type */ 908 1585 0, /* rightshift */ 909 1586 0, /* size (0 = byte, 1 = short, 2 = long) */ 910 1587 0, /* bitsize */ 911 false, /* pc_relative */1588 FALSE, /* pc_relative */ 912 1589 0, /* bitpos */ 913 1590 complain_overflow_dont, /* complain_on_overflow */ 914 1591 NULL, /* special_function */ 915 1592 "R_PPC_GNU_VTINHERIT", /* name */ 916 false, /* partial_inplace */1593 FALSE, /* partial_inplace */ 917 1594 0, /* src_mask */ 918 1595 0, /* dst_mask */ 919 false), /* pcrel_offset */920 921 /* GNU extension to record C++ vtable member usage */1596 FALSE), /* pcrel_offset */ 1597 1598 /* GNU extension to record C++ vtable member usage. */ 922 1599 HOWTO (R_PPC_GNU_VTENTRY, /* type */ 923 1600 0, /* rightshift */ 924 1601 0, /* size (0 = byte, 1 = short, 2 = long) */ 925 1602 0, /* bitsize */ 926 false, /* pc_relative */1603 FALSE, /* pc_relative */ 927 1604 0, /* bitpos */ 928 1605 complain_overflow_dont, /* complain_on_overflow */ 929 1606 NULL, /* special_function */ 930 1607 "R_PPC_GNU_VTENTRY", /* name */ 931 false, /* partial_inplace */1608 FALSE, /* partial_inplace */ 932 1609 0, /* src_mask */ 933 1610 0, /* dst_mask */ 934 false), /* pcrel_offset */935 936 /* Phony reloc to handle AIX style TOC entries */1611 FALSE), /* pcrel_offset */ 1612 1613 /* Phony reloc to handle AIX style TOC entries. */ 937 1614 HOWTO (R_PPC_TOC16, /* type */ 938 1615 0, /* rightshift */ 939 1616 1, /* size (0 = byte, 1 = short, 2 = long) */ 940 1617 16, /* bitsize */ 941 false, /* pc_relative */1618 FALSE, /* pc_relative */ 942 1619 0, /* bitpos */ 943 1620 complain_overflow_signed, /* complain_on_overflow */ 944 1621 bfd_elf_generic_reloc, /* special_function */ 945 1622 "R_PPC_TOC16", /* name */ 946 false, /* partial_inplace */1623 FALSE, /* partial_inplace */ 947 1624 0, /* src_mask */ 948 1625 0xffff, /* dst_mask */ 949 false), /* pcrel_offset */1626 FALSE), /* pcrel_offset */ 950 1627 }; 951 1628 … … 958 1635 unsigned int i, type; 959 1636 960 for (i = 0; i < sizeof (ppc_elf_howto_raw) / sizeof (ppc_elf_howto_raw[0]); i++) 1637 for (i = 0; 1638 i < sizeof (ppc_elf_howto_raw) / sizeof (ppc_elf_howto_raw[0]); 1639 i++) 961 1640 { 962 1641 type = ppc_elf_howto_raw[i].type; 963 BFD_ASSERT (type < sizeof (ppc_elf_howto_table) / sizeof (ppc_elf_howto_table[0])); 1642 if (type >= (sizeof (ppc_elf_howto_table) 1643 / sizeof (ppc_elf_howto_table[0]))) 1644 abort (); 964 1645 ppc_elf_howto_table[type] = &ppc_elf_howto_raw[i]; 965 1646 } … … 976 1657 3/ The branch is taken. 977 1658 4/ The branch is located in the last 5 words of a page. 978 (The EOP limit is 5 by default but may be specified as any value from 1-10.) 1659 (The EOP limit is 5 by default but may be specified as any value 1660 from 1-10.) 979 1661 980 1662 Our software solution is to detect these problematic branches in a … … 986 1668 bit" is set (ensure it is predicted taken). 987 1669 4/ Conditional register branches - Ensure that the "y bit" is set 988 (ensure it is predicted taken). 989 */ 1670 (ensure it is predicted taken). */ 990 1671 991 1672 /* Sort sections by address. */ … … 993 1674 static int 994 1675 ppc_elf_sort_rela (arg1, arg2) 995 const void *arg1;996 const void *arg2;1676 const PTR arg1; 1677 const PTR arg2; 997 1678 { 998 1679 const Elf_Internal_Rela **rela1 = (const Elf_Internal_Rela**) arg1; … … 1003 1684 } 1004 1685 1005 static b oolean1686 static bfd_boolean 1006 1687 ppc_elf_relax_section (abfd, isec, link_info, again) 1007 1688 bfd *abfd; 1008 1689 asection *isec; 1009 1690 struct bfd_link_info *link_info; 1010 b oolean *again;1691 bfd_boolean *again; 1011 1692 { 1012 1693 #define PAGESIZE 0x1000 … … 1020 1701 1021 1702 /* We never have to do this more than once per input section. */ 1022 *again = false;1703 *again = FALSE; 1023 1704 1024 1705 /* If needed, initialize this section's cooked size. */ 1025 1706 if (isec->_cooked_size == 0) 1026 1707 isec->_cooked_size = isec->_raw_size; 1027 1708 1028 1709 /* We're only interested in text sections which overlap the … … 1031 1712 { 1032 1713 bfd_vma dot, end_page, end_section; 1033 b oolean section_modified;1714 bfd_boolean section_modified; 1034 1715 1035 1716 /* Get the section contents. */ 1036 1717 /* Get cached copy if it exists. */ 1037 1718 if (elf_section_data (isec)->this_hdr.contents != NULL) 1038 1719 contents = elf_section_data (isec)->this_hdr.contents; 1039 1720 else 1040 1721 { … … 1054 1735 if (isec->reloc_count) 1055 1736 { 1056 unsigned n; 1057 1058 /* Get a copy of the native relocations. */ 1059 internal_relocs = _bfd_elf32_link_read_relocs ( 1060 abfd, isec, (PTR) NULL, (Elf_Internal_Rela *) NULL, 1061 link_info->keep_memory); 1062 if (internal_relocs == NULL) 1063 goto error_return; 1064 if (! link_info->keep_memory) 1065 free_relocs = internal_relocs; 1066 1067 /* Setup a faster access method for the reloc info we need. */ 1068 rela_comb = (Elf_Internal_Rela**) 1069 bfd_malloc (isec->reloc_count*sizeof (Elf_Internal_Rela*)); 1070 if (rela_comb == NULL) 1071 goto error_return; 1072 for (n = 0; n < isec->reloc_count; ++n) 1073 { 1074 long r_type; 1075 1076 r_type = ELF32_R_TYPE (internal_relocs[n].r_info); 1077 if (r_type < 0 || r_type >= (int) R_PPC_max) 1078 goto error_return; 1079 1080 /* Prologue constants are sometimes present in the ".text" 1081 sections and they can be identified by their associated relocation. 1082 We don't want to process those words and some others which 1083 can also be identified by their relocations. However, not all 1084 conditional branches will have a relocation so we will 1085 only ignore words that 1) have a reloc, and 2) the reloc 1086 is not applicable to a conditional branch. 1087 The array rela_comb is built here for use in the EOP scan loop. */ 1088 switch (r_type) 1089 { 1090 case R_PPC_ADDR14_BRNTAKEN: /* absolute, predicted not taken */ 1091 case R_PPC_REL14: /* relative cond. br. */ 1092 case R_PPC_REL14_BRNTAKEN: /* rel. cond. br., predicted not taken */ 1093 /* We should check the instruction. */ 1094 break; 1095 default: 1096 /* The word is not a conditional branch - ignore it. */ 1097 rela_comb[comb_count++] = &internal_relocs[n]; 1098 break; 1099 } 1100 } 1101 if (comb_count > 1) 1102 qsort (rela_comb, (size_t) comb_count, sizeof (int), ppc_elf_sort_rela); 1737 unsigned n; 1738 bfd_size_type amt; 1739 1740 /* Get a copy of the native relocations. */ 1741 internal_relocs 1742 = _bfd_elf32_link_read_relocs (abfd, isec, (PTR) NULL, 1743 (Elf_Internal_Rela *) NULL, 1744 link_info->keep_memory); 1745 if (internal_relocs == NULL) 1746 goto error_return; 1747 if (! link_info->keep_memory) 1748 free_relocs = internal_relocs; 1749 1750 /* Setup a faster access method for the reloc info we need. */ 1751 amt = isec->reloc_count; 1752 amt *= sizeof (Elf_Internal_Rela*); 1753 rela_comb = (Elf_Internal_Rela**) bfd_malloc (amt); 1754 if (rela_comb == NULL) 1755 goto error_return; 1756 for (n = 0; n < isec->reloc_count; ++n) 1757 { 1758 long r_type; 1759 1760 r_type = ELF32_R_TYPE (internal_relocs[n].r_info); 1761 if (r_type < 0 || r_type >= (int) R_PPC_max) 1762 goto error_return; 1763 1764 /* Prologue constants are sometimes present in the ".text" 1765 sections and they can be identified by their associated 1766 relocation. We don't want to process those words and 1767 some others which can also be identified by their 1768 relocations. However, not all conditional branches will 1769 have a relocation so we will only ignore words that 1770 1) have a reloc, and 2) the reloc is not applicable to a 1771 conditional branch. The array rela_comb is built here 1772 for use in the EOP scan loop. */ 1773 switch (r_type) 1774 { 1775 case R_PPC_ADDR14_BRNTAKEN: 1776 case R_PPC_REL14: 1777 case R_PPC_REL14_BRNTAKEN: 1778 /* We should check the instruction. */ 1779 break; 1780 default: 1781 /* The word is not a conditional branch - ignore it. */ 1782 rela_comb[comb_count++] = &internal_relocs[n]; 1783 break; 1784 } 1785 } 1786 if (comb_count > 1) 1787 qsort (rela_comb, (size_t) comb_count, sizeof (int), 1788 ppc_elf_sort_rela); 1103 1789 } 1104 1790 … … 1107 1793 dot = end_page = (isec->vma | (PAGESIZE - 1)) + 1; 1108 1794 dot -= link_info->mpc860c0; 1109 section_modified = false; 1110 if (dot < isec->vma) /* Increment the start position if this section */ 1111 dot = isec->vma; /* begins in the middle of its first EOP region. */ 1795 section_modified = FALSE; 1796 /* Increment the start position if this section begins in the 1797 middle of its first EOP region. */ 1798 if (dot < isec->vma) 1799 dot = isec->vma; 1112 1800 for (; 1113 dot < end_section; 1114 dot += PAGESIZE, end_page += PAGESIZE) 1115 { 1116 1117 /* Check each word in this EOP region. */ 1118 for (; dot < end_page; dot += 4) 1119 { 1120 bfd_vma isec_offset; 1121 unsigned long insn; 1122 boolean skip, modified; 1123 1124 /* Don't process this word if there is a relocation for it and 1125 the relocation indicates the word is not a conditional branch. */ 1126 skip = false; 1127 isec_offset = dot - isec->vma; 1128 for (; comb_curr<comb_count; ++comb_curr) 1129 { 1130 bfd_vma r_offset; 1131 1132 r_offset = rela_comb[comb_curr]->r_offset; 1133 if (r_offset >= isec_offset) 1134 { 1135 if (r_offset == isec_offset) skip = true; 1136 break; 1137 } 1138 } 1139 if (skip) continue; 1140 1141 /* Check the current word for a problematic conditional branch. */ 1801 dot < end_section; 1802 dot += PAGESIZE, end_page += PAGESIZE) 1803 { 1804 /* Check each word in this EOP region. */ 1805 for (; dot < end_page; dot += 4) 1806 { 1807 bfd_vma isec_offset; 1808 unsigned long insn; 1809 bfd_boolean skip, modified; 1810 1811 /* Don't process this word if there is a relocation for it 1812 and the relocation indicates the word is not a 1813 conditional branch. */ 1814 skip = FALSE; 1815 isec_offset = dot - isec->vma; 1816 for (; comb_curr<comb_count; ++comb_curr) 1817 { 1818 bfd_vma r_offset; 1819 1820 r_offset = rela_comb[comb_curr]->r_offset; 1821 if (r_offset >= isec_offset) 1822 { 1823 if (r_offset == isec_offset) skip = TRUE; 1824 break; 1825 } 1826 } 1827 if (skip) continue; 1828 1829 /* Check the current word for a problematic conditional 1830 branch. */ 1142 1831 #define BO0(insn) ((insn) & 0x02000000) 1143 1832 #define BO2(insn) ((insn) & 0x00800000) 1144 1833 #define BO4(insn) ((insn) & 0x00200000) 1145 insn = (unsigned long) bfd_get_32 (abfd, contents + isec_offset); 1146 modified = false; 1147 if ((insn & 0xFc000000) == 0x40000000) 1148 { 1149 /* Instruction is BCx */ 1150 if ((!BO0(insn) || !BO2(insn)) && !BO4(insn)) 1151 { 1152 bfd_vma target; 1153 /* This branch is predicted as "normal". 1154 If this is a forward branch, it is problematic. */ 1155 1156 target = insn & 0x0000Fffc; /*extract*/ 1157 target = (target ^ 0x8000) - 0x8000; /*sign extend*/ 1158 if ((insn & 0x00000002) == 0) 1159 target += dot; /*convert to abs*/ 1160 if (target > dot) 1161 { 1162 insn |= 0x00200000; /* set the prediction bit */ 1163 modified = true; 1164 } 1165 } 1166 } 1167 else if ((insn & 0xFc00Fffe) == 0x4c000420) 1168 { 1169 /* Instruction is BCCTRx */ 1170 if ((!BO0(insn) || !BO2(insn)) && !BO4(insn)) 1834 insn = (unsigned long) bfd_get_32 (abfd, contents + isec_offset); 1835 modified = FALSE; 1836 if ((insn & 0xFc000000) == 0x40000000) 1837 { 1838 /* Instruction is BCx */ 1839 if ((!BO0(insn) || !BO2(insn)) && !BO4(insn)) 1840 { 1841 bfd_vma target; 1842 1843 /* This branch is predicted as "normal". 1844 If this is a forward branch, it is problematic. */ 1845 target = insn & 0x0000Fffc; 1846 target = (target ^ 0x8000) - 0x8000; 1847 if ((insn & 0x00000002) == 0) 1848 /* Convert to abs. */ 1849 target += dot; 1850 if (target > dot) 1851 { 1852 /* Set the prediction bit. */ 1853 insn |= 0x00200000; 1854 modified = TRUE; 1855 } 1856 } 1857 } 1858 else if ((insn & 0xFc00Fffe) == 0x4c000420) 1859 { 1860 /* Instruction is BCCTRx. */ 1861 if ((!BO0(insn) || !BO2(insn)) && !BO4(insn)) 1171 1862 { 1172 1863 /* This branch is predicted as not-taken. 1173 1174 Since we can't tell statically if it will branch forward, 1175 1176 insn |= 0x00200000; /* set the prediction bit */ 1177 modified = true;1864 If this is a forward branch, it is problematic. 1865 Since we can't tell statically if it will branch 1866 forward, always set the prediction bit. */ 1867 insn |= 0x00200000; 1868 modified = TRUE; 1178 1869 } 1179 1180 1181 1182 1183 1870 } 1871 else if ((insn & 0xFc00Fffe) == 0x4c000020) 1872 { 1873 /* Instruction is BCLRx */ 1874 if ((!BO0(insn) || !BO2(insn)) && !BO4(insn)) 1184 1875 { 1185 1876 /* This branch is predicted as not-taken. 1186 1187 Since we can't tell statically if it will branch forward, 1188 1189 insn |= 0x00200000; /* set the prediction bit */ 1190 modified = true;1877 If this is a forward branch, it is problematic. 1878 Since we can't tell statically if it will branch 1879 forward, always set the prediction bit. */ 1880 insn |= 0x00200000; 1881 modified = TRUE; 1191 1882 } 1192 1883 } 1193 1884 #undef BO0 1194 1885 #undef BO2 1195 1886 #undef BO4 1196 1197 1198 bfd_put_32 (abfd,insn, contents + isec_offset);1199 section_modified = true;1200 1201 1202 1887 if (modified) 1888 { 1889 bfd_put_32 (abfd, (bfd_vma) insn, contents + isec_offset); 1890 section_modified = TRUE; 1891 } 1892 } 1893 } 1203 1894 if (section_modified) 1204 1895 { … … 1232 1923 } 1233 1924 1234 return true;1235 1236 error_return:1925 return TRUE; 1926 1927 error_return: 1237 1928 if (rela_comb != NULL) 1238 1929 free (rela_comb); … … 1241 1932 if (free_contents != NULL) 1242 1933 free (free_contents); 1243 return false;1934 return FALSE; 1244 1935 } 1245 1936 … … 1250 1941 bfd_reloc_code_real_type code; 1251 1942 { 1252 enum elf_ppc_reloc_type ppc_reloc = R_PPC_NONE;1943 enum elf_ppc_reloc_type r; 1253 1944 1254 1945 if (!ppc_elf_howto_table[R_PPC_ADDR32]) … … 1261 1952 return (reloc_howto_type *) NULL; 1262 1953 1263 case BFD_RELOC_NONE: ppc_reloc = R_PPC_NONE; break; 1264 case BFD_RELOC_32: ppc_reloc = R_PPC_ADDR32; break; 1265 case BFD_RELOC_PPC_BA26: ppc_reloc = R_PPC_ADDR24; break; 1266 case BFD_RELOC_16: ppc_reloc = R_PPC_ADDR16; break; 1267 case BFD_RELOC_LO16: ppc_reloc = R_PPC_ADDR16_LO; break; 1268 case BFD_RELOC_HI16: ppc_reloc = R_PPC_ADDR16_HI; break; 1269 case BFD_RELOC_HI16_S: ppc_reloc = R_PPC_ADDR16_HA; break; 1270 case BFD_RELOC_PPC_BA16: ppc_reloc = R_PPC_ADDR14; break; 1271 case BFD_RELOC_PPC_BA16_BRTAKEN: ppc_reloc = R_PPC_ADDR14_BRTAKEN; break; 1272 case BFD_RELOC_PPC_BA16_BRNTAKEN: ppc_reloc = R_PPC_ADDR14_BRNTAKEN; break; 1273 case BFD_RELOC_PPC_B26: ppc_reloc = R_PPC_REL24; break; 1274 case BFD_RELOC_PPC_B16: ppc_reloc = R_PPC_REL14; break; 1275 case BFD_RELOC_PPC_B16_BRTAKEN: ppc_reloc = R_PPC_REL14_BRTAKEN; break; 1276 case BFD_RELOC_PPC_B16_BRNTAKEN: ppc_reloc = R_PPC_REL14_BRNTAKEN; break; 1277 case BFD_RELOC_16_GOTOFF: ppc_reloc = R_PPC_GOT16; break; 1278 case BFD_RELOC_LO16_GOTOFF: ppc_reloc = R_PPC_GOT16_LO; break; 1279 case BFD_RELOC_HI16_GOTOFF: ppc_reloc = R_PPC_GOT16_HI; break; 1280 case BFD_RELOC_HI16_S_GOTOFF: ppc_reloc = R_PPC_GOT16_HA; break; 1281 case BFD_RELOC_24_PLT_PCREL: ppc_reloc = R_PPC_PLTREL24; break; 1282 case BFD_RELOC_PPC_COPY: ppc_reloc = R_PPC_COPY; break; 1283 case BFD_RELOC_PPC_GLOB_DAT: ppc_reloc = R_PPC_GLOB_DAT; break; 1284 case BFD_RELOC_PPC_LOCAL24PC: ppc_reloc = R_PPC_LOCAL24PC; break; 1285 case BFD_RELOC_32_PCREL: ppc_reloc = R_PPC_REL32; break; 1286 case BFD_RELOC_32_PLTOFF: ppc_reloc = R_PPC_PLT32; break; 1287 case BFD_RELOC_32_PLT_PCREL: ppc_reloc = R_PPC_PLTREL32; break; 1288 case BFD_RELOC_LO16_PLTOFF: ppc_reloc = R_PPC_PLT16_LO; break; 1289 case BFD_RELOC_HI16_PLTOFF: ppc_reloc = R_PPC_PLT16_HI; break; 1290 case BFD_RELOC_HI16_S_PLTOFF: ppc_reloc = R_PPC_PLT16_HA; break; 1291 case BFD_RELOC_GPREL16: ppc_reloc = R_PPC_SDAREL16; break; 1292 case BFD_RELOC_32_BASEREL: ppc_reloc = R_PPC_SECTOFF; break; 1293 case BFD_RELOC_LO16_BASEREL: ppc_reloc = R_PPC_SECTOFF_LO; break; 1294 case BFD_RELOC_HI16_BASEREL: ppc_reloc = R_PPC_SECTOFF_HI; break; 1295 case BFD_RELOC_HI16_S_BASEREL: ppc_reloc = R_PPC_SECTOFF_HA; break; 1296 case BFD_RELOC_CTOR: ppc_reloc = R_PPC_ADDR32; break; 1297 case BFD_RELOC_PPC_TOC16: ppc_reloc = R_PPC_TOC16; break; 1298 case BFD_RELOC_PPC_EMB_NADDR32: ppc_reloc = R_PPC_EMB_NADDR32; break; 1299 case BFD_RELOC_PPC_EMB_NADDR16: ppc_reloc = R_PPC_EMB_NADDR16; break; 1300 case BFD_RELOC_PPC_EMB_NADDR16_LO: ppc_reloc = R_PPC_EMB_NADDR16_LO; break; 1301 case BFD_RELOC_PPC_EMB_NADDR16_HI: ppc_reloc = R_PPC_EMB_NADDR16_HI; break; 1302 case BFD_RELOC_PPC_EMB_NADDR16_HA: ppc_reloc = R_PPC_EMB_NADDR16_HA; break; 1303 case BFD_RELOC_PPC_EMB_SDAI16: ppc_reloc = R_PPC_EMB_SDAI16; break; 1304 case BFD_RELOC_PPC_EMB_SDA2I16: ppc_reloc = R_PPC_EMB_SDA2I16; break; 1305 case BFD_RELOC_PPC_EMB_SDA2REL: ppc_reloc = R_PPC_EMB_SDA2REL; break; 1306 case BFD_RELOC_PPC_EMB_SDA21: ppc_reloc = R_PPC_EMB_SDA21; break; 1307 case BFD_RELOC_PPC_EMB_MRKREF: ppc_reloc = R_PPC_EMB_MRKREF; break; 1308 case BFD_RELOC_PPC_EMB_RELSEC16: ppc_reloc = R_PPC_EMB_RELSEC16; break; 1309 case BFD_RELOC_PPC_EMB_RELST_LO: ppc_reloc = R_PPC_EMB_RELST_LO; break; 1310 case BFD_RELOC_PPC_EMB_RELST_HI: ppc_reloc = R_PPC_EMB_RELST_HI; break; 1311 case BFD_RELOC_PPC_EMB_RELST_HA: ppc_reloc = R_PPC_EMB_RELST_HA; break; 1312 case BFD_RELOC_PPC_EMB_BIT_FLD: ppc_reloc = R_PPC_EMB_BIT_FLD; break; 1313 case BFD_RELOC_PPC_EMB_RELSDA: ppc_reloc = R_PPC_EMB_RELSDA; break; 1314 case BFD_RELOC_VTABLE_INHERIT: ppc_reloc = R_PPC_GNU_VTINHERIT; break; 1315 case BFD_RELOC_VTABLE_ENTRY: ppc_reloc = R_PPC_GNU_VTENTRY; break; 1954 case BFD_RELOC_NONE: r = R_PPC_NONE; break; 1955 case BFD_RELOC_32: r = R_PPC_ADDR32; break; 1956 case BFD_RELOC_PPC_BA26: r = R_PPC_ADDR24; break; 1957 case BFD_RELOC_16: r = R_PPC_ADDR16; break; 1958 case BFD_RELOC_LO16: r = R_PPC_ADDR16_LO; break; 1959 case BFD_RELOC_HI16: r = R_PPC_ADDR16_HI; break; 1960 case BFD_RELOC_HI16_S: r = R_PPC_ADDR16_HA; break; 1961 case BFD_RELOC_PPC_BA16: r = R_PPC_ADDR14; break; 1962 case BFD_RELOC_PPC_BA16_BRTAKEN: r = R_PPC_ADDR14_BRTAKEN; break; 1963 case BFD_RELOC_PPC_BA16_BRNTAKEN: r = R_PPC_ADDR14_BRNTAKEN; break; 1964 case BFD_RELOC_PPC_B26: r = R_PPC_REL24; break; 1965 case BFD_RELOC_PPC_B16: r = R_PPC_REL14; break; 1966 case BFD_RELOC_PPC_B16_BRTAKEN: r = R_PPC_REL14_BRTAKEN; break; 1967 case BFD_RELOC_PPC_B16_BRNTAKEN: r = R_PPC_REL14_BRNTAKEN; break; 1968 case BFD_RELOC_16_GOTOFF: r = R_PPC_GOT16; break; 1969 case BFD_RELOC_LO16_GOTOFF: r = R_PPC_GOT16_LO; break; 1970 case BFD_RELOC_HI16_GOTOFF: r = R_PPC_GOT16_HI; break; 1971 case BFD_RELOC_HI16_S_GOTOFF: r = R_PPC_GOT16_HA; break; 1972 case BFD_RELOC_24_PLT_PCREL: r = R_PPC_PLTREL24; break; 1973 case BFD_RELOC_PPC_COPY: r = R_PPC_COPY; break; 1974 case BFD_RELOC_PPC_GLOB_DAT: r = R_PPC_GLOB_DAT; break; 1975 case BFD_RELOC_PPC_LOCAL24PC: r = R_PPC_LOCAL24PC; break; 1976 case BFD_RELOC_32_PCREL: r = R_PPC_REL32; break; 1977 case BFD_RELOC_32_PLTOFF: r = R_PPC_PLT32; break; 1978 case BFD_RELOC_32_PLT_PCREL: r = R_PPC_PLTREL32; break; 1979 case BFD_RELOC_LO16_PLTOFF: r = R_PPC_PLT16_LO; break; 1980 case BFD_RELOC_HI16_PLTOFF: r = R_PPC_PLT16_HI; break; 1981 case BFD_RELOC_HI16_S_PLTOFF: r = R_PPC_PLT16_HA; break; 1982 case BFD_RELOC_GPREL16: r = R_PPC_SDAREL16; break; 1983 case BFD_RELOC_16_BASEREL: r = R_PPC_SECTOFF; break; 1984 case BFD_RELOC_LO16_BASEREL: r = R_PPC_SECTOFF_LO; break; 1985 case BFD_RELOC_HI16_BASEREL: r = R_PPC_SECTOFF_HI; break; 1986 case BFD_RELOC_HI16_S_BASEREL: r = R_PPC_SECTOFF_HA; break; 1987 case BFD_RELOC_CTOR: r = R_PPC_ADDR32; break; 1988 case BFD_RELOC_PPC_TOC16: r = R_PPC_TOC16; break; 1989 case BFD_RELOC_PPC_TLS: r = R_PPC_TLS; break; 1990 case BFD_RELOC_PPC_DTPMOD: r = R_PPC_DTPMOD32; break; 1991 case BFD_RELOC_PPC_TPREL16: r = R_PPC_TPREL16; break; 1992 case BFD_RELOC_PPC_TPREL16_LO: r = R_PPC_TPREL16_LO; break; 1993 case BFD_RELOC_PPC_TPREL16_HI: r = R_PPC_TPREL16_HI; break; 1994 case BFD_RELOC_PPC_TPREL16_HA: r = R_PPC_TPREL16_HA; break; 1995 case BFD_RELOC_PPC_TPREL: r = R_PPC_TPREL32; break; 1996 case BFD_RELOC_PPC_DTPREL16: r = R_PPC_DTPREL16; break; 1997 case BFD_RELOC_PPC_DTPREL16_LO: r = R_PPC_DTPREL16_LO; break; 1998 case BFD_RELOC_PPC_DTPREL16_HI: r = R_PPC_DTPREL16_HI; break; 1999 case BFD_RELOC_PPC_DTPREL16_HA: r = R_PPC_DTPREL16_HA; break; 2000 case BFD_RELOC_PPC_DTPREL: r = R_PPC_DTPREL32; break; 2001 case BFD_RELOC_PPC_GOT_TLSGD16: r = R_PPC_GOT_TLSGD16; break; 2002 case BFD_RELOC_PPC_GOT_TLSGD16_LO: r = R_PPC_GOT_TLSGD16_LO; break; 2003 case BFD_RELOC_PPC_GOT_TLSGD16_HI: r = R_PPC_GOT_TLSGD16_HI; break; 2004 case BFD_RELOC_PPC_GOT_TLSGD16_HA: r = R_PPC_GOT_TLSGD16_HA; break; 2005 case BFD_RELOC_PPC_GOT_TLSLD16: r = R_PPC_GOT_TLSLD16; break; 2006 case BFD_RELOC_PPC_GOT_TLSLD16_LO: r = R_PPC_GOT_TLSLD16_LO; break; 2007 case BFD_RELOC_PPC_GOT_TLSLD16_HI: r = R_PPC_GOT_TLSLD16_HI; break; 2008 case BFD_RELOC_PPC_GOT_TLSLD16_HA: r = R_PPC_GOT_TLSLD16_HA; break; 2009 case BFD_RELOC_PPC_GOT_TPREL16: r = R_PPC_GOT_TPREL16; break; 2010 case BFD_RELOC_PPC_GOT_TPREL16_LO: r = R_PPC_GOT_TPREL16_LO; break; 2011 case BFD_RELOC_PPC_GOT_TPREL16_HI: r = R_PPC_GOT_TPREL16_HI; break; 2012 case BFD_RELOC_PPC_GOT_TPREL16_HA: r = R_PPC_GOT_TPREL16_HA; break; 2013 case BFD_RELOC_PPC_GOT_DTPREL16: r = R_PPC_GOT_DTPREL16; break; 2014 case BFD_RELOC_PPC_GOT_DTPREL16_LO: r = R_PPC_GOT_DTPREL16_LO; break; 2015 case BFD_RELOC_PPC_GOT_DTPREL16_HI: r = R_PPC_GOT_DTPREL16_HI; break; 2016 case BFD_RELOC_PPC_GOT_DTPREL16_HA: r = R_PPC_GOT_DTPREL16_HA; break; 2017 case BFD_RELOC_PPC_EMB_NADDR32: r = R_PPC_EMB_NADDR32; break; 2018 case BFD_RELOC_PPC_EMB_NADDR16: r = R_PPC_EMB_NADDR16; break; 2019 case BFD_RELOC_PPC_EMB_NADDR16_LO: r = R_PPC_EMB_NADDR16_LO; break; 2020 case BFD_RELOC_PPC_EMB_NADDR16_HI: r = R_PPC_EMB_NADDR16_HI; break; 2021 case BFD_RELOC_PPC_EMB_NADDR16_HA: r = R_PPC_EMB_NADDR16_HA; break; 2022 case BFD_RELOC_PPC_EMB_SDAI16: r = R_PPC_EMB_SDAI16; break; 2023 case BFD_RELOC_PPC_EMB_SDA2I16: r = R_PPC_EMB_SDA2I16; break; 2024 case BFD_RELOC_PPC_EMB_SDA2REL: r = R_PPC_EMB_SDA2REL; break; 2025 case BFD_RELOC_PPC_EMB_SDA21: r = R_PPC_EMB_SDA21; break; 2026 case BFD_RELOC_PPC_EMB_MRKREF: r = R_PPC_EMB_MRKREF; break; 2027 case BFD_RELOC_PPC_EMB_RELSEC16: r = R_PPC_EMB_RELSEC16; break; 2028 case BFD_RELOC_PPC_EMB_RELST_LO: r = R_PPC_EMB_RELST_LO; break; 2029 case BFD_RELOC_PPC_EMB_RELST_HI: r = R_PPC_EMB_RELST_HI; break; 2030 case BFD_RELOC_PPC_EMB_RELST_HA: r = R_PPC_EMB_RELST_HA; break; 2031 case BFD_RELOC_PPC_EMB_BIT_FLD: r = R_PPC_EMB_BIT_FLD; break; 2032 case BFD_RELOC_PPC_EMB_RELSDA: r = R_PPC_EMB_RELSDA; break; 2033 case BFD_RELOC_VTABLE_INHERIT: r = R_PPC_GNU_VTINHERIT; break; 2034 case BFD_RELOC_VTABLE_ENTRY: r = R_PPC_GNU_VTENTRY; break; 1316 2035 } 1317 2036 1318 return ppc_elf_howto_table[(int) ppc_reloc];2037 return ppc_elf_howto_table[(int) r]; 1319 2038 }; 1320 2039 … … 1325 2044 bfd *abfd ATTRIBUTE_UNUSED; 1326 2045 arelent *cache_ptr; 1327 Elf 32_Internal_Rela *dst;2046 Elf_Internal_Rela *dst; 1328 2047 { 1329 2048 if (!ppc_elf_howto_table[R_PPC_ADDR32]) … … 1373 2092 } 1374 2093 2094 static bfd_reloc_status_type 2095 ppc_elf_unhandled_reloc (abfd, reloc_entry, symbol, data, 2096 input_section, output_bfd, error_message) 2097 bfd *abfd; 2098 arelent *reloc_entry; 2099 asymbol *symbol; 2100 PTR data; 2101 asection *input_section; 2102 bfd *output_bfd; 2103 char **error_message; 2104 { 2105 /* If this is a relocatable link (output_bfd test tells us), just 2106 call the generic function. Any adjustment will be done at final 2107 link time. */ 2108 if (output_bfd != NULL) 2109 return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, 2110 input_section, output_bfd, error_message); 2111 2112 if (error_message != NULL) 2113 { 2114 static char buf[60]; 2115 sprintf (buf, "generic linker can't handle %s", 2116 reloc_entry->howto->name); 2117 *error_message = buf; 2118 } 2119 return bfd_reloc_dangerous; 2120 } 2121 2122 /* Fix bad default arch selected for a 32 bit input bfd when the 2123 default is 64 bit. */ 2124 2125 static bfd_boolean 2126 ppc_elf_object_p (abfd) 2127 bfd *abfd; 2128 { 2129 if (abfd->arch_info->the_default && abfd->arch_info->bits_per_word == 64) 2130 { 2131 Elf_Internal_Ehdr *i_ehdr = elf_elfheader (abfd); 2132 2133 if (i_ehdr->e_ident[EI_CLASS] == ELFCLASS32) 2134 { 2135 /* Relies on arch after 64 bit default being 32 bit default. */ 2136 abfd->arch_info = abfd->arch_info->next; 2137 BFD_ASSERT (abfd->arch_info->bits_per_word == 32); 2138 } 2139 } 2140 return TRUE; 2141 } 2142 1375 2143 /* Function to set whether a module needs the -mrelocatable bit set. */ 1376 2144 1377 static b oolean2145 static bfd_boolean 1378 2146 ppc_elf_set_private_flags (abfd, flags) 1379 2147 bfd *abfd; … … 1384 2152 1385 2153 elf_elfheader (abfd)->e_flags = flags; 1386 elf_flags_init (abfd) = true;1387 return true;2154 elf_flags_init (abfd) = TRUE; 2155 return TRUE; 1388 2156 } 1389 2157 1390 /* Copy backend specific data from one object module to another */1391 static boolean1392 ppc_elf_copy_private_bfd_data (ibfd, obfd)1393 bfd *ibfd;1394 bfd *obfd;1395 {1396 if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour1397 || bfd_get_flavour (obfd) != bfd_target_elf_flavour)1398 return true;1399 1400 BFD_ASSERT (!elf_flags_init (obfd)1401 || elf_elfheader (obfd)->e_flags == elf_elfheader (ibfd)->e_flags);1402 1403 elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;1404 elf_flags_init (obfd) = true;1405 return true;1406 }1407 1408 2158 /* Merge backend specific data from an object file to the output 1409 object file when linking */ 1410 static boolean 2159 object file when linking. */ 2160 2161 static bfd_boolean 1411 2162 ppc_elf_merge_private_bfd_data (ibfd, obfd) 1412 2163 bfd *ibfd; … … 1415 2166 flagword old_flags; 1416 2167 flagword new_flags; 1417 b oolean error;1418 1419 /* Check if we have the same endianess */1420 if ( _bfd_generic_verify_endian_match (ibfd, obfd) == false)1421 return false;2168 bfd_boolean error; 2169 2170 /* Check if we have the same endianess. */ 2171 if (! _bfd_generic_verify_endian_match (ibfd, obfd)) 2172 return FALSE; 1422 2173 1423 2174 if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour 1424 2175 || bfd_get_flavour (obfd) != bfd_target_elf_flavour) 1425 return true;2176 return TRUE; 1426 2177 1427 2178 new_flags = elf_elfheader (ibfd)->e_flags; 1428 2179 old_flags = elf_elfheader (obfd)->e_flags; 1429 if (!elf_flags_init (obfd)) /* First call, no flags set */2180 if (!elf_flags_init (obfd)) 1430 2181 { 1431 elf_flags_init (obfd) = true; 2182 /* First call, no flags set. */ 2183 elf_flags_init (obfd) = TRUE; 1432 2184 elf_elfheader (obfd)->e_flags = new_flags; 1433 2185 } 1434 2186 1435 else if (new_flags == old_flags) /* Compatible flags are ok */ 2187 /* Compatible flags are ok. */ 2188 else if (new_flags == old_flags) 1436 2189 ; 1437 2190 1438 else /* Incompatible flags */ 2191 /* Incompatible flags. */ 2192 else 1439 2193 { 1440 /* Warn about -mrelocatable mismatch. Allow -mrelocatable-lib to be linked1441 1442 error = false;2194 /* Warn about -mrelocatable mismatch. Allow -mrelocatable-lib 2195 to be linked with either. */ 2196 error = FALSE; 1443 2197 if ((new_flags & EF_PPC_RELOCATABLE) != 0 1444 2198 && (old_flags & (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB)) == 0) 1445 2199 { 1446 error = true;2200 error = TRUE; 1447 2201 (*_bfd_error_handler) 1448 2202 (_("%s: compiled with -mrelocatable and linked with modules compiled normally"), 1449 bfd_ get_filename (ibfd));2203 bfd_archive_filename (ibfd)); 1450 2204 } 1451 2205 else if ((new_flags & (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB)) == 0 1452 2206 && (old_flags & EF_PPC_RELOCATABLE) != 0) 1453 2207 { 1454 error = true;2208 error = TRUE; 1455 2209 (*_bfd_error_handler) 1456 2210 (_("%s: compiled normally and linked with modules compiled with -mrelocatable"), 1457 bfd_ get_filename (ibfd));2211 bfd_archive_filename (ibfd)); 1458 2212 } 1459 2213 … … 1463 2217 1464 2218 /* The output is -mrelocatable iff it can't be -mrelocatable-lib, 1465 2219 but each input file is either -mrelocatable or -mrelocatable-lib. */ 1466 2220 if (! (elf_elfheader (obfd)->e_flags & EF_PPC_RELOCATABLE_LIB) 1467 2221 && (new_flags & (EF_PPC_RELOCATABLE_LIB | EF_PPC_RELOCATABLE)) … … 1469 2223 elf_elfheader (obfd)->e_flags |= EF_PPC_RELOCATABLE; 1470 2224 1471 /* Do not warn about eabi vs. V.4 mismatch, just or in the bit if any module uses it */ 2225 /* Do not warn about eabi vs. V.4 mismatch, just or in the bit if 2226 any module uses it. */ 1472 2227 elf_elfheader (obfd)->e_flags |= (new_flags & EF_PPC_EMB); 1473 2228 1474 new_flags &= ~ 1475 old_flags &= ~ 1476 1477 /* Warn about any other mismatches */2229 new_flags &= ~(EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB | EF_PPC_EMB); 2230 old_flags &= ~(EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB | EF_PPC_EMB); 2231 2232 /* Warn about any other mismatches. */ 1478 2233 if (new_flags != old_flags) 1479 2234 { 1480 error = true;2235 error = TRUE; 1481 2236 (*_bfd_error_handler) 1482 2237 (_("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"), 1483 bfd_ get_filename (ibfd), (long) new_flags, (long) old_flags);2238 bfd_archive_filename (ibfd), (long) new_flags, (long) old_flags); 1484 2239 } 1485 2240 … … 1487 2242 { 1488 2243 bfd_set_error (bfd_error_bad_value); 1489 return false;2244 return FALSE; 1490 2245 } 1491 2246 } 1492 2247 1493 return true;2248 return TRUE; 1494 2249 } 1495 2250 … … 1498 2253 is called when elfcode.h finds a section with an unknown type. */ 1499 2254 1500 static b oolean2255 static bfd_boolean 1501 2256 ppc_elf_section_from_shdr (abfd, hdr, name) 1502 2257 bfd *abfd; 1503 Elf 32_Internal_Shdr *hdr;1504 c har *name;2258 Elf_Internal_Shdr *hdr; 2259 const char *name; 1505 2260 { 1506 2261 asection *newsect; … … 1508 2263 1509 2264 if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name)) 1510 return false;2265 return FALSE; 1511 2266 1512 2267 newsect = hdr->bfd_section; … … 1519 2274 1520 2275 bfd_set_section_flags (abfd, newsect, flags); 1521 return true;2276 return TRUE; 1522 2277 } 1523 2278 … … 1525 2280 /* Set up any other section flags and such that may be necessary. */ 1526 2281 1527 static b oolean2282 static bfd_boolean 1528 2283 ppc_elf_fake_sections (abfd, shdr, asect) 1529 2284 bfd *abfd ATTRIBUTE_UNUSED; 1530 Elf 32_Internal_Shdr *shdr;2285 Elf_Internal_Shdr *shdr; 1531 2286 asection *asect; 1532 2287 { … … 1537 2292 shdr->sh_type = SHT_ORDERED; 1538 2293 1539 return true;2294 return TRUE; 1540 2295 } 1541 2296 … … 1551 2306 elf_linker_section_t *lsect; 1552 2307 1553 /* Record the first bfd section that needs the special section */2308 /* Record the first bfd section that needs the special section. */ 1554 2309 if (!dynobj) 1555 2310 dynobj = elf_hash_table (info)->dynobj = abfd; 1556 2311 1557 /* If this is the first time, create the section */2312 /* If this is the first time, create the section. */ 1558 2313 lsect = elf_linker_section (dynobj, which); 1559 2314 if (!lsect) … … 1564 2319 defaults = zero_section; 1565 2320 defaults.which = which; 1566 defaults.hole_written_p = false;2321 defaults.hole_written_p = FALSE; 1567 2322 defaults.alignment = 2; 1568 2323 … … 1581 2336 { 1582 2337 default: 1583 (*_bfd_error_handler) (_("%s: Unknown special linker type %d"),2338 (*_bfd_error_handler) (_("%s: unknown special linker type %d"), 1584 2339 bfd_get_filename (abfd), 1585 2340 (int) which); … … 1642 2397 /* Modify the segment map if needed. */ 1643 2398 1644 static b oolean2399 static bfd_boolean 1645 2400 ppc_elf_modify_segment_map (abfd) 1646 2401 bfd *abfd ATTRIBUTE_UNUSED; 1647 2402 { 1648 return true;2403 return TRUE; 1649 2404 } 1650 2405 2406 2407 /* The powerpc .got has a blrl instruction in it. Mark it executable. */ 2408 2409 static bfd_boolean 2410 ppc_elf_create_got (abfd, info) 2411 bfd *abfd; 2412 struct bfd_link_info *info; 2413 { 2414 struct ppc_elf_link_hash_table *htab; 2415 asection *s; 2416 flagword flags; 2417 2418 if (!_bfd_elf_create_got_section (abfd, info)) 2419 return FALSE; 2420 2421 htab = ppc_elf_hash_table (info); 2422 htab->got = s = bfd_get_section_by_name (abfd, ".got"); 2423 if (s == NULL) 2424 abort (); 2425 2426 flags = (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS | SEC_IN_MEMORY 2427 | SEC_LINKER_CREATED); 2428 if (!bfd_set_section_flags (abfd, s, flags)) 2429 return FALSE; 2430 2431 htab->relgot = bfd_make_section (abfd, ".rela.got"); 2432 if (!htab->relgot 2433 || ! bfd_set_section_flags (abfd, htab->relgot, 2434 (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS 2435 | SEC_IN_MEMORY | SEC_LINKER_CREATED 2436 | SEC_READONLY)) 2437 || ! bfd_set_section_alignment (abfd, htab->relgot, 2)) 2438 return FALSE; 2439 2440 return TRUE; 2441 } 1651 2442 1652 2443 /* We have to create .dynsbss and .rela.sbss here so that they get mapped … … 1654 2445 to create .dynbss and .rela.bss). */ 1655 2446 1656 static b oolean2447 static bfd_boolean 1657 2448 ppc_elf_create_dynamic_sections (abfd, info) 1658 2449 bfd *abfd; 1659 2450 struct bfd_link_info *info; 1660 2451 { 1661 register asection *s; 2452 struct ppc_elf_link_hash_table *htab; 2453 asection *s; 1662 2454 flagword flags; 1663 2455 2456 if (!ppc_elf_create_got (abfd, info)) 2457 return FALSE; 2458 1664 2459 if (!_bfd_elf_create_dynamic_sections (abfd, info)) 1665 return false;2460 return FALSE; 1666 2461 1667 2462 flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY 1668 2463 | SEC_LINKER_CREATED); 1669 2464 1670 s = bfd_make_section (abfd, ".dynsbss"); 2465 htab = ppc_elf_hash_table (info); 2466 htab->dynbss = bfd_get_section_by_name (abfd, ".dynbss"); 2467 htab->dynsbss = s = bfd_make_section (abfd, ".dynsbss"); 1671 2468 if (s == NULL 1672 2469 || ! bfd_set_section_flags (abfd, s, SEC_ALLOC)) 1673 return false;2470 return FALSE; 1674 2471 1675 2472 if (! info->shared) 1676 2473 { 1677 s = bfd_make_section (abfd, ".rela.sbss"); 2474 htab->relbss = bfd_get_section_by_name (abfd, ".rela.bss"); 2475 htab->relsbss = s = bfd_make_section (abfd, ".rela.sbss"); 1678 2476 if (s == NULL 1679 2477 || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) 1680 2478 || ! bfd_set_section_alignment (abfd, s, 2)) 1681 return false;2479 return FALSE; 1682 2480 } 1683 return true; 2481 2482 htab->relplt = bfd_get_section_by_name (abfd, ".rela.plt"); 2483 htab->plt = s = bfd_get_section_by_name (abfd, ".plt"); 2484 if (s == NULL) 2485 abort (); 2486 2487 flags = SEC_ALLOC | SEC_CODE | SEC_IN_MEMORY | SEC_LINKER_CREATED; 2488 return bfd_set_section_flags (abfd, s, flags); 1684 2489 } 1685 2490 … … 1690 2495 understand. */ 1691 2496 1692 static b oolean2497 static bfd_boolean 1693 2498 ppc_elf_adjust_dynamic_symbol (info, h) 1694 2499 struct bfd_link_info *info; 1695 2500 struct elf_link_hash_entry *h; 1696 2501 { 1697 bfd *dynobj = elf_hash_table (info)->dynobj;2502 struct ppc_elf_link_hash_table *htab; 1698 2503 asection *s; 1699 2504 unsigned int power_of_two; 1700 bfd_vma plt_offset;1701 2505 1702 2506 #ifdef DEBUG 1703 fprintf (stderr, "ppc_elf_adjust_dynamic_symbol called for %s\n", h->root.root.string); 2507 fprintf (stderr, "ppc_elf_adjust_dynamic_symbol called for %s\n", 2508 h->root.root.string); 1704 2509 #endif 1705 2510 1706 2511 /* Make sure we know what is going on here. */ 1707 BFD_ASSERT (dynobj != NULL 2512 htab = ppc_elf_hash_table (info); 2513 BFD_ASSERT (htab->elf.dynobj != NULL 1708 2514 && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) 1709 2515 || h->weakdef != NULL … … 1715 2521 & ELF_LINK_HASH_DEF_REGULAR) == 0))); 1716 2522 1717 /* If this is a function, put it in the procedure linkage table. We 1718 will fill in the contents of the procedure linkage table later, 1719 when we know the address of the .got section. */ 2523 /* Deal with function syms. */ 1720 2524 if (h->type == STT_FUNC 1721 2525 || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0) 1722 2526 { 1723 if (! elf_hash_table (info)->dynamic_sections_created 1724 || SYMBOL_CALLS_LOCAL (info, h) 1725 || (info->shared && h->plt.refcount <= 0)) 2527 /* Clear procedure linkage table information for any symbol that 2528 won't need a .plt entry. */ 2529 if (! htab->elf.dynamic_sections_created 2530 || SYMBOL_CALLS_LOCAL (info, h) 2531 || h->plt.refcount <= 0) 1726 2532 { 1727 2533 /* A PLT entry is not required/allowed when: 1728 2534 1729 1. We are not using ld.so; because then the PLT entry 1730 can't be set up, so we can't use one. 1731 1732 2. We know for certain that a call to this symbol 1733 will go to this object. 1734 1735 3. GC has rendered the entry unused. 1736 Note, however, that in an executable all references to the 1737 symbol go to the PLT, so we can't turn it off in that case. 1738 ??? The correct thing to do here is to reference count 1739 all uses of the symbol, not just those to the GOT or PLT. */ 2535 1. We are not using ld.so; because then the PLT entry 2536 can't be set up, so we can't use one. 2537 2538 2. We know for certain that a call to this symbol 2539 will go to this object. 2540 2541 3. GC has rendered the entry unused. */ 1740 2542 h->plt.offset = (bfd_vma) -1; 1741 2543 h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; 1742 return true;1743 2544 } 1744 1745 /* Make sure this symbol is output as a dynamic symbol. */ 1746 if (h->dynindx == -1) 1747 { 1748 if (! bfd_elf32_link_record_dynamic_symbol (info, h)) 1749 return false; 1750 } 1751 BFD_ASSERT (h->dynindx != -1); 1752 1753 s = bfd_get_section_by_name (dynobj, ".plt"); 1754 BFD_ASSERT (s != NULL); 1755 1756 /* If this is the first .plt entry, make room for the special 1757 first entry. */ 1758 if (s->_raw_size == 0) 1759 s->_raw_size += PLT_INITIAL_ENTRY_SIZE; 1760 1761 /* The PowerPC PLT is actually composed of two parts, the first part 1762 is 2 words (for a load and a jump), and then there is a remaining 1763 word available at the end. */ 1764 plt_offset = (PLT_INITIAL_ENTRY_SIZE 1765 + (PLT_SLOT_SIZE 1766 * ((s->_raw_size - PLT_INITIAL_ENTRY_SIZE) 1767 / PLT_ENTRY_SIZE))); 1768 1769 /* If this symbol is not defined in a regular file, and we are 1770 not generating a shared library, then set the symbol to this 1771 location in the .plt. This is required to make function 1772 pointers compare as equal between the normal executable and 1773 the shared library. */ 1774 if (! info->shared 1775 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) 1776 { 1777 h->root.u.def.section = s; 1778 h->root.u.def.value = plt_offset; 1779 } 1780 1781 h->plt.offset = plt_offset; 1782 1783 /* Make room for this entry. After the 8192nd entry, room 1784 for two entries is allocated. */ 1785 if ((s->_raw_size - PLT_INITIAL_ENTRY_SIZE) / PLT_ENTRY_SIZE 1786 >= PLT_NUM_SINGLE_ENTRIES) 1787 s->_raw_size += 2 * PLT_ENTRY_SIZE; 1788 else 1789 s->_raw_size += PLT_ENTRY_SIZE; 1790 1791 /* We also need to make an entry in the .rela.plt section. */ 1792 s = bfd_get_section_by_name (dynobj, ".rela.plt"); 1793 BFD_ASSERT (s != NULL); 1794 s->_raw_size += sizeof (Elf32_External_Rela); 1795 1796 return true; 2545 return TRUE; 1797 2546 } 2547 else 2548 h->plt.offset = (bfd_vma) -1; 1798 2549 1799 2550 /* If this is a weak symbol, and there is a real definition, the … … 1806 2557 h->root.u.def.section = h->weakdef->root.u.def.section; 1807 2558 h->root.u.def.value = h->weakdef->root.u.def.value; 1808 return true; 2559 if (ELIMINATE_COPY_RELOCS) 2560 h->elf_link_hash_flags 2561 = ((h->elf_link_hash_flags & ~ELF_LINK_NON_GOT_REF) 2562 | (h->weakdef->elf_link_hash_flags & ELF_LINK_NON_GOT_REF)); 2563 return TRUE; 1809 2564 } 1810 2565 … … 1817 2572 be handled correctly by relocate_section. */ 1818 2573 if (info->shared) 1819 return true; 2574 return TRUE; 2575 2576 /* If there are no references to this symbol that do not use the 2577 GOT, we don't need to generate a copy reloc. */ 2578 if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0) 2579 return TRUE; 2580 2581 if (ELIMINATE_COPY_RELOCS) 2582 { 2583 struct ppc_elf_dyn_relocs *p; 2584 for (p = ppc_elf_hash_entry (h)->dyn_relocs; p != NULL; p = p->next) 2585 { 2586 s = p->sec->output_section; 2587 if (s != NULL && (s->flags & SEC_READONLY) != 0) 2588 break; 2589 } 2590 2591 /* If we didn't find any dynamic relocs in read-only sections, then 2592 we'll be keeping the dynamic relocs and avoiding the copy reloc. */ 2593 if (p == NULL) 2594 { 2595 h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF; 2596 return TRUE; 2597 } 2598 } 1820 2599 1821 2600 /* We must allocate the symbol in our .dynbss section, which will … … 1833 2612 only if there were actually SDAREL relocs for that symbol. */ 1834 2613 1835 if (h->size <= elf_gp_size ( dynobj))1836 s = bfd_get_section_by_name (dynobj, ".dynsbss");2614 if (h->size <= elf_gp_size (htab->elf.dynobj)) 2615 s = htab->dynsbss; 1837 2616 else 1838 s = bfd_get_section_by_name (dynobj, ".dynbss");2617 s = htab->dynbss; 1839 2618 BFD_ASSERT (s != NULL); 1840 2619 … … 1847 2626 asection *srel; 1848 2627 1849 if (h->size <= elf_gp_size ( dynobj))1850 srel = bfd_get_section_by_name (dynobj, ".rela.sbss");2628 if (h->size <= elf_gp_size (htab->elf.dynobj)) 2629 srel = htab->relsbss; 1851 2630 else 1852 srel = bfd_get_section_by_name (dynobj, ".rela.bss");2631 srel = htab->relbss; 1853 2632 BFD_ASSERT (srel != NULL); 1854 2633 srel->_raw_size += sizeof (Elf32_External_Rela); … … 1865 2644 s->_raw_size = BFD_ALIGN (s->_raw_size, 1866 2645 (bfd_size_type) (1 << power_of_two)); 1867 if (power_of_two > bfd_get_section_alignment ( dynobj, s))2646 if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s)) 1868 2647 { 1869 if (! bfd_set_section_alignment ( dynobj, s, power_of_two))1870 return false;2648 if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two)) 2649 return FALSE; 1871 2650 } 1872 2651 … … 1878 2657 s->_raw_size += h->size; 1879 2658 1880 return true;2659 return TRUE; 1881 2660 } 1882 2661 1883 2662 2663 /* This is the condition under which finish_dynamic_symbol will be 2664 called from elflink.h. If elflink.h doesn't call our 2665 finish_dynamic_symbol routine, we'll need to do something about 2666 initializing any .plt and .got entries in relocate_section. */ 2667 #define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, SHARED, H) \ 2668 ((DYN) \ 2669 && ((SHARED) \ 2670 || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) \ 2671 && ((H)->dynindx != -1 \ 2672 || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)) 2673 2674 /* Of those relocs that might be copied as dynamic relocs, this macro 2675 selects those that must be copied when linking a shared library, 2676 even when the symbol is local. */ 2677 2678 #define MUST_BE_DYN_RELOC(RTYPE) \ 2679 ((RTYPE) != R_PPC_REL24 \ 2680 && (RTYPE) != R_PPC_REL14 \ 2681 && (RTYPE) != R_PPC_REL14_BRTAKEN \ 2682 && (RTYPE) != R_PPC_REL14_BRNTAKEN \ 2683 && (RTYPE) != R_PPC_REL32) 2684 2685 /* Allocate space in associated reloc sections for dynamic relocs. */ 2686 2687 static bfd_boolean 2688 allocate_dynrelocs (h, inf) 2689 struct elf_link_hash_entry *h; 2690 PTR inf; 2691 { 2692 struct bfd_link_info *info = (struct bfd_link_info *) inf; 2693 struct ppc_elf_link_hash_entry *eh; 2694 struct ppc_elf_link_hash_table *htab; 2695 struct ppc_elf_dyn_relocs *p; 2696 2697 if (h->root.type == bfd_link_hash_indirect) 2698 return TRUE; 2699 2700 if (h->root.type == bfd_link_hash_warning) 2701 /* When warning symbols are created, they **replace** the "real" 2702 entry in the hash table, thus we never get to see the real 2703 symbol in a hash traversal. So look at it now. */ 2704 h = (struct elf_link_hash_entry *) h->root.u.i.link; 2705 2706 htab = ppc_elf_hash_table (info); 2707 if (htab->elf.dynamic_sections_created 2708 && h->plt.refcount > 0) 2709 { 2710 /* Make sure this symbol is output as a dynamic symbol. */ 2711 if (h->dynindx == -1 2712 && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) 2713 { 2714 if (! bfd_elf32_link_record_dynamic_symbol (info, h)) 2715 return FALSE; 2716 } 2717 2718 if (info->shared 2719 || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h)) 2720 { 2721 asection *s = htab->plt; 2722 2723 /* If this is the first .plt entry, make room for the special 2724 first entry. */ 2725 if (s->_raw_size == 0) 2726 s->_raw_size += PLT_INITIAL_ENTRY_SIZE; 2727 2728 /* The PowerPC PLT is actually composed of two parts, the 2729 first part is 2 words (for a load and a jump), and then 2730 there is a remaining word available at the end. */ 2731 h->plt.offset = (PLT_INITIAL_ENTRY_SIZE 2732 + (PLT_SLOT_SIZE 2733 * ((s->_raw_size - PLT_INITIAL_ENTRY_SIZE) 2734 / PLT_ENTRY_SIZE))); 2735 2736 /* If this symbol is not defined in a regular file, and we 2737 are not generating a shared library, then set the symbol 2738 to this location in the .plt. This is required to make 2739 function pointers compare as equal between the normal 2740 executable and the shared library. */ 2741 if (! info->shared 2742 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) 2743 { 2744 h->root.u.def.section = s; 2745 h->root.u.def.value = h->plt.offset; 2746 } 2747 2748 /* Make room for this entry. After the 8192nd entry, room 2749 for two entries is allocated. */ 2750 s->_raw_size += PLT_ENTRY_SIZE; 2751 if ((s->_raw_size - PLT_INITIAL_ENTRY_SIZE) / PLT_ENTRY_SIZE 2752 > PLT_NUM_SINGLE_ENTRIES) 2753 s->_raw_size += PLT_ENTRY_SIZE; 2754 2755 /* We also need to make an entry in the .rela.plt section. */ 2756 htab->relplt->_raw_size += sizeof (Elf32_External_Rela); 2757 } 2758 else 2759 { 2760 h->plt.offset = (bfd_vma) -1; 2761 h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; 2762 } 2763 } 2764 else 2765 { 2766 h->plt.offset = (bfd_vma) -1; 2767 h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; 2768 } 2769 2770 eh = (struct ppc_elf_link_hash_entry *) h; 2771 if (eh->elf.got.refcount > 0) 2772 { 2773 /* Make sure this symbol is output as a dynamic symbol. */ 2774 if (eh->elf.dynindx == -1 2775 && (eh->elf.elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) 2776 { 2777 if (!bfd_elf32_link_record_dynamic_symbol (info, &eh->elf)) 2778 return FALSE; 2779 } 2780 2781 if (eh->tls_mask == (TLS_TLS | TLS_LD) 2782 && !(eh->elf.elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC)) 2783 /* If just an LD reloc, we'll just use htab->tlsld_got.offset. */ 2784 eh->elf.got.offset = (bfd_vma) -1; 2785 else 2786 { 2787 bfd_boolean dyn; 2788 eh->elf.got.offset = htab->got->_raw_size; 2789 if ((eh->tls_mask & TLS_TLS) != 0) 2790 { 2791 if ((eh->tls_mask & TLS_LD) != 0) 2792 htab->got->_raw_size += 8; 2793 if ((eh->tls_mask & TLS_GD) != 0) 2794 htab->got->_raw_size += 8; 2795 if ((eh->tls_mask & (TLS_TPREL | TLS_TPRELGD)) != 0) 2796 htab->got->_raw_size += 4; 2797 if ((eh->tls_mask & TLS_DTPREL) != 0) 2798 htab->got->_raw_size += 4; 2799 } 2800 else 2801 htab->got->_raw_size += 4; 2802 dyn = htab->elf.dynamic_sections_created; 2803 if (info->shared 2804 || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, &eh->elf)) 2805 { 2806 /* All the entries we allocated need relocs. */ 2807 htab->relgot->_raw_size 2808 += ((htab->got->_raw_size - eh->elf.got.offset) / 4 2809 * sizeof (Elf32_External_Rela)); 2810 /* Except LD only needs one. */ 2811 if ((eh->tls_mask & TLS_LD) != 0) 2812 htab->relgot->_raw_size -= sizeof (Elf32_External_Rela); 2813 } 2814 } 2815 } 2816 else 2817 eh->elf.got.offset = (bfd_vma) -1; 2818 2819 if (eh->dyn_relocs == NULL) 2820 return TRUE; 2821 2822 /* In the shared -Bsymbolic case, discard space allocated for 2823 dynamic pc-relative relocs against symbols which turn out to be 2824 defined in regular objects. For the normal shared case, discard 2825 space for relocs that have become local due to symbol visibility 2826 changes. */ 2827 if (info->shared) 2828 { 2829 if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0 2830 && ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0 2831 || info->symbolic)) 2832 { 2833 struct ppc_elf_dyn_relocs **pp; 2834 2835 for (pp = &eh->dyn_relocs; (p = *pp) != NULL; ) 2836 { 2837 p->count -= p->pc_count; 2838 p->pc_count = 0; 2839 if (p->count == 0) 2840 *pp = p->next; 2841 else 2842 pp = &p->next; 2843 } 2844 } 2845 } 2846 else if (ELIMINATE_COPY_RELOCS) 2847 { 2848 /* For the non-shared case, discard space for relocs against 2849 symbols which turn out to need copy relocs or are not 2850 dynamic. */ 2851 2852 if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0 2853 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0 2854 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) 2855 { 2856 /* Make sure this symbol is output as a dynamic symbol. 2857 Undefined weak syms won't yet be marked as dynamic. */ 2858 if (h->dynindx == -1 2859 && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) 2860 { 2861 if (! bfd_elf64_link_record_dynamic_symbol (info, h)) 2862 return FALSE; 2863 } 2864 2865 /* If that succeeded, we know we'll be keeping all the 2866 relocs. */ 2867 if (h->dynindx != -1) 2868 goto keep; 2869 } 2870 2871 eh->dyn_relocs = NULL; 2872 2873 keep: ; 2874 } 2875 2876 /* Finally, allocate space. */ 2877 for (p = eh->dyn_relocs; p != NULL; p = p->next) 2878 { 2879 asection *sreloc = elf_section_data (p->sec)->sreloc; 2880 sreloc->_raw_size += p->count * sizeof (Elf32_External_Rela); 2881 } 2882 2883 return TRUE; 2884 } 2885 2886 /* Find any dynamic relocs that apply to read-only sections. */ 2887 2888 static bfd_boolean 2889 readonly_dynrelocs (h, info) 2890 struct elf_link_hash_entry *h; 2891 PTR info; 2892 { 2893 struct ppc_elf_dyn_relocs *p; 2894 2895 if (h->root.type == bfd_link_hash_indirect) 2896 return TRUE; 2897 2898 if (h->root.type == bfd_link_hash_warning) 2899 h = (struct elf_link_hash_entry *) h->root.u.i.link; 2900 2901 for (p = ppc_elf_hash_entry (h)->dyn_relocs; p != NULL; p = p->next) 2902 { 2903 asection *s = p->sec->output_section; 2904 2905 if (s != NULL 2906 && ((s->flags & (SEC_READONLY | SEC_ALLOC)) 2907 == (SEC_READONLY | SEC_ALLOC))) 2908 { 2909 ((struct bfd_link_info *) info)->flags |= DF_TEXTREL; 2910 2911 /* Not an error, just cut short the traversal. */ 2912 return FALSE; 2913 } 2914 } 2915 return TRUE; 2916 } 2917 1884 2918 /* Set the sizes of the dynamic sections. */ 1885 2919 1886 static b oolean2920 static bfd_boolean 1887 2921 ppc_elf_size_dynamic_sections (output_bfd, info) 1888 bfd *output_bfd ;2922 bfd *output_bfd ATTRIBUTE_UNUSED; 1889 2923 struct bfd_link_info *info; 1890 2924 { 1891 bfd *dynobj;2925 struct ppc_elf_link_hash_table *htab; 1892 2926 asection *s; 1893 boolean plt; 1894 boolean relocs; 1895 boolean reltext; 2927 bfd_boolean relocs; 2928 bfd *ibfd; 1896 2929 1897 2930 #ifdef DEBUG … … 1899 2932 #endif 1900 2933 1901 dynobj = elf_hash_table (info)->dynobj;1902 BFD_ASSERT ( dynobj != NULL);2934 htab = ppc_elf_hash_table (info); 2935 BFD_ASSERT (htab->elf.dynobj != NULL); 1903 2936 1904 2937 if (elf_hash_table (info)->dynamic_sections_created) … … 1907 2940 if (! info->shared) 1908 2941 { 1909 s = bfd_get_section_by_name ( dynobj, ".interp");2942 s = bfd_get_section_by_name (htab->elf.dynobj, ".interp"); 1910 2943 BFD_ASSERT (s != NULL); 1911 2944 s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; … … 1913 2946 } 1914 2947 } 2948 2949 if (htab->tlsld_got.refcount > 0) 2950 { 2951 htab->tlsld_got.offset = htab->got->_raw_size; 2952 htab->got->_raw_size += 8; 2953 if (info->shared) 2954 htab->relgot->_raw_size += sizeof (Elf32_External_Rela); 2955 } 1915 2956 else 2957 htab->tlsld_got.offset = (bfd_vma) -1; 2958 2959 /* Set up .got offsets for local syms, and space for local dynamic 2960 relocs. */ 2961 for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next) 1916 2962 { 1917 /* We may have created entries in the .rela.got, .rela.sdata, and1918 .rela.sdata2 sections. However, if we are not creating the 1919 dynamic sections, we will not actually use these entries. Reset 1920 the size of .rela.got, et al, which will cause it to get 1921 stripped from the output file below. */ 1922 static char *rela_sections[] = { ".rela.got", ".rela.sdata",1923 ".rela.sdata2", ".rela.sbss", 1924 (char *) 0 }; 1925 char **p;1926 1927 for ( p = rela_sections; *p != (char *) 0; p++)2963 bfd_signed_vma *local_got; 2964 bfd_signed_vma *end_local_got; 2965 char *lgot_masks; 2966 bfd_size_type locsymcount; 2967 Elf_Internal_Shdr *symtab_hdr; 2968 asection *srel; 2969 2970 if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour) 2971 continue; 2972 2973 for (s = ibfd->sections; s != NULL; s = s->next) 1928 2974 { 1929 s = bfd_get_section_by_name (dynobj, *p); 1930 if (s != NULL) 1931 s->_raw_size = 0; 2975 struct ppc_elf_dyn_relocs *p; 2976 2977 for (p = ((struct ppc_elf_dyn_relocs *) 2978 elf_section_data (s)->local_dynrel); 2979 p != NULL; 2980 p = p->next) 2981 { 2982 if (!bfd_is_abs_section (p->sec) 2983 && bfd_is_abs_section (p->sec->output_section)) 2984 { 2985 /* Input section has been discarded, either because 2986 it is a copy of a linkonce section or due to 2987 linker script /DISCARD/, so we'll be discarding 2988 the relocs too. */ 2989 } 2990 else if (p->count != 0) 2991 { 2992 elf_section_data (p->sec)->sreloc->_raw_size 2993 += p->count * sizeof (Elf32_External_Rela); 2994 if ((p->sec->output_section->flags 2995 & (SEC_READONLY | SEC_ALLOC)) 2996 == (SEC_READONLY | SEC_ALLOC)) 2997 info->flags |= DF_TEXTREL; 2998 } 2999 } 1932 3000 } 3001 3002 local_got = elf_local_got_refcounts (ibfd); 3003 if (!local_got) 3004 continue; 3005 3006 symtab_hdr = &elf_tdata (ibfd)->symtab_hdr; 3007 locsymcount = symtab_hdr->sh_info; 3008 end_local_got = local_got + locsymcount; 3009 lgot_masks = (char *) end_local_got; 3010 s = htab->got; 3011 srel = htab->relgot; 3012 for (; local_got < end_local_got; ++local_got, ++lgot_masks) 3013 if (*local_got > 0) 3014 { 3015 if (*lgot_masks == (TLS_TLS | TLS_LD)) 3016 { 3017 /* If just an LD reloc, we'll just use 3018 htab->tlsld_got.offset. */ 3019 if (htab->tlsld_got.offset == (bfd_vma) -1) 3020 { 3021 htab->tlsld_got.offset = s->_raw_size; 3022 s->_raw_size += 8; 3023 if (info->shared) 3024 srel->_raw_size += sizeof (Elf32_External_Rela); 3025 } 3026 *local_got = (bfd_vma) -1; 3027 } 3028 else 3029 { 3030 *local_got = s->_raw_size; 3031 if ((*lgot_masks & TLS_TLS) != 0) 3032 { 3033 if ((*lgot_masks & TLS_GD) != 0) 3034 s->_raw_size += 8; 3035 if ((*lgot_masks & (TLS_TPREL | TLS_TPRELGD)) != 0) 3036 s->_raw_size += 4; 3037 if ((*lgot_masks & TLS_DTPREL) != 0) 3038 s->_raw_size += 4; 3039 } 3040 else 3041 s->_raw_size += 4; 3042 if (info->shared) 3043 srel->_raw_size += ((s->_raw_size - *local_got) / 4 3044 * sizeof (Elf32_External_Rela)); 3045 } 3046 } 3047 else 3048 *local_got = (bfd_vma) -1; 1933 3049 } 1934 3050 1935 /* The check_relocs and adjust_dynamic_symbol entry points have1936 determined the sizes of the various dynamic sections. Allocate1937 memory for them. */ 1938 plt = false;1939 relocs = false;1940 rel text = false;1941 for (s = dynobj->sections; s != NULL; s = s->next)3051 /* Allocate space for global sym dynamic relocs. */ 3052 elf_link_hash_traverse (elf_hash_table (info), allocate_dynrelocs, info); 3053 3054 /* We've now determined the sizes of the various dynamic sections. 3055 Allocate memory for them. */ 3056 relocs = FALSE; 3057 for (s = htab->elf.dynobj->sections; s != NULL; s = s->next) 1942 3058 { 1943 const char *name;1944 boolean strip;1945 1946 3059 if ((s->flags & SEC_LINKER_CREATED) == 0) 1947 3060 continue; 1948 3061 1949 /* It's OK to base decisions on the section name, because none 1950 of the dynobj section names depend upon the input files. */ 1951 name = bfd_get_section_name (dynobj, s); 1952 1953 strip = false; 1954 1955 if (strcmp (name, ".plt") == 0) 3062 if (s == htab->plt 3063 || s == htab->got 3064 || (htab->sdata != NULL && s == htab->sdata->section) 3065 || (htab->sdata2 != NULL && s == htab->sdata2->section)) 1956 3066 { 1957 if (s->_raw_size == 0) 1958 { 1959 /* Strip this section if we don't need it; see the 1960 comment below. */ 1961 strip = true; 1962 } 1963 else 1964 { 1965 /* Remember whether there is a PLT. */ 1966 plt = true; 1967 } 3067 /* Strip this section if we don't need it; see the 3068 comment below. */ 1968 3069 } 1969 else if (strncmp ( name, ".rela", 5) == 0)3070 else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0) 1970 3071 { 1971 3072 if (s->_raw_size == 0) … … 1980 3081 function which decides whether anything needs to go 1981 3082 into these sections. */ 1982 strip = true;1983 3083 } 1984 3084 else 1985 3085 { 1986 asection *target;1987 const char *outname;1988 1989 3086 /* Remember whether there are any relocation sections. */ 1990 relocs = true; 1991 1992 /* If this relocation section applies to a read only 1993 section, then we probably need a DT_TEXTREL entry. */ 1994 outname = bfd_get_section_name (output_bfd, 1995 s->output_section); 1996 target = bfd_get_section_by_name (output_bfd, outname + 5); 1997 if (target != NULL 1998 && (target->flags & SEC_READONLY) != 0 1999 && (target->flags & SEC_ALLOC) != 0) 2000 reltext = true; 3087 relocs = TRUE; 2001 3088 2002 3089 /* We use the reloc_count field as a counter if we need … … 2005 3092 } 2006 3093 } 2007 else if (strcmp (name, ".got") != 0 2008 && strcmp (name, ".sdata") != 0 2009 && strcmp (name, ".sdata2") != 0) 3094 else 2010 3095 { 2011 3096 /* It's not one of our sections, so don't allocate space. */ … … 2013 3098 } 2014 3099 2015 if (s trip)3100 if (s->_raw_size == 0) 2016 3101 { 2017 3102 _bfd_strip_section_from_output (info, s); … … 2020 3105 2021 3106 /* Allocate memory for the section contents. */ 2022 s->contents = (bfd_byte *) bfd_zalloc ( dynobj, s->_raw_size);2023 if (s->contents == NULL && s->_raw_size != 0)2024 return false;3107 s->contents = (bfd_byte *) bfd_zalloc (htab->elf.dynobj, s->_raw_size); 3108 if (s->contents == NULL) 3109 return FALSE; 2025 3110 } 2026 3111 2027 if ( elf_hash_table (info)->dynamic_sections_created)3112 if (htab->elf.dynamic_sections_created) 2028 3113 { 2029 3114 /* Add some entries to the .dynamic section. We fill in the … … 2032 3117 the .dynamic section. The DT_DEBUG entry is filled in by the 2033 3118 dynamic linker and used by the debugger. */ 2034 if (! info->shared) 3119 #define add_dynamic_entry(TAG, VAL) \ 3120 bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) 3121 3122 if (!info->shared) 2035 3123 { 2036 if (! bfd_elf32_add_dynamic_entry (info,DT_DEBUG, 0))2037 return false;3124 if (!add_dynamic_entry (DT_DEBUG, 0)) 3125 return FALSE; 2038 3126 } 2039 3127 2040 if ( plt)3128 if (htab->plt != NULL && htab->plt->_raw_size != 0) 2041 3129 { 2042 if (! bfd_elf32_add_dynamic_entry (info,DT_PLTGOT, 0)2043 || ! bfd_elf32_add_dynamic_entry (info,DT_PLTRELSZ, 0)2044 || ! bfd_elf32_add_dynamic_entry (info,DT_PLTREL, DT_RELA)2045 || ! bfd_elf32_add_dynamic_entry (info,DT_JMPREL, 0))2046 return false;3130 if (!add_dynamic_entry (DT_PLTGOT, 0) 3131 || !add_dynamic_entry (DT_PLTRELSZ, 0) 3132 || !add_dynamic_entry (DT_PLTREL, DT_RELA) 3133 || !add_dynamic_entry (DT_JMPREL, 0)) 3134 return FALSE; 2047 3135 } 2048 3136 2049 3137 if (relocs) 2050 3138 { 2051 if (! bfd_elf32_add_dynamic_entry (info, DT_RELA, 0) 2052 || ! bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0) 2053 || ! bfd_elf32_add_dynamic_entry (info, DT_RELAENT, 2054 sizeof (Elf32_External_Rela))) 2055 return false; 3139 if (!add_dynamic_entry (DT_RELA, 0) 3140 || !add_dynamic_entry (DT_RELASZ, 0) 3141 || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela))) 3142 return FALSE; 2056 3143 } 2057 3144 2058 if (reltext) 3145 /* If any dynamic relocs apply to a read-only section, then we 3146 need a DT_TEXTREL entry. */ 3147 if ((info->flags & DF_TEXTREL) == 0) 3148 elf_link_hash_traverse (elf_hash_table (info), readonly_dynrelocs, 3149 (PTR) info); 3150 3151 if ((info->flags & DF_TEXTREL) != 0) 2059 3152 { 2060 if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0)) 2061 return false; 2062 info->flags |= DF_TEXTREL; 3153 if (!add_dynamic_entry (DT_TEXTREL, 0)) 3154 return FALSE; 2063 3155 } 2064 3156 } 2065 2066 return true; 3157 #undef add_dynamic_entry 3158 3159 return TRUE; 2067 3160 } 2068 3161 3162 3163 static bfd_boolean 3164 update_local_sym_info (abfd, symtab_hdr, r_symndx, tls_type) 3165 bfd *abfd; 3166 Elf_Internal_Shdr *symtab_hdr; 3167 unsigned long r_symndx; 3168 int tls_type; 3169 { 3170 bfd_signed_vma *local_got_refcounts = elf_local_got_refcounts (abfd); 3171 char *local_got_tls_masks; 3172 3173 if (local_got_refcounts == NULL) 3174 { 3175 bfd_size_type size = symtab_hdr->sh_info; 3176 3177 size *= sizeof (*local_got_refcounts) + sizeof (*local_got_tls_masks); 3178 local_got_refcounts = (bfd_signed_vma *) bfd_zalloc (abfd, size); 3179 if (local_got_refcounts == NULL) 3180 return FALSE; 3181 elf_local_got_refcounts (abfd) = local_got_refcounts; 3182 } 3183 3184 local_got_refcounts[r_symndx] += 1; 3185 local_got_tls_masks = (char *) (local_got_refcounts + symtab_hdr->sh_info); 3186 local_got_tls_masks[r_symndx] |= tls_type; 3187 return TRUE; 3188 } 3189 3190 static void 3191 bad_shared_reloc (abfd, r_type) 3192 bfd *abfd; 3193 enum elf_ppc_reloc_type r_type; 3194 { 3195 (*_bfd_error_handler) 3196 (_("%s: relocation %s cannot be used when making a shared object"), 3197 bfd_archive_filename (abfd), 3198 ppc_elf_howto_table[(int) r_type]->name); 3199 bfd_set_error (bfd_error_bad_value); 3200 } 2069 3201 2070 3202 /* Look through the relocs for a section during the first phase, and … … 2072 3204 table. */ 2073 3205 2074 static b oolean3206 static bfd_boolean 2075 3207 ppc_elf_check_relocs (abfd, info, sec, relocs) 2076 3208 bfd *abfd; … … 2079 3211 const Elf_Internal_Rela *relocs; 2080 3212 { 2081 bfd *dynobj;3213 struct ppc_elf_link_hash_table *htab; 2082 3214 Elf_Internal_Shdr *symtab_hdr; 2083 struct elf_link_hash_entry **sym_hashes , **sym_hashes_end;3215 struct elf_link_hash_entry **sym_hashes; 2084 3216 const Elf_Internal_Rela *rel; 2085 3217 const Elf_Internal_Rela *rel_end; 2086 bfd_signed_vma *local_got_refcounts;2087 elf_linker_section_t *sdata;2088 elf_linker_section_t *sdata2;2089 3218 asection *sreloc; 2090 asection *sgot = NULL;2091 asection *srelgot = NULL;2092 3219 2093 3220 if (info->relocateable) 2094 return true;3221 return TRUE; 2095 3222 2096 3223 #ifdef DEBUG 2097 3224 fprintf (stderr, "ppc_elf_check_relocs called for section %s in %s\n", 2098 3225 bfd_get_section_name (abfd, sec), 2099 bfd_ get_filename (abfd));3226 bfd_archive_filename (abfd)); 2100 3227 #endif 2101 3228 … … 2103 3230 special symbols are created. */ 2104 3231 2105 if ((sdata = elf_linker_section (abfd, LINKER_SECTION_SDATA)) == NULL) 3232 htab = ppc_elf_hash_table (info); 3233 if (htab->sdata == NULL) 2106 3234 { 2107 sdata = ppc_elf_create_linker_section (abfd, info, LINKER_SECTION_SDATA); 2108 if (!sdata) 2109 return false; 3235 htab->sdata = elf_linker_section (abfd, LINKER_SECTION_SDATA); 3236 if (htab->sdata == NULL) 3237 htab->sdata = ppc_elf_create_linker_section (abfd, info, 3238 LINKER_SECTION_SDATA); 3239 if (htab->sdata == NULL) 3240 return FALSE; 2110 3241 } 2111 3242 2112 if ( (sdata2 = elf_linker_section (abfd, LINKER_SECTION_SDATA2))== NULL)3243 if (htab->sdata2 == NULL) 2113 3244 { 2114 sdata2 = ppc_elf_create_linker_section (abfd, info, LINKER_SECTION_SDATA2); 2115 if (!sdata2) 2116 return false; 3245 htab->sdata2 = elf_linker_section (abfd, LINKER_SECTION_SDATA2); 3246 if (htab->sdata2 == NULL) 3247 htab->sdata2 = ppc_elf_create_linker_section (abfd, info, 3248 LINKER_SECTION_SDATA2); 3249 if (htab->sdata2 == NULL) 3250 return FALSE; 2117 3251 } 2118 3252 2119 dynobj = elf_hash_table (info)->dynobj;2120 3253 symtab_hdr = &elf_tdata (abfd)->symtab_hdr; 2121 local_got_refcounts = elf_local_got_refcounts (abfd);2122 2123 3254 sym_hashes = elf_sym_hashes (abfd); 2124 sym_hashes_end = sym_hashes + symtab_hdr->sh_size/sizeof (Elf32_External_Sym);2125 if (!elf_bad_symtab (abfd))2126 sym_hashes_end -= symtab_hdr->sh_info;2127 2128 3255 sreloc = NULL; 2129 3256 … … 2132 3259 { 2133 3260 unsigned long r_symndx; 3261 enum elf_ppc_reloc_type r_type; 2134 3262 struct elf_link_hash_entry *h; 3263 int tls_type = 0; 2135 3264 2136 3265 r_symndx = ELF32_R_SYM (rel->r_info); … … 2145 3274 if (h && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0) 2146 3275 { 2147 if ( sgot == NULL)3276 if (htab->got == NULL) 2148 3277 { 2149 if (dynobj == NULL) 2150 elf_hash_table (info)->dynobj = dynobj = abfd; 2151 if (! _bfd_elf_create_got_section (dynobj, info)) 2152 return false; 2153 sgot = bfd_get_section_by_name (dynobj, ".got"); 2154 BFD_ASSERT (sgot != NULL); 3278 if (htab->elf.dynobj == NULL) 3279 htab->elf.dynobj = abfd; 3280 if (!ppc_elf_create_got (htab->elf.dynobj, info)) 3281 return FALSE; 2155 3282 } 2156 3283 } 2157 3284 2158 switch (ELF32_R_TYPE (rel->r_info)) 3285 r_type = (enum elf_ppc_reloc_type) ELF32_R_TYPE (rel->r_info); 3286 switch (r_type) 2159 3287 { 2160 /* GOT16 relocations */ 3288 case R_PPC_GOT_TLSLD16: 3289 case R_PPC_GOT_TLSLD16_LO: 3290 case R_PPC_GOT_TLSLD16_HI: 3291 case R_PPC_GOT_TLSLD16_HA: 3292 htab->tlsld_got.refcount += 1; 3293 tls_type = TLS_TLS | TLS_LD; 3294 goto dogottls; 3295 3296 case R_PPC_GOT_TLSGD16: 3297 case R_PPC_GOT_TLSGD16_LO: 3298 case R_PPC_GOT_TLSGD16_HI: 3299 case R_PPC_GOT_TLSGD16_HA: 3300 tls_type = TLS_TLS | TLS_GD; 3301 goto dogottls; 3302 3303 case R_PPC_GOT_TPREL16: 3304 case R_PPC_GOT_TPREL16_LO: 3305 case R_PPC_GOT_TPREL16_HI: 3306 case R_PPC_GOT_TPREL16_HA: 3307 if (info->shared) 3308 info->flags |= DF_STATIC_TLS; 3309 tls_type = TLS_TLS | TLS_TPREL; 3310 goto dogottls; 3311 3312 case R_PPC_GOT_DTPREL16: 3313 case R_PPC_GOT_DTPREL16_LO: 3314 case R_PPC_GOT_DTPREL16_HI: 3315 case R_PPC_GOT_DTPREL16_HA: 3316 tls_type = TLS_TLS | TLS_DTPREL; 3317 dogottls: 3318 sec->has_tls_reloc = 1; 3319 /* Fall thru */ 3320 3321 /* GOT16 relocations */ 2161 3322 case R_PPC_GOT16: 2162 3323 case R_PPC_GOT16_LO: … … 2164 3325 case R_PPC_GOT16_HA: 2165 3326 /* This symbol requires a global offset table entry. */ 2166 2167 if (sgot == NULL) 3327 if (htab->got == NULL) 2168 3328 { 2169 if (dynobj == NULL) 2170 elf_hash_table (info)->dynobj = dynobj = abfd; 2171 if (! _bfd_elf_create_got_section (dynobj, info)) 2172 return false; 2173 sgot = bfd_get_section_by_name (dynobj, ".got"); 2174 BFD_ASSERT (sgot != NULL); 3329 if (htab->elf.dynobj == NULL) 3330 htab->elf.dynobj = abfd; 3331 if (!ppc_elf_create_got (htab->elf.dynobj, info)) 3332 return FALSE; 2175 3333 } 2176 2177 if (srelgot == NULL2178 && (h != NULL || info->shared))2179 {2180 srelgot = bfd_get_section_by_name (dynobj, ".rela.got");2181 if (srelgot == NULL)2182 {2183 srelgot = bfd_make_section (dynobj, ".rela.got");2184 if (srelgot == NULL2185 || ! bfd_set_section_flags (dynobj, srelgot,2186 (SEC_ALLOC2187 | SEC_LOAD2188 | SEC_HAS_CONTENTS2189 | SEC_IN_MEMORY2190 | SEC_LINKER_CREATED2191 | SEC_READONLY))2192 || ! bfd_set_section_alignment (dynobj, srelgot, 2))2193 return false;2194 }2195 }2196 2197 3334 if (h != NULL) 2198 3335 { 2199 if (h->got.refcount == -1) 2200 { 2201 /* Make sure this symbol is output as a dynamic symbol. */ 2202 if (h->dynindx == -1) 2203 if (!bfd_elf32_link_record_dynamic_symbol (info, h)) 2204 return false; 2205 2206 /* Allocate space in the .got. */ 2207 sgot->_raw_size += 4; 2208 /* Allocate relocation space. */ 2209 srelgot->_raw_size += sizeof (Elf32_External_Rela); 2210 2211 h->got.refcount = 1; 2212 } 2213 else 2214 h->got.refcount++; 3336 h->got.refcount += 1; 3337 ppc_elf_hash_entry (h)->tls_mask |= tls_type; 2215 3338 } 2216 3339 else 2217 { 2218 /* This is a global offset table entry for a local symbol. */ 2219 if (local_got_refcounts == NULL) 2220 { 2221 size_t size; 2222 2223 size = symtab_hdr->sh_info * sizeof (bfd_signed_vma); 2224 local_got_refcounts = (bfd_signed_vma *) 2225 bfd_alloc (abfd, size); 2226 if (local_got_refcounts == NULL) 2227 return false; 2228 elf_local_got_refcounts (abfd) = local_got_refcounts; 2229 memset (local_got_refcounts, -1, size); 2230 } 2231 if (local_got_refcounts[r_symndx] == -1) 2232 { 2233 sgot->_raw_size += 4; 2234 2235 /* If we are generating a shared object, we need to 2236 output a R_PPC_RELATIVE reloc so that the 2237 dynamic linker can adjust this GOT entry. */ 2238 if (info->shared) 2239 srelgot->_raw_size += sizeof (Elf32_External_Rela); 2240 2241 local_got_refcounts[r_symndx] = 1; 2242 } 2243 else 2244 local_got_refcounts[r_symndx]++; 2245 } 3340 /* This is a global offset table entry for a local symbol. */ 3341 if (!update_local_sym_info (abfd, symtab_hdr, r_symndx, tls_type)) 3342 return FALSE; 2246 3343 break; 2247 3344 2248 /* Indirect .sdata relocation*/3345 /* Indirect .sdata relocation. */ 2249 3346 case R_PPC_EMB_SDAI16: 2250 3347 if (info->shared) 2251 3348 { 2252 ((*_bfd_error_handler) 2253 (_("%s: relocation %s cannot be used when making a shared object"), 2254 bfd_get_filename (abfd), "R_PPC_EMB_SDAI16")); 2255 return false; 3349 bad_shared_reloc (abfd, r_type); 3350 return FALSE; 2256 3351 } 2257 2258 if (srelgot == NULL && (h != NULL || info->shared)) 2259 { 2260 srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); 2261 if (srelgot == NULL) 2262 { 2263 srelgot = bfd_make_section (dynobj, ".rela.got"); 2264 if (srelgot == NULL 2265 || ! bfd_set_section_flags (dynobj, srelgot, 2266 (SEC_ALLOC 2267 | SEC_LOAD 2268 | SEC_HAS_CONTENTS 2269 | SEC_IN_MEMORY 2270 | SEC_LINKER_CREATED 2271 | SEC_READONLY)) 2272 || ! bfd_set_section_alignment (dynobj, srelgot, 2)) 2273 return false; 2274 } 2275 } 2276 2277 if (!bfd_elf32_create_pointer_linker_section (abfd, info, sdata, h, rel)) 2278 return false; 2279 3352 if (!bfd_elf32_create_pointer_linker_section (abfd, info, 3353 htab->sdata, h, rel)) 3354 return FALSE; 2280 3355 break; 2281 3356 2282 /* Indirect .sdata2 relocation*/3357 /* Indirect .sdata2 relocation. */ 2283 3358 case R_PPC_EMB_SDA2I16: 2284 3359 if (info->shared) 2285 3360 { 2286 ((*_bfd_error_handler) 2287 (_("%s: relocation %s cannot be used when making a shared object"), 2288 bfd_get_filename (abfd), "R_PPC_EMB_SDA2I16")); 2289 return false; 3361 bad_shared_reloc (abfd, r_type); 3362 return FALSE; 2290 3363 } 2291 2292 if (srelgot == NULL && (h != NULL || info->shared)) 2293 { 2294 srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); 2295 if (srelgot == NULL) 2296 { 2297 srelgot = bfd_make_section (dynobj, ".rela.got"); 2298 if (srelgot == NULL 2299 || ! bfd_set_section_flags (dynobj, srelgot, 2300 (SEC_ALLOC 2301 | SEC_LOAD 2302 | SEC_HAS_CONTENTS 2303 | SEC_IN_MEMORY 2304 | SEC_LINKER_CREATED 2305 | SEC_READONLY)) 2306 || ! bfd_set_section_alignment (dynobj, srelgot, 2)) 2307 return false; 2308 } 2309 } 2310 2311 if (!bfd_elf32_create_pointer_linker_section (abfd, info, sdata2, h, rel)) 2312 return false; 2313 3364 if (!bfd_elf32_create_pointer_linker_section (abfd, info, 3365 htab->sdata2, h, rel)) 3366 return FALSE; 2314 3367 break; 2315 3368 … … 2317 3370 case R_PPC_EMB_SDA2REL: 2318 3371 case R_PPC_EMB_SDA21: 3372 case R_PPC_EMB_RELSDA: 3373 case R_PPC_EMB_NADDR32: 3374 case R_PPC_EMB_NADDR16: 3375 case R_PPC_EMB_NADDR16_LO: 3376 case R_PPC_EMB_NADDR16_HI: 3377 case R_PPC_EMB_NADDR16_HA: 2319 3378 if (info->shared) 2320 3379 { 2321 ((*_bfd_error_handler) 2322 (_("%s: relocation %s cannot be used when making a shared object"), 2323 bfd_get_filename (abfd), 2324 ppc_elf_howto_table[(int) ELF32_R_TYPE (rel->r_info)]->name)); 2325 return false; 3380 bad_shared_reloc (abfd, r_type); 3381 return FALSE; 2326 3382 } 2327 3383 break; … … 2329 3385 case R_PPC_PLT32: 2330 3386 case R_PPC_PLTREL24: 3387 case R_PPC_PLTREL32: 2331 3388 case R_PPC_PLT16_LO: 2332 3389 case R_PPC_PLT16_HI: … … 2336 3393 #endif 2337 3394 /* This symbol requires a procedure linkage table entry. We 2338 actually build the entry in adjust_dynamic_symbol,2339 2340 2341 3395 actually build the entry in finish_dynamic_symbol, 3396 because this might be a case of linking PIC code without 3397 linking in any dynamic objects, in which case we don't 3398 need to generate a procedure linkage table after all. */ 2342 3399 2343 3400 if (h == NULL) 2344 3401 { 2345 3402 /* It does not make sense to have a procedure linkage 2346 3403 table entry for a local symbol. */ 2347 3404 bfd_set_error (bfd_error_bad_value); 2348 return false;3405 return FALSE; 2349 3406 } 2350 3407 2351 /* Make sure this symbol is output as a dynamic symbol. */ 2352 if (h->dynindx == -1) 2353 { 2354 if (! bfd_elf32_link_record_dynamic_symbol (info, h)) 2355 return false; 2356 } 2357 if (h->plt.refcount == -1) 2358 { 2359 h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT; 2360 h->plt.refcount = 1; 2361 } 2362 else 2363 h->plt.refcount++; 3408 h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT; 3409 h->plt.refcount++; 2364 3410 break; 2365 3411 … … 2371 3417 case R_PPC_SECTOFF_HI: 2372 3418 case R_PPC_SECTOFF_HA: 3419 case R_PPC_DTPREL16: 3420 case R_PPC_DTPREL16_LO: 3421 case R_PPC_DTPREL16_HI: 3422 case R_PPC_DTPREL16_HA: 3423 case R_PPC_TOC16: 2373 3424 break; 2374 3425 2375 /* This refers only to functions defined in the shared library */ 3426 /* This are just markers. */ 3427 case R_PPC_TLS: 3428 case R_PPC_EMB_MRKREF: 3429 case R_PPC_NONE: 3430 case R_PPC_max: 3431 break; 3432 3433 /* These should only appear in dynamic objects. */ 3434 case R_PPC_COPY: 3435 case R_PPC_GLOB_DAT: 3436 case R_PPC_JMP_SLOT: 3437 case R_PPC_RELATIVE: 3438 break; 3439 3440 /* These aren't handled yet. We'll report an error later. */ 3441 case R_PPC_ADDR30: 3442 case R_PPC_EMB_RELSEC16: 3443 case R_PPC_EMB_RELST_LO: 3444 case R_PPC_EMB_RELST_HI: 3445 case R_PPC_EMB_RELST_HA: 3446 case R_PPC_EMB_BIT_FLD: 3447 break; 3448 3449 /* This refers only to functions defined in the shared library. */ 2376 3450 case R_PPC_LOCAL24PC: 2377 3451 break; … … 2381 3455 case R_PPC_GNU_VTINHERIT: 2382 3456 if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) 2383 return false;3457 return FALSE; 2384 3458 break; 2385 3459 … … 2388 3462 case R_PPC_GNU_VTENTRY: 2389 3463 if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend)) 2390 return false;3464 return FALSE; 2391 3465 break; 3466 3467 /* We shouldn't really be seeing these. */ 3468 case R_PPC_TPREL32: 3469 if (info->shared) 3470 info->flags |= DF_STATIC_TLS; 3471 goto dodyn; 3472 3473 /* Nor these. */ 3474 case R_PPC_DTPMOD32: 3475 case R_PPC_DTPREL32: 3476 goto dodyn; 3477 3478 case R_PPC_TPREL16: 3479 case R_PPC_TPREL16_LO: 3480 case R_PPC_TPREL16_HI: 3481 case R_PPC_TPREL16_HA: 3482 if (info->shared) 3483 info->flags |= DF_STATIC_TLS; 3484 goto dodyn; 2392 3485 2393 3486 /* When creating a shared object, we must copy these … … 2400 3493 case R_PPC_REL32: 2401 3494 if (h == NULL 2402 || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0 2403 || SYMBOL_REFERENCES_LOCAL (info, h)) 3495 || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0) 2404 3496 break; 2405 3497 /* fall through */ 2406 3498 2407 default: 2408 if (info->shared) 3499 case R_PPC_ADDR32: 3500 case R_PPC_ADDR24: 3501 case R_PPC_ADDR16: 3502 case R_PPC_ADDR16_LO: 3503 case R_PPC_ADDR16_HI: 3504 case R_PPC_ADDR16_HA: 3505 case R_PPC_ADDR14: 3506 case R_PPC_ADDR14_BRTAKEN: 3507 case R_PPC_ADDR14_BRNTAKEN: 3508 case R_PPC_UADDR32: 3509 case R_PPC_UADDR16: 3510 if (h != NULL && !info->shared) 2409 3511 { 3512 /* We may need a plt entry if the symbol turns out to be 3513 a function defined in a dynamic object. */ 3514 h->plt.refcount++; 3515 3516 /* We may need a copy reloc too. */ 3517 h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF; 3518 } 3519 3520 dodyn: 3521 /* If we are creating a shared library, and this is a reloc 3522 against a global symbol, or a non PC relative reloc 3523 against a local symbol, then we need to copy the reloc 3524 into the shared library. However, if we are linking with 3525 -Bsymbolic, we do not need to copy a reloc against a 3526 global symbol which is defined in an object we are 3527 including in the link (i.e., DEF_REGULAR is set). At 3528 this point we have not seen all the input files, so it is 3529 possible that DEF_REGULAR is not set now but will be set 3530 later (it is never cleared). In case of a weak definition, 3531 DEF_REGULAR may be cleared later by a strong definition in 3532 a shared library. We account for that possibility below by 3533 storing information in the dyn_relocs field of the hash 3534 table entry. A similar situation occurs when creating 3535 shared libraries and symbol visibility changes render the 3536 symbol local. 3537 3538 If on the other hand, we are creating an executable, we 3539 may need to keep relocations for symbols satisfied by a 3540 dynamic library if we manage to avoid copy relocs for the 3541 symbol. */ 3542 if ((info->shared 3543 && (MUST_BE_DYN_RELOC (r_type) 3544 || (h != NULL 3545 && (! info->symbolic 3546 || h->root.type == bfd_link_hash_defweak 3547 || (h->elf_link_hash_flags 3548 & ELF_LINK_HASH_DEF_REGULAR) == 0)))) 3549 || (ELIMINATE_COPY_RELOCS 3550 && !info->shared 3551 && (sec->flags & SEC_ALLOC) != 0 3552 && h != NULL 3553 && (h->root.type == bfd_link_hash_defweak 3554 || (h->elf_link_hash_flags 3555 & ELF_LINK_HASH_DEF_REGULAR) == 0))) 3556 { 3557 struct ppc_elf_dyn_relocs *p; 3558 struct ppc_elf_dyn_relocs **head; 3559 2410 3560 #ifdef DEBUG 2411 3561 fprintf (stderr, "ppc_elf_check_relocs need to create relocation for %s\n", 2412 (h && h->root.root.string) ? h->root.root.string : "<unknown>"); 3562 (h && h->root.root.string 3563 ? h->root.root.string : "<unknown>")); 2413 3564 #endif 2414 3565 if (sreloc == NULL) … … 2421 3572 elf_section_data (sec)->rel_hdr.sh_name)); 2422 3573 if (name == NULL) 2423 return false;3574 return FALSE; 2424 3575 2425 3576 BFD_ASSERT (strncmp (name, ".rela", 5) == 0 … … 2427 3578 name + 5) == 0); 2428 3579 2429 sreloc = bfd_get_section_by_name ( dynobj, name);3580 sreloc = bfd_get_section_by_name (htab->elf.dynobj, name); 2430 3581 if (sreloc == NULL) 2431 3582 { 2432 3583 flagword flags; 2433 3584 2434 sreloc = bfd_make_section ( dynobj, name);3585 sreloc = bfd_make_section (htab->elf.dynobj, name); 2435 3586 flags = (SEC_HAS_CONTENTS | SEC_READONLY 2436 3587 | SEC_IN_MEMORY | SEC_LINKER_CREATED); … … 2438 3589 flags |= SEC_ALLOC | SEC_LOAD; 2439 3590 if (sreloc == NULL 2440 || ! bfd_set_section_flags (dynobj, sreloc, flags) 2441 || ! bfd_set_section_alignment (dynobj, sreloc, 2)) 2442 return false; 3591 || ! bfd_set_section_flags (htab->elf.dynobj, 3592 sreloc, flags) 3593 || ! bfd_set_section_alignment (htab->elf.dynobj, 3594 sreloc, 2)) 3595 return FALSE; 2443 3596 } 3597 elf_section_data (sec)->sreloc = sreloc; 2444 3598 } 2445 3599 2446 sreloc->_raw_size += sizeof (Elf32_External_Rela); 2447 2448 /* FIXME: We should here do what the m68k and i386 2449 backends do: if the reloc is pc-relative, record it 2450 in case it turns out that the reloc is unnecessary 2451 because the symbol is forced local by versioning or 2452 we are linking with -Bdynamic. Fortunately this 2453 case is not frequent. */ 3600 /* If this is a global symbol, we count the number of 3601 relocations we need for this symbol. */ 3602 if (h != NULL) 3603 { 3604 head = &ppc_elf_hash_entry (h)->dyn_relocs; 3605 } 3606 else 3607 { 3608 /* Track dynamic relocs needed for local syms too. 3609 We really need local syms available to do this 3610 easily. Oh well. */ 3611 3612 asection *s; 3613 s = bfd_section_from_r_symndx (abfd, &htab->sym_sec, 3614 sec, r_symndx); 3615 if (s == NULL) 3616 return FALSE; 3617 3618 head = ((struct ppc_elf_dyn_relocs **) 3619 &elf_section_data (s)->local_dynrel); 3620 } 3621 3622 p = *head; 3623 if (p == NULL || p->sec != sec) 3624 { 3625 p = ((struct ppc_elf_dyn_relocs *) 3626 bfd_alloc (htab->elf.dynobj, sizeof *p)); 3627 if (p == NULL) 3628 return FALSE; 3629 p->next = *head; 3630 *head = p; 3631 p->sec = sec; 3632 p->count = 0; 3633 p->pc_count = 0; 3634 } 3635 3636 p->count += 1; 3637 if (!MUST_BE_DYN_RELOC (r_type)) 3638 p->pc_count += 1; 2454 3639 } 2455 3640 … … 2458 3643 } 2459 3644 2460 return true;3645 return TRUE; 2461 3646 } 2462 3647 … … 2465 3650 2466 3651 static asection * 2467 ppc_elf_gc_mark_hook ( abfd, info, rel, h, sym)2468 bfd *abfd;3652 ppc_elf_gc_mark_hook (sec, info, rel, h, sym) 3653 asection *sec; 2469 3654 struct bfd_link_info *info ATTRIBUTE_UNUSED; 2470 3655 Elf_Internal_Rela *rel; … … 2496 3681 } 2497 3682 else 2498 { 2499 if (!(elf_bad_symtab (abfd) 2500 && ELF_ST_BIND (sym->st_info) != STB_LOCAL) 2501 && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE) 2502 && sym->st_shndx != SHN_COMMON)) 2503 { 2504 return bfd_section_from_elf_index (abfd, sym->st_shndx); 2505 } 2506 } 3683 return bfd_section_from_elf_index (sec->owner, sym->st_shndx); 2507 3684 2508 3685 return NULL; 2509 3686 } 2510 3687 2511 /* Update the got entry reference counts for the section being removed. */ 2512 2513 static boolean 3688 /* Update the got, plt and dynamic reloc reference counts for the 3689 section being removed. */ 3690 3691 static bfd_boolean 2514 3692 ppc_elf_gc_sweep_hook (abfd, info, sec, relocs) 2515 3693 bfd *abfd; 2516 struct bfd_link_info *info ATTRIBUTE_UNUSED;3694 struct bfd_link_info *info; 2517 3695 asection *sec; 2518 3696 const Elf_Internal_Rela *relocs; 2519 3697 { 3698 struct ppc_elf_link_hash_table *htab; 2520 3699 Elf_Internal_Shdr *symtab_hdr; 2521 3700 struct elf_link_hash_entry **sym_hashes; 2522 3701 bfd_signed_vma *local_got_refcounts; 2523 3702 const Elf_Internal_Rela *rel, *relend; 2524 unsigned long r_symndx; 2525 struct elf_link_hash_entry *h; 2526 3703 3704 elf_section_data (sec)->local_dynrel = NULL; 3705 3706 htab = ppc_elf_hash_table (info); 2527 3707 symtab_hdr = &elf_tdata (abfd)->symtab_hdr; 2528 3708 sym_hashes = elf_sym_hashes (abfd); … … 2531 3711 relend = relocs + sec->reloc_count; 2532 3712 for (rel = relocs; rel < relend; rel++) 2533 switch (ELF32_R_TYPE (rel->r_info)) 2534 { 2535 case R_PPC_GOT16: 2536 case R_PPC_GOT16_LO: 2537 case R_PPC_GOT16_HI: 2538 case R_PPC_GOT16_HA: 2539 r_symndx = ELF32_R_SYM (rel->r_info); 2540 if (r_symndx >= symtab_hdr->sh_info) 3713 { 3714 unsigned long r_symndx; 3715 enum elf_ppc_reloc_type r_type; 3716 struct elf_link_hash_entry *h = NULL; 3717 3718 r_symndx = ELF32_R_SYM (rel->r_info); 3719 if (r_symndx >= symtab_hdr->sh_info) 3720 { 3721 struct ppc_elf_dyn_relocs **pp, *p; 3722 struct ppc_elf_link_hash_entry *eh; 3723 3724 h = sym_hashes[r_symndx - symtab_hdr->sh_info]; 3725 eh = (struct ppc_elf_link_hash_entry *) h; 3726 3727 for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next) 3728 if (p->sec == sec) 3729 { 3730 /* Everything must go for SEC. */ 3731 *pp = p->next; 3732 break; 3733 } 3734 } 3735 3736 r_type = (enum elf_ppc_reloc_type) ELF32_R_TYPE (rel->r_info); 3737 switch (r_type) 3738 { 3739 case R_PPC_GOT_TLSLD16: 3740 case R_PPC_GOT_TLSLD16_LO: 3741 case R_PPC_GOT_TLSLD16_HI: 3742 case R_PPC_GOT_TLSLD16_HA: 3743 htab->tlsld_got.refcount -= 1; 3744 /* Fall thru */ 3745 3746 case R_PPC_GOT_TLSGD16: 3747 case R_PPC_GOT_TLSGD16_LO: 3748 case R_PPC_GOT_TLSGD16_HI: 3749 case R_PPC_GOT_TLSGD16_HA: 3750 case R_PPC_GOT_TPREL16: 3751 case R_PPC_GOT_TPREL16_LO: 3752 case R_PPC_GOT_TPREL16_HI: 3753 case R_PPC_GOT_TPREL16_HA: 3754 case R_PPC_GOT_DTPREL16: 3755 case R_PPC_GOT_DTPREL16_LO: 3756 case R_PPC_GOT_DTPREL16_HI: 3757 case R_PPC_GOT_DTPREL16_HA: 3758 case R_PPC_GOT16: 3759 case R_PPC_GOT16_LO: 3760 case R_PPC_GOT16_HI: 3761 case R_PPC_GOT16_HA: 3762 if (h != NULL) 3763 { 3764 if (h->got.refcount > 0) 3765 h->got.refcount--; 3766 } 3767 else if (local_got_refcounts != NULL) 3768 { 3769 if (local_got_refcounts[r_symndx] > 0) 3770 local_got_refcounts[r_symndx]--; 3771 } 3772 break; 3773 3774 case R_PPC_REL24: 3775 case R_PPC_REL14: 3776 case R_PPC_REL14_BRTAKEN: 3777 case R_PPC_REL14_BRNTAKEN: 3778 case R_PPC_REL32: 3779 if (h == NULL 3780 || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0) 3781 break; 3782 /* Fall thru */ 3783 3784 case R_PPC_ADDR32: 3785 case R_PPC_ADDR24: 3786 case R_PPC_ADDR16: 3787 case R_PPC_ADDR16_LO: 3788 case R_PPC_ADDR16_HI: 3789 case R_PPC_ADDR16_HA: 3790 case R_PPC_ADDR14: 3791 case R_PPC_ADDR14_BRTAKEN: 3792 case R_PPC_ADDR14_BRNTAKEN: 3793 case R_PPC_UADDR32: 3794 case R_PPC_UADDR16: 3795 case R_PPC_PLT32: 3796 case R_PPC_PLTREL24: 3797 case R_PPC_PLT16_LO: 3798 case R_PPC_PLT16_HI: 3799 case R_PPC_PLT16_HA: 3800 if (h != NULL) 3801 { 3802 if (h->plt.refcount > 0) 3803 h->plt.refcount--; 3804 } 3805 break; 3806 3807 default: 3808 break; 3809 } 3810 } 3811 return TRUE; 3812 } 3813 3814 /* Set htab->tls_sec and htab->tls_get_addr. */ 3815 3816 bfd_boolean 3817 ppc_elf_tls_setup (obfd, info) 3818 bfd *obfd; 3819 struct bfd_link_info *info; 3820 { 3821 asection *tls; 3822 struct ppc_elf_link_hash_table *htab; 3823 3824 htab = ppc_elf_hash_table (info); 3825 htab->tls_get_addr = elf_link_hash_lookup (&htab->elf, "__tls_get_addr", 3826 FALSE, FALSE, TRUE); 3827 3828 for (tls = obfd->sections; tls != NULL; tls = tls->next) 3829 if ((tls->flags & (SEC_THREAD_LOCAL | SEC_LOAD)) 3830 == (SEC_THREAD_LOCAL | SEC_LOAD)) 3831 break; 3832 htab->tls_sec = tls; 3833 3834 return tls != NULL; 3835 } 3836 3837 /* Run through all the TLS relocs looking for optimization 3838 opportunities. */ 3839 3840 bfd_boolean 3841 ppc_elf_tls_optimize (obfd, info) 3842 bfd *obfd ATTRIBUTE_UNUSED; 3843 struct bfd_link_info *info; 3844 { 3845 bfd *ibfd; 3846 asection *sec; 3847 struct ppc_elf_link_hash_table *htab; 3848 3849 if (info->relocateable || info->shared) 3850 return TRUE; 3851 3852 htab = ppc_elf_hash_table (info); 3853 for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next) 3854 { 3855 Elf_Internal_Sym *locsyms = NULL; 3856 Elf_Internal_Shdr *symtab_hdr = &elf_tdata (ibfd)->symtab_hdr; 3857 3858 for (sec = ibfd->sections; sec != NULL; sec = sec->next) 3859 if (sec->has_tls_reloc && !bfd_is_abs_section (sec->output_section)) 2541 3860 { 2542 h = sym_hashes[r_symndx - symtab_hdr->sh_info]; 2543 if (h->got.refcount > 0) 2544 h->got.refcount--; 3861 Elf_Internal_Rela *relstart, *rel, *relend; 3862 int expecting_tls_get_addr; 3863 3864 /* Read the relocations. */ 3865 relstart = _bfd_elf32_link_read_relocs (ibfd, sec, (PTR) NULL, 3866 (Elf_Internal_Rela *) NULL, 3867 info->keep_memory); 3868 if (relstart == NULL) 3869 return FALSE; 3870 3871 expecting_tls_get_addr = 0; 3872 relend = relstart + sec->reloc_count; 3873 for (rel = relstart; rel < relend; rel++) 3874 { 3875 enum elf_ppc_reloc_type r_type; 3876 unsigned long r_symndx; 3877 struct elf_link_hash_entry *h = NULL; 3878 char *tls_mask; 3879 char tls_set, tls_clear; 3880 bfd_boolean is_local; 3881 3882 r_symndx = ELF32_R_SYM (rel->r_info); 3883 if (r_symndx >= symtab_hdr->sh_info) 3884 { 3885 struct elf_link_hash_entry **sym_hashes; 3886 3887 sym_hashes = elf_sym_hashes (ibfd); 3888 h = sym_hashes[r_symndx - symtab_hdr->sh_info]; 3889 while (h->root.type == bfd_link_hash_indirect 3890 || h->root.type == bfd_link_hash_warning) 3891 h = (struct elf_link_hash_entry *) h->root.u.i.link; 3892 } 3893 3894 is_local = FALSE; 3895 if (h == NULL 3896 || !(h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC)) 3897 is_local = TRUE; 3898 3899 r_type = (enum elf_ppc_reloc_type) ELF32_R_TYPE (rel->r_info); 3900 switch (r_type) 3901 { 3902 case R_PPC_GOT_TLSLD16: 3903 case R_PPC_GOT_TLSLD16_LO: 3904 case R_PPC_GOT_TLSLD16_HI: 3905 case R_PPC_GOT_TLSLD16_HA: 3906 /* These relocs should never be against a symbol 3907 defined in a shared lib. Leave them alone if 3908 that turns out to be the case. */ 3909 expecting_tls_get_addr = 0; 3910 htab->tlsld_got.refcount -= 1; 3911 if (!is_local) 3912 continue; 3913 3914 /* LD -> LE */ 3915 tls_set = 0; 3916 tls_clear = TLS_LD; 3917 expecting_tls_get_addr = 1; 3918 break; 3919 3920 case R_PPC_GOT_TLSGD16: 3921 case R_PPC_GOT_TLSGD16_LO: 3922 case R_PPC_GOT_TLSGD16_HI: 3923 case R_PPC_GOT_TLSGD16_HA: 3924 if (is_local) 3925 /* GD -> LE */ 3926 tls_set = 0; 3927 else 3928 /* GD -> IE */ 3929 tls_set = TLS_TLS | TLS_TPRELGD; 3930 tls_clear = TLS_GD; 3931 expecting_tls_get_addr = 1; 3932 break; 3933 3934 case R_PPC_GOT_TPREL16: 3935 case R_PPC_GOT_TPREL16_LO: 3936 case R_PPC_GOT_TPREL16_HI: 3937 case R_PPC_GOT_TPREL16_HA: 3938 expecting_tls_get_addr = 0; 3939 if (is_local) 3940 { 3941 /* IE -> LE */ 3942 tls_set = 0; 3943 tls_clear = TLS_TPREL; 3944 break; 3945 } 3946 else 3947 continue; 3948 3949 case R_PPC_REL14: 3950 case R_PPC_REL14_BRTAKEN: 3951 case R_PPC_REL14_BRNTAKEN: 3952 case R_PPC_REL24: 3953 if (expecting_tls_get_addr 3954 && h != NULL 3955 && h == htab->tls_get_addr) 3956 { 3957 if (h->plt.refcount > 0) 3958 h->plt.refcount -= 1; 3959 } 3960 expecting_tls_get_addr = 0; 3961 continue; 3962 3963 default: 3964 expecting_tls_get_addr = 0; 3965 continue; 3966 } 3967 3968 if (h != NULL) 3969 { 3970 if (tls_set == 0) 3971 { 3972 /* We managed to get rid of a got entry. */ 3973 if (h->got.refcount > 0) 3974 h->got.refcount -= 1; 3975 } 3976 tls_mask = &ppc_elf_hash_entry (h)->tls_mask; 3977 } 3978 else 3979 { 3980 Elf_Internal_Sym *sym; 3981 bfd_signed_vma *lgot_refs; 3982 char *lgot_masks; 3983 3984 if (locsyms == NULL) 3985 { 3986 locsyms = (Elf_Internal_Sym *) symtab_hdr->contents; 3987 if (locsyms == NULL) 3988 locsyms = bfd_elf_get_elf_syms (ibfd, symtab_hdr, 3989 symtab_hdr->sh_info, 3990 0, NULL, NULL, NULL); 3991 if (locsyms == NULL) 3992 { 3993 if (elf_section_data (sec)->relocs != relstart) 3994 free (relstart); 3995 return FALSE; 3996 } 3997 } 3998 sym = locsyms + r_symndx; 3999 lgot_refs = elf_local_got_refcounts (ibfd); 4000 if (lgot_refs == NULL) 4001 abort (); 4002 if (tls_set == 0) 4003 { 4004 /* We managed to get rid of a got entry. */ 4005 if (lgot_refs[r_symndx] > 0) 4006 lgot_refs[r_symndx] -= 1; 4007 } 4008 lgot_masks = (char *) (lgot_refs + symtab_hdr->sh_info); 4009 tls_mask = &lgot_masks[r_symndx]; 4010 } 4011 4012 *tls_mask |= tls_set; 4013 *tls_mask &= ~tls_clear; 4014 } 4015 4016 if (elf_section_data (sec)->relocs != relstart) 4017 free (relstart); 2545 4018 } 2546 else if (local_got_refcounts != NULL) 2547 { 2548 if (local_got_refcounts[r_symndx] > 0) 2549 local_got_refcounts[r_symndx]--; 2550 } 2551 break; 2552 2553 case R_PPC_PLT32: 2554 case R_PPC_PLTREL24: 2555 case R_PPC_PLT16_LO: 2556 case R_PPC_PLT16_HI: 2557 case R_PPC_PLT16_HA: 2558 r_symndx = ELF32_R_SYM (rel->r_info); 2559 if (r_symndx >= symtab_hdr->sh_info) 2560 { 2561 h = sym_hashes[r_symndx - symtab_hdr->sh_info]; 2562 if (h->plt.refcount > 0) 2563 h->plt.refcount--; 2564 } 2565 break; 2566 2567 default: 2568 break; 2569 } 2570 2571 return true; 4019 4020 if (locsyms != NULL 4021 && (symtab_hdr->contents != (unsigned char *) locsyms)) 4022 { 4023 if (!info->keep_memory) 4024 free (locsyms); 4025 else 4026 symtab_hdr->contents = (unsigned char *) locsyms; 4027 } 4028 } 4029 return TRUE; 2572 4030 } 2573 4031 … … 2576 4034 file. We use it to put .comm items in .sbss, and not .bss. */ 2577 4035 2578 static b oolean4036 static bfd_boolean 2579 4037 ppc_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) 2580 4038 bfd *abfd; … … 2588 4046 if (sym->st_shndx == SHN_COMMON 2589 4047 && !info->relocateable 2590 && sym->st_size <= (bfd_vma) bfd_get_gp_size (abfd)) 4048 && sym->st_size <= elf_gp_size (abfd) 4049 && info->hash->creator->flavour == bfd_target_elf_flavour) 2591 4050 { 2592 4051 /* Common symbols less than or equal to -G nn bytes are automatically … … 2597 4056 if (!sdata->bss_section) 2598 4057 { 4058 bfd_size_type amt; 4059 2599 4060 /* We don't go through bfd_make_section, because we don't 2600 2601 2602 2603 sdata->bss_section = ((asection *)2604 bfd_zalloc (abfd, sizeof (asection)));4061 want to attach this common section to DYNOBJ. The linker 4062 will move the symbols to the appropriate output section 4063 when it defines common symbols. */ 4064 amt = sizeof (asection); 4065 sdata->bss_section = (asection *) bfd_zalloc (abfd, amt); 2605 4066 if (sdata->bss_section == NULL) 2606 return false;4067 return FALSE; 2607 4068 sdata->bss_section->name = sdata->bss_name; 2608 4069 sdata->bss_section->flags = SEC_IS_COMMON; 2609 4070 sdata->bss_section->output_section = sdata->bss_section; 2610 sdata->bss_section->symbol = 2611 (asymbol *) bfd_zalloc (abfd, sizeof (asymbol)); 4071 amt = sizeof (asymbol); 4072 sdata->bss_section->symbol = (asymbol *) bfd_zalloc (abfd, amt); 4073 amt = sizeof (asymbol *); 2612 4074 sdata->bss_section->symbol_ptr_ptr = 2613 (asymbol **) bfd_zalloc (abfd, sizeof (asymbol *));4075 (asymbol **) bfd_zalloc (abfd, amt); 2614 4076 if (sdata->bss_section->symbol == NULL 2615 4077 || sdata->bss_section->symbol_ptr_ptr == NULL) 2616 return false;4078 return FALSE; 2617 4079 sdata->bss_section->symbol->name = sdata->bss_name; 2618 4080 sdata->bss_section->symbol->flags = BSF_SECTION_SYM; … … 2625 4087 } 2626 4088 2627 return true;4089 return TRUE; 2628 4090 } 2629 4091 … … 2632 4094 dynamic sections here. */ 2633 4095 2634 static b oolean4096 static bfd_boolean 2635 4097 ppc_elf_finish_dynamic_symbol (output_bfd, info, h, sym) 2636 4098 bfd *output_bfd; … … 2639 4101 Elf_Internal_Sym *sym; 2640 4102 { 2641 bfd *dynobj;4103 struct ppc_elf_link_hash_table *htab; 2642 4104 2643 4105 #ifdef DEBUG … … 2646 4108 #endif 2647 4109 2648 dynobj = elf_hash_table (info)->dynobj;2649 BFD_ASSERT ( dynobj != NULL);4110 htab = ppc_elf_hash_table (info); 4111 BFD_ASSERT (htab->elf.dynobj != NULL); 2650 4112 2651 4113 if (h->plt.offset != (bfd_vma) -1) 2652 4114 { 2653 asection *splt;2654 asection *srela;2655 4115 Elf_Internal_Rela rela; 4116 bfd_byte *loc; 2656 4117 bfd_vma reloc_index; 2657 4118 … … 2661 4122 2662 4123 /* This symbol has an entry in the procedure linkage table. Set 2663 4124 it up. */ 2664 4125 2665 4126 BFD_ASSERT (h->dynindx != -1); 2666 2667 splt = bfd_get_section_by_name (dynobj, ".plt"); 2668 srela = bfd_get_section_by_name (dynobj, ".rela.plt"); 2669 BFD_ASSERT (splt != NULL && srela != NULL); 4127 BFD_ASSERT (htab->plt != NULL && htab->relplt != NULL); 2670 4128 2671 4129 /* We don't need to fill in the .plt. The ppc dynamic linker … … 2673 4131 2674 4132 /* Fill in the entry in the .rela.plt section. */ 2675 rela.r_offset = ( splt->output_section->vma2676 + splt->output_offset4133 rela.r_offset = (htab->plt->output_section->vma 4134 + htab->plt->output_offset 2677 4135 + h->plt.offset); 2678 4136 rela.r_info = ELF32_R_INFO (h->dynindx, R_PPC_JMP_SLOT); … … 2682 4140 if (reloc_index > PLT_NUM_SINGLE_ENTRIES) 2683 4141 reloc_index -= (reloc_index - PLT_NUM_SINGLE_ENTRIES) / 2; 2684 bfd_elf32_swap_reloca_out (output_bfd, &rela,2685 ((Elf32_External_Rela *) srela->contents2686 + reloc_index));4142 loc = (htab->relplt->contents 4143 + reloc_index * sizeof (Elf32_External_Rela)); 4144 bfd_elf32_swap_reloca_out (output_bfd, &rela, loc); 2687 4145 2688 4146 if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) … … 2701 4159 } 2702 4160 2703 if (h->got.offset != (bfd_vma) -1)2704 {2705 asection *sgot;2706 asection *srela;2707 Elf_Internal_Rela rela;2708 2709 /* This symbol has an entry in the global offset table. Set it2710 up. */2711 2712 sgot = bfd_get_section_by_name (dynobj, ".got");2713 srela = bfd_get_section_by_name (dynobj, ".rela.got");2714 BFD_ASSERT (sgot != NULL && srela != NULL);2715 2716 rela.r_offset = (sgot->output_section->vma2717 + sgot->output_offset2718 + (h->got.offset &~ 1));2719 2720 /* If this is a -Bsymbolic link, and the symbol is defined2721 locally, we just want to emit a RELATIVE reloc. The entry in2722 the global offset table will already have been initialized in2723 the relocate_section function. */2724 if (info->shared2725 && SYMBOL_REFERENCES_LOCAL (info, h))2726 {2727 rela.r_info = ELF32_R_INFO (0, R_PPC_RELATIVE);2728 rela.r_addend = (h->root.u.def.value2729 + h->root.u.def.section->output_section->vma2730 + h->root.u.def.section->output_offset);2731 }2732 else2733 {2734 BFD_ASSERT ((h->got.offset & 1) == 0);2735 bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset);2736 rela.r_info = ELF32_R_INFO (h->dynindx, R_PPC_GLOB_DAT);2737 rela.r_addend = 0;2738 }2739 2740 bfd_elf32_swap_reloca_out (output_bfd, &rela,2741 ((Elf32_External_Rela *) srela->contents2742 + srela->reloc_count));2743 ++srela->reloc_count;2744 }2745 2746 4161 if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0) 2747 4162 { 2748 4163 asection *s; 2749 4164 Elf_Internal_Rela rela; 4165 bfd_byte *loc; 2750 4166 2751 4167 /* This symbols needs a copy reloc. Set it up. */ … … 2757 4173 BFD_ASSERT (h->dynindx != -1); 2758 4174 2759 if (h->size <= elf_gp_size (dynobj)) 2760 s = bfd_get_section_by_name (h->root.u.def.section->owner, 2761 ".rela.sbss"); 4175 if (h->size <= elf_gp_size (htab->elf.dynobj)) 4176 s = htab->relsbss; 2762 4177 else 2763 s = bfd_get_section_by_name (h->root.u.def.section->owner, 2764 ".rela.bss"); 4178 s = htab->relbss; 2765 4179 BFD_ASSERT (s != NULL); 2766 4180 … … 2770 4184 rela.r_info = ELF32_R_INFO (h->dynindx, R_PPC_COPY); 2771 4185 rela.r_addend = 0; 2772 bfd_elf32_swap_reloca_out (output_bfd, &rela, 2773 ((Elf32_External_Rela *) s->contents 2774 + s->reloc_count)); 2775 ++s->reloc_count; 4186 loc = s->contents + s->reloc_count++ * sizeof (Elf32_External_Rela); 4187 bfd_elf32_swap_reloca_out (output_bfd, &rela, loc); 2776 4188 } 2777 4189 … … 2786 4198 sym->st_shndx = SHN_ABS; 2787 4199 2788 return true;4200 return TRUE; 2789 4201 } 2790 4202 … … 2792 4204 /* Finish up the dynamic sections. */ 2793 4205 2794 static b oolean4206 static bfd_boolean 2795 4207 ppc_elf_finish_dynamic_sections (output_bfd, info) 2796 4208 bfd *output_bfd; … … 2798 4210 { 2799 4211 asection *sdyn; 2800 bfd *dynobj = elf_hash_table (info)->dynobj; 2801 asection *sgot = bfd_get_section_by_name (dynobj, ".got"); 4212 struct ppc_elf_link_hash_table *htab; 2802 4213 2803 4214 #ifdef DEBUG … … 2805 4216 #endif 2806 4217 2807 sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); 2808 2809 if (elf_hash_table (info)->dynamic_sections_created) 4218 htab = ppc_elf_hash_table (info); 4219 sdyn = bfd_get_section_by_name (htab->elf.dynobj, ".dynamic"); 4220 4221 if (htab->elf.dynamic_sections_created) 2810 4222 { 2811 asection *splt;2812 4223 Elf32_External_Dyn *dyncon, *dynconend; 2813 4224 2814 splt = bfd_get_section_by_name (dynobj, ".plt"); 2815 BFD_ASSERT (splt != NULL && sdyn != NULL); 4225 BFD_ASSERT (htab->plt != NULL && sdyn != NULL); 2816 4226 2817 4227 dyncon = (Elf32_External_Dyn *) sdyn->contents; … … 2820 4230 { 2821 4231 Elf_Internal_Dyn dyn; 2822 const char *name; 2823 boolean size; 2824 2825 bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn); 4232 asection *s; 4233 4234 bfd_elf32_swap_dyn_in (htab->elf.dynobj, dyncon, &dyn); 2826 4235 2827 4236 switch (dyn.d_tag) 2828 4237 { 2829 case DT_PLTGOT: name = ".plt"; size = false; break; 2830 case DT_PLTRELSZ: name = ".rela.plt"; size = true; break; 2831 case DT_JMPREL: name = ".rela.plt"; size = false; break; 2832 default: name = NULL; size = false; break; 4238 case DT_PLTGOT: 4239 s = htab->plt; 4240 dyn.d_un.d_ptr = s->output_section->vma + s->output_offset; 4241 break; 4242 4243 case DT_PLTRELSZ: 4244 dyn.d_un.d_val = htab->relplt->_raw_size; 4245 break; 4246 4247 case DT_JMPREL: 4248 s = htab->relplt; 4249 dyn.d_un.d_ptr = s->output_section->vma + s->output_offset; 4250 break; 4251 4252 default: 4253 continue; 2833 4254 } 2834 4255 2835 if (name != NULL) 2836 { 2837 asection *s; 2838 2839 s = bfd_get_section_by_name (output_bfd, name); 2840 if (s == NULL) 2841 dyn.d_un.d_val = 0; 2842 else 2843 { 2844 if (! size) 2845 dyn.d_un.d_ptr = s->vma; 2846 else 2847 { 2848 if (s->_cooked_size != 0) 2849 dyn.d_un.d_val = s->_cooked_size; 2850 else 2851 dyn.d_un.d_val = s->_raw_size; 2852 } 2853 } 2854 bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); 2855 } 4256 bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); 2856 4257 } 2857 4258 } … … 2859 4260 /* Add a blrl instruction at _GLOBAL_OFFSET_TABLE_-4 so that a function can 2860 4261 easily find the address of the _GLOBAL_OFFSET_TABLE_. */ 2861 if ( sgot)4262 if (htab->got) 2862 4263 { 2863 unsigned char *contents = sgot->contents;2864 bfd_put_32 (output_bfd, 0x4e800021 /* blrl */, contents);4264 unsigned char *contents = htab->got->contents; 4265 bfd_put_32 (output_bfd, (bfd_vma) 0x4e800021 /* blrl */, contents); 2865 4266 2866 4267 if (sdyn == NULL) 2867 bfd_put_32 (output_bfd, (bfd_vma) 0, contents +4);4268 bfd_put_32 (output_bfd, (bfd_vma) 0, contents + 4); 2868 4269 else 2869 4270 bfd_put_32 (output_bfd, 2870 4271 sdyn->output_section->vma + sdyn->output_offset, 2871 contents +4);2872 2873 elf_section_data ( sgot->output_section)->this_hdr.sh_entsize = 4;4272 contents + 4); 4273 4274 elf_section_data (htab->got->output_section)->this_hdr.sh_entsize = 4; 2874 4275 } 2875 4276 2876 return true;4277 return TRUE; 2877 4278 } 2878 4279 … … 2907 4308 accordingly. */ 2908 4309 2909 static b oolean4310 static bfd_boolean 2910 4311 ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, 2911 4312 contents, relocs, local_syms, local_sections) … … 2919 4320 asection **local_sections; 2920 4321 { 2921 Elf_Internal_Shdr *symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; 2922 struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd); 2923 bfd *dynobj = elf_hash_table (info)->dynobj; 2924 elf_linker_section_t *sdata = (dynobj) ? elf_linker_section (dynobj, LINKER_SECTION_SDATA) : NULL; 2925 elf_linker_section_t *sdata2 = (dynobj) ? elf_linker_section (dynobj, LINKER_SECTION_SDATA2) : NULL; 2926 Elf_Internal_Rela *rel = relocs; 2927 Elf_Internal_Rela *relend = relocs + input_section->reloc_count; 2928 asection *sreloc = NULL; 2929 asection *splt; 2930 asection *sgot; 4322 Elf_Internal_Shdr *symtab_hdr; 4323 struct elf_link_hash_entry **sym_hashes; 4324 struct ppc_elf_link_hash_table *htab; 4325 Elf_Internal_Rela *rel; 4326 Elf_Internal_Rela *relend; 4327 Elf_Internal_Rela outrel; 4328 bfd_byte *loc; 4329 asection *sreloc = NULL; 2931 4330 bfd_vma *local_got_offsets; 2932 boolean ret = true; 2933 long insn; 4331 bfd_boolean ret = TRUE; 2934 4332 2935 4333 #ifdef DEBUG 2936 4334 fprintf (stderr, "ppc_elf_relocate_section called for %s section %s, %ld relocations%s\n", 2937 bfd_ get_filename (input_bfd),4335 bfd_archive_filename (input_bfd), 2938 4336 bfd_section_name(input_bfd, input_section), 2939 4337 (long) input_section->reloc_count, … … 2941 4339 #endif 2942 4340 4341 if (info->relocateable) 4342 return TRUE; 4343 2943 4344 if (!ppc_elf_howto_table[R_PPC_ADDR32]) 2944 4345 /* Initialize howto table if needed. */ 2945 4346 ppc_elf_howto_init (); 2946 4347 4348 htab = ppc_elf_hash_table (info); 2947 4349 local_got_offsets = elf_local_got_offsets (input_bfd); 2948 2949 splt = sgot = NULL; 2950 if (dynobj != NULL) 2951 { 2952 splt = bfd_get_section_by_name (dynobj, ".plt"); 2953 sgot = bfd_get_section_by_name (dynobj, ".got"); 2954 } 2955 4350 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; 4351 sym_hashes = elf_sym_hashes (input_bfd); 4352 rel = relocs; 4353 relend = relocs + input_section->reloc_count; 2956 4354 for (; rel < relend; rel++) 2957 4355 { 2958 enum elf_ppc_reloc_type r_type = (enum elf_ppc_reloc_type)ELF32_R_TYPE (rel->r_info); 2959 bfd_vma offset = rel->r_offset; 2960 bfd_vma addend = rel->r_addend; 2961 bfd_reloc_status_type r = bfd_reloc_other; 2962 Elf_Internal_Sym *sym = (Elf_Internal_Sym *) 0; 2963 asection *sec = (asection *) 0; 2964 struct elf_link_hash_entry *h = (struct elf_link_hash_entry *) 0; 2965 const char *sym_name = (const char *) 0; 4356 enum elf_ppc_reloc_type r_type; 4357 bfd_vma addend; 4358 bfd_reloc_status_type r; 4359 Elf_Internal_Sym *sym; 4360 asection *sec; 4361 struct elf_link_hash_entry *h; 4362 const char *sym_name; 2966 4363 reloc_howto_type *howto; 2967 4364 unsigned long r_symndx; 2968 4365 bfd_vma relocation; 2969 int will_become_local; 2970 2971 /* Unknown relocation handling */ 2972 if ((unsigned) r_type >= (unsigned) R_PPC_max 2973 || !ppc_elf_howto_table[(int) r_type]) 2974 { 2975 (*_bfd_error_handler) (_("%s: unknown relocation type %d"), 2976 bfd_get_filename (input_bfd), 2977 (int) r_type); 2978 2979 bfd_set_error (bfd_error_bad_value); 2980 ret = false; 2981 continue; 2982 } 2983 2984 howto = ppc_elf_howto_table[(int) r_type]; 4366 bfd_vma branch_bit, insn, from; 4367 bfd_boolean unresolved_reloc; 4368 bfd_boolean warned; 4369 unsigned int tls_type, tls_mask, tls_gd; 4370 4371 r_type = (enum elf_ppc_reloc_type)ELF32_R_TYPE (rel->r_info); 4372 sym = (Elf_Internal_Sym *) 0; 4373 sec = (asection *) 0; 4374 h = (struct elf_link_hash_entry *) 0; 4375 unresolved_reloc = FALSE; 4376 warned = FALSE; 2985 4377 r_symndx = ELF32_R_SYM (rel->r_info); 2986 2987 if (info->relocateable)2988 {2989 /* This is a relocateable link. We don't have to change2990 anything, unless the reloc is against a section symbol,2991 in which case we have to adjust according to where the2992 section symbol winds up in the output section. */2993 if (r_symndx < symtab_hdr->sh_info)2994 {2995 sym = local_syms + r_symndx;2996 if ((unsigned) ELF_ST_TYPE (sym->st_info) == STT_SECTION)2997 {2998 sec = local_sections[r_symndx];2999 addend = rel->r_addend += sec->output_offset + sym->st_value;3000 }3001 }3002 3003 #ifdef DEBUG3004 fprintf (stderr, "\ttype = %s (%d), symbol index = %ld, offset = %ld, addend = %ld\n",3005 howto->name,3006 (int) r_type,3007 r_symndx,3008 (long) offset,3009 (long) addend);3010 #endif3011 continue;3012 }3013 3014 /* This is a final link. */3015 4378 if (r_symndx < symtab_hdr->sh_info) 3016 4379 { 3017 4380 sym = local_syms + r_symndx; 3018 4381 sec = local_sections[r_symndx]; 3019 sym_name = "<local symbol>"; 3020 3021 relocation = (sec->output_section->vma 3022 + sec->output_offset 3023 + sym->st_value); 3024 /* Relocs to local symbols are always resolved. */ 3025 will_become_local = 1; 4382 sym_name = bfd_elf_local_sym_name (input_bfd, sym); 4383 4384 relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel); 3026 4385 } 3027 4386 else … … 3033 4392 sym_name = h->root.root.string; 3034 4393 3035 /* Can this relocation be resolved immediately? */ 3036 will_become_local = SYMBOL_REFERENCES_LOCAL (info, h); 3037 4394 relocation = 0; 3038 4395 if (h->root.type == bfd_link_hash_defined 3039 4396 || h->root.type == bfd_link_hash_defweak) 3040 4397 { 3041 4398 sec = h->root.u.def.section; 3042 if (((r_type == R_PPC_PLT32 3043 || r_type == R_PPC_PLTREL24) 3044 && splt != NULL 3045 && h->plt.offset != (bfd_vma) -1) 3046 || (r_type == R_PPC_LOCAL24PC 3047 && sec->output_section == NULL) 3048 || ((r_type == R_PPC_GOT16 3049 || r_type == R_PPC_GOT16_LO 3050 || r_type == R_PPC_GOT16_HI 3051 || r_type == R_PPC_GOT16_HA) 3052 && elf_hash_table (info)->dynamic_sections_created 3053 && (! info->shared || ! will_become_local)) 3054 || (info->shared 3055 && ! will_become_local 3056 && ((input_section->flags & SEC_ALLOC) != 0 3057 /* Testing SEC_DEBUGGING here may be wrong. 3058 It's here to avoid a crash when 3059 generating a shared library with DWARF 3060 debugging information. */ 3061 || ((input_section->flags & SEC_DEBUGGING) != 0 3062 && (h->elf_link_hash_flags 3063 & ELF_LINK_HASH_DEF_DYNAMIC) != 0)) 3064 && (r_type == R_PPC_ADDR32 3065 || r_type == R_PPC_ADDR24 3066 || r_type == R_PPC_ADDR16 3067 || r_type == R_PPC_ADDR16_LO 3068 || r_type == R_PPC_ADDR16_HI 3069 || r_type == R_PPC_ADDR16_HA 3070 || r_type == R_PPC_ADDR14 3071 || r_type == R_PPC_ADDR14_BRTAKEN 3072 || r_type == R_PPC_ADDR14_BRNTAKEN 3073 || r_type == R_PPC_COPY 3074 || r_type == R_PPC_GLOB_DAT 3075 || r_type == R_PPC_JMP_SLOT 3076 || r_type == R_PPC_UADDR32 3077 || r_type == R_PPC_UADDR16 3078 || r_type == R_PPC_SDAREL16 3079 || r_type == R_PPC_EMB_NADDR32 3080 || r_type == R_PPC_EMB_NADDR16 3081 || r_type == R_PPC_EMB_NADDR16_LO 3082 || r_type == R_PPC_EMB_NADDR16_HI 3083 || r_type == R_PPC_EMB_NADDR16_HA 3084 || r_type == R_PPC_EMB_SDAI16 3085 || r_type == R_PPC_EMB_SDA2I16 3086 || r_type == R_PPC_EMB_SDA2REL 3087 || r_type == R_PPC_EMB_SDA21 3088 || r_type == R_PPC_EMB_MRKREF 3089 || r_type == R_PPC_EMB_BIT_FLD 3090 || r_type == R_PPC_EMB_RELSDA 3091 || ((r_type == R_PPC_REL24 3092 || r_type == R_PPC_REL32 3093 || r_type == R_PPC_REL14 3094 || r_type == R_PPC_REL14_BRTAKEN 3095 || r_type == R_PPC_REL14_BRNTAKEN 3096 || r_type == R_PPC_RELATIVE) 3097 && strcmp (h->root.root.string, 3098 "_GLOBAL_OFFSET_TABLE_") != 0)))) 3099 { 3100 /* In these cases, we don't need the relocation 3101 value. We check specially because in some 3102 obscure cases sec->output_section will be NULL. */ 3103 relocation = 0; 3104 } 3105 else if (sec->output_section == NULL) 3106 { 3107 (*_bfd_error_handler) 3108 (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"), 3109 bfd_get_filename (input_bfd), h->root.root.string, 3110 bfd_get_section_name (input_bfd, input_section)); 3111 relocation = 0; 3112 } 4399 /* Set a flag that will be cleared later if we find a 4400 relocation value for this symbol. output_section 4401 is typically NULL for symbols satisfied by a shared 4402 library. */ 4403 if (sec->output_section == NULL) 4404 unresolved_reloc = TRUE; 3113 4405 else 3114 4406 relocation = (h->root.u.def.value … … 3117 4409 } 3118 4410 else if (h->root.type == bfd_link_hash_undefweak) 3119 relocation = 0; 3120 else if (info->shared && !info->symbolic && !info->no_undefined 4411 ; 4412 else if (info->shared 4413 && !info->no_undefined 3121 4414 && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) 3122 relocation = 0;4415 ; 3123 4416 else 3124 4417 { 3125 if (! (*info->callbacks->undefined_symbol) (info, 3126 h->root.root.string, 3127 input_bfd, 3128 input_section, 3129 rel->r_offset, 3130 (!info->shared 3131 || info->no_undefined 3132 || ELF_ST_VISIBILITY (h->other)))) 3133 return false; 3134 relocation = 0; 4418 if (! ((*info->callbacks->undefined_symbol) 4419 (info, h->root.root.string, input_bfd, input_section, 4420 rel->r_offset, (!info->shared 4421 || info->no_undefined 4422 || ELF_ST_VISIBILITY (h->other))))) 4423 return FALSE; 4424 warned = TRUE; 3135 4425 } 3136 4426 } 3137 4427 3138 switch ((int) r_type) 4428 /* TLS optimizations. Replace instruction sequences and relocs 4429 based on information we collected in tls_optimize. We edit 4430 RELOCS so that --emit-relocs will output something sensible 4431 for the final instruction stream. */ 4432 tls_mask = 0; 4433 tls_gd = 0; 4434 if (IS_PPC_TLS_RELOC (r_type)) 4435 { 4436 if (h != NULL) 4437 tls_mask = ((struct ppc_elf_link_hash_entry *) h)->tls_mask; 4438 else if (local_got_offsets != NULL) 4439 { 4440 char *lgot_masks; 4441 lgot_masks = (char *) (local_got_offsets + symtab_hdr->sh_info); 4442 tls_mask = lgot_masks[r_symndx]; 4443 } 4444 } 4445 4446 /* Ensure reloc mapping code below stays sane. */ 4447 if ((R_PPC_GOT_TLSLD16 & 3) != (R_PPC_GOT_TLSGD16 & 3) 4448 || (R_PPC_GOT_TLSLD16_LO & 3) != (R_PPC_GOT_TLSGD16_LO & 3) 4449 || (R_PPC_GOT_TLSLD16_HI & 3) != (R_PPC_GOT_TLSGD16_HI & 3) 4450 || (R_PPC_GOT_TLSLD16_HA & 3) != (R_PPC_GOT_TLSGD16_HA & 3) 4451 || (R_PPC_GOT_TLSLD16 & 3) != (R_PPC_GOT_TPREL16 & 3) 4452 || (R_PPC_GOT_TLSLD16_LO & 3) != (R_PPC_GOT_TPREL16_LO & 3) 4453 || (R_PPC_GOT_TLSLD16_HI & 3) != (R_PPC_GOT_TPREL16_HI & 3) 4454 || (R_PPC_GOT_TLSLD16_HA & 3) != (R_PPC_GOT_TPREL16_HA & 3)) 4455 abort (); 4456 switch (r_type) 3139 4457 { 3140 4458 default: 3141 (*_bfd_error_handler) (_("%s: unknown relocation type %d for symbol %s"), 3142 bfd_get_filename (input_bfd), 3143 (int) r_type, sym_name); 4459 break; 4460 4461 case R_PPC_GOT_TPREL16: 4462 case R_PPC_GOT_TPREL16_LO: 4463 if (tls_mask != 0 4464 && (tls_mask & TLS_TPREL) == 0) 4465 { 4466 bfd_vma insn; 4467 insn = bfd_get_32 (output_bfd, contents + rel->r_offset - 2); 4468 insn &= 31 << 21; 4469 insn |= 0x3c020000; /* addis 0,2,0 */ 4470 bfd_put_32 (output_bfd, insn, contents + rel->r_offset - 2); 4471 r_type = R_PPC_TPREL16_HA; 4472 rel->r_info = ELF32_R_INFO (r_symndx, r_type); 4473 } 4474 break; 4475 4476 case R_PPC_TLS: 4477 if (tls_mask != 0 4478 && (tls_mask & TLS_TPREL) == 0) 4479 { 4480 bfd_vma insn, rtra; 4481 insn = bfd_get_32 (output_bfd, contents + rel->r_offset); 4482 if ((insn & ((31 << 26) | (31 << 11))) 4483 == ((31 << 26) | (2 << 11))) 4484 rtra = insn & ((1 << 26) - (1 << 16)); 4485 else if ((insn & ((31 << 26) | (31 << 16))) 4486 == ((31 << 26) | (2 << 16))) 4487 rtra = (insn & (31 << 21)) | ((insn & (31 << 11)) << 5); 4488 else 4489 abort (); 4490 if ((insn & ((1 << 11) - (1 << 1))) == 266 << 1) 4491 /* add -> addi. */ 4492 insn = 14 << 26; 4493 else if ((insn & (31 << 1)) == 23 << 1 4494 && ((insn & (31 << 6)) < 14 << 6 4495 || ((insn & (31 << 6)) >= 16 << 6 4496 && (insn & (31 << 6)) < 24 << 6))) 4497 /* load and store indexed -> dform. */ 4498 insn = (32 | ((insn >> 6) & 31)) << 26; 4499 else if ((insn & (31 << 1)) == 21 << 1 4500 && (insn & (0x1a << 6)) == 0) 4501 /* ldx, ldux, stdx, stdux -> ld, ldu, std, stdu. */ 4502 insn = (((58 | ((insn >> 6) & 4)) << 26) 4503 | ((insn >> 6) & 1)); 4504 else if ((insn & (31 << 1)) == 21 << 1 4505 && (insn & ((1 << 11) - (1 << 1))) == 341 << 1) 4506 /* lwax -> lwa. */ 4507 insn = (58 << 26) | 2; 4508 else 4509 abort (); 4510 insn |= rtra; 4511 bfd_put_32 (output_bfd, insn, contents + rel->r_offset); 4512 r_type = R_PPC_TPREL16_LO; 4513 rel->r_info = ELF32_R_INFO (r_symndx, r_type); 4514 /* Was PPC_TLS which sits on insn boundary, now 4515 PPC_TPREL16_LO which is at insn+2. */ 4516 rel->r_offset += 2; 4517 } 4518 break; 4519 4520 case R_PPC_GOT_TLSGD16_HI: 4521 case R_PPC_GOT_TLSGD16_HA: 4522 tls_gd = TLS_TPRELGD; 4523 if (tls_mask != 0 && (tls_mask & TLS_GD) == 0) 4524 goto tls_gdld_hi; 4525 break; 4526 4527 case R_PPC_GOT_TLSLD16_HI: 4528 case R_PPC_GOT_TLSLD16_HA: 4529 if (tls_mask != 0 && (tls_mask & TLS_LD) == 0) 4530 { 4531 tls_gdld_hi: 4532 if ((tls_mask & tls_gd) != 0) 4533 r_type = (((r_type - (R_PPC_GOT_TLSGD16 & 3)) & 3) 4534 + R_PPC_GOT_TPREL16); 4535 else 4536 { 4537 bfd_put_32 (output_bfd, NOP, contents + rel->r_offset); 4538 rel->r_offset -= 2; 4539 r_type = R_PPC_NONE; 4540 } 4541 rel->r_info = ELF32_R_INFO (r_symndx, r_type); 4542 } 4543 break; 4544 4545 case R_PPC_GOT_TLSGD16: 4546 case R_PPC_GOT_TLSGD16_LO: 4547 tls_gd = TLS_TPRELGD; 4548 if (tls_mask != 0 && (tls_mask & TLS_GD) == 0) 4549 goto tls_get_addr_check; 4550 break; 4551 4552 case R_PPC_GOT_TLSLD16: 4553 case R_PPC_GOT_TLSLD16_LO: 4554 if (tls_mask != 0 && (tls_mask & TLS_LD) == 0) 4555 { 4556 tls_get_addr_check: 4557 if (rel + 1 < relend) 4558 { 4559 enum elf_ppc_reloc_type r_type2; 4560 unsigned long r_symndx2; 4561 struct elf_link_hash_entry *h2; 4562 bfd_vma insn1, insn2; 4563 bfd_vma offset; 4564 4565 /* The next instruction should be a call to 4566 __tls_get_addr. Peek at the reloc to be sure. */ 4567 r_type2 4568 = (enum elf_ppc_reloc_type) ELF32_R_TYPE (rel[1].r_info); 4569 r_symndx2 = ELF32_R_SYM (rel[1].r_info); 4570 if (r_symndx2 < symtab_hdr->sh_info 4571 || (r_type2 != R_PPC_REL14 4572 && r_type2 != R_PPC_REL14_BRTAKEN 4573 && r_type2 != R_PPC_REL14_BRNTAKEN 4574 && r_type2 != R_PPC_REL24 4575 && r_type2 != R_PPC_PLTREL24)) 4576 break; 4577 4578 h2 = sym_hashes[r_symndx2 - symtab_hdr->sh_info]; 4579 while (h2->root.type == bfd_link_hash_indirect 4580 || h2->root.type == bfd_link_hash_warning) 4581 h2 = (struct elf_link_hash_entry *) h2->root.u.i.link; 4582 if (h2 == NULL || h2 != htab->tls_get_addr) 4583 break; 4584 4585 /* OK, it checks out. Replace the call. */ 4586 offset = rel[1].r_offset; 4587 insn1 = bfd_get_32 (output_bfd, 4588 contents + rel->r_offset - 2); 4589 if ((tls_mask & tls_gd) != 0) 4590 { 4591 /* IE */ 4592 insn1 &= (1 << 26) - 1; 4593 insn1 |= 32 << 26; /* lwz */ 4594 insn2 = 0x7c631214; /* add 3,3,2 */ 4595 rel[1].r_info = ELF32_R_INFO (r_symndx2, R_PPC_NONE); 4596 r_type = (((r_type - (R_PPC_GOT_TLSGD16 & 3)) & 3) 4597 + R_PPC_GOT_TPREL16); 4598 rel->r_info = ELF32_R_INFO (r_symndx, r_type); 4599 } 4600 else 4601 { 4602 /* LE */ 4603 insn1 = 0x3c620000; /* addis 3,2,0 */ 4604 insn2 = 0x38630000; /* addi 3,3,0 */ 4605 if (tls_gd == 0) 4606 { 4607 /* Was an LD reloc. */ 4608 r_symndx = 0; 4609 rel->r_addend = htab->tls_sec->vma + DTP_OFFSET; 4610 rel[1].r_addend = htab->tls_sec->vma + DTP_OFFSET; 4611 } 4612 r_type = R_PPC_TPREL16_HA; 4613 rel->r_info = ELF32_R_INFO (r_symndx, r_type); 4614 rel[1].r_info = ELF32_R_INFO (r_symndx, 4615 R_PPC_TPREL16_LO); 4616 rel[1].r_offset += 2; 4617 } 4618 bfd_put_32 (output_bfd, insn1, contents + rel->r_offset - 2); 4619 bfd_put_32 (output_bfd, insn2, contents + offset); 4620 if (tls_gd == 0) 4621 { 4622 /* We changed the symbol on an LD reloc. Start over 4623 in order to get h, sym, sec etc. right. */ 4624 rel--; 4625 continue; 4626 } 4627 } 4628 } 4629 break; 4630 } 4631 4632 /* Handle other relocations that tweak non-addend part of insn. */ 4633 branch_bit = 0; 4634 switch (r_type) 4635 { 4636 default: 4637 break; 4638 4639 /* Branch taken prediction relocations. */ 4640 case R_PPC_ADDR14_BRTAKEN: 4641 case R_PPC_REL14_BRTAKEN: 4642 branch_bit = BRANCH_PREDICT_BIT; 4643 /* Fall thru */ 4644 4645 /* Branch not taken predicition relocations. */ 4646 case R_PPC_ADDR14_BRNTAKEN: 4647 case R_PPC_REL14_BRNTAKEN: 4648 insn = bfd_get_32 (output_bfd, contents + rel->r_offset); 4649 insn &= ~BRANCH_PREDICT_BIT; 4650 insn |= branch_bit; 4651 4652 from = (rel->r_offset 4653 + input_section->output_offset 4654 + input_section->output_section->vma); 4655 4656 /* Invert 'y' bit if not the default. */ 4657 if ((bfd_signed_vma) (relocation + rel->r_addend - from) < 0) 4658 insn ^= BRANCH_PREDICT_BIT; 4659 4660 bfd_put_32 (output_bfd, insn, contents + rel->r_offset); 4661 break; 4662 } 4663 4664 addend = rel->r_addend; 4665 tls_type = 0; 4666 howto = NULL; 4667 if ((unsigned) r_type < (unsigned) R_PPC_max) 4668 howto = ppc_elf_howto_table[(int) r_type]; 4669 switch (r_type) 4670 { 4671 default: 4672 (*_bfd_error_handler) 4673 (_("%s: unknown relocation type %d for symbol %s"), 4674 bfd_archive_filename (input_bfd), (int) r_type, sym_name); 3144 4675 3145 4676 bfd_set_error (bfd_error_bad_value); 3146 ret = false;4677 ret = FALSE; 3147 4678 continue; 3148 4679 4680 case R_PPC_NONE: 4681 case R_PPC_TLS: 4682 case R_PPC_EMB_MRKREF: 4683 case R_PPC_GNU_VTINHERIT: 4684 case R_PPC_GNU_VTENTRY: 4685 continue; 4686 4687 /* GOT16 relocations. Like an ADDR16 using the symbol's 4688 address in the GOT as relocation value instead of the 4689 symbol's value itself. Also, create a GOT entry for the 4690 symbol and put the symbol value there. */ 4691 case R_PPC_GOT_TLSGD16: 4692 case R_PPC_GOT_TLSGD16_LO: 4693 case R_PPC_GOT_TLSGD16_HI: 4694 case R_PPC_GOT_TLSGD16_HA: 4695 tls_type = TLS_TLS | TLS_GD; 4696 goto dogot; 4697 4698 case R_PPC_GOT_TLSLD16: 4699 case R_PPC_GOT_TLSLD16_LO: 4700 case R_PPC_GOT_TLSLD16_HI: 4701 case R_PPC_GOT_TLSLD16_HA: 4702 tls_type = TLS_TLS | TLS_LD; 4703 goto dogot; 4704 4705 case R_PPC_GOT_TPREL16: 4706 case R_PPC_GOT_TPREL16_LO: 4707 case R_PPC_GOT_TPREL16_HI: 4708 case R_PPC_GOT_TPREL16_HA: 4709 tls_type = TLS_TLS | TLS_TPREL; 4710 goto dogot; 4711 4712 case R_PPC_GOT_DTPREL16: 4713 case R_PPC_GOT_DTPREL16_LO: 4714 case R_PPC_GOT_DTPREL16_HI: 4715 case R_PPC_GOT_DTPREL16_HA: 4716 tls_type = TLS_TLS | TLS_DTPREL; 4717 goto dogot; 4718 4719 case R_PPC_GOT16: 4720 case R_PPC_GOT16_LO: 4721 case R_PPC_GOT16_HI: 4722 case R_PPC_GOT16_HA: 4723 dogot: 4724 { 4725 /* Relocation is to the entry for this symbol in the global 4726 offset table. */ 4727 bfd_vma off; 4728 bfd_vma *offp; 4729 unsigned long indx; 4730 4731 if (htab->got == NULL) 4732 abort (); 4733 4734 indx = 0; 4735 if (tls_type == (TLS_TLS | TLS_LD) 4736 && (h == NULL 4737 || !(h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC))) 4738 offp = &htab->tlsld_got.offset; 4739 else if (h != NULL) 4740 { 4741 bfd_boolean dyn; 4742 dyn = htab->elf.dynamic_sections_created; 4743 if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h) 4744 || (info->shared 4745 && SYMBOL_REFERENCES_LOCAL (info, h))) 4746 /* This is actually a static link, or it is a 4747 -Bsymbolic link and the symbol is defined 4748 locally, or the symbol was forced to be local 4749 because of a version file. */ 4750 ; 4751 else 4752 { 4753 indx = h->dynindx; 4754 unresolved_reloc = FALSE; 4755 } 4756 offp = &h->got.offset; 4757 } 4758 else 4759 { 4760 if (local_got_offsets == NULL) 4761 abort (); 4762 offp = &local_got_offsets[r_symndx]; 4763 } 4764 4765 /* The offset must always be a multiple of 4. We use the 4766 least significant bit to record whether we have already 4767 processed this entry. */ 4768 off = *offp; 4769 if ((off & 1) != 0) 4770 off &= ~1; 4771 else 4772 { 4773 unsigned int tls_m = (tls_mask 4774 & (TLS_LD | TLS_GD | TLS_DTPREL 4775 | TLS_TPREL | TLS_TPRELGD)); 4776 4777 if (offp == &htab->tlsld_got.offset) 4778 tls_m = TLS_LD; 4779 else if (h == NULL 4780 || !(h->elf_link_hash_flags 4781 & ELF_LINK_HASH_DEF_DYNAMIC)) 4782 tls_m &= ~TLS_LD; 4783 4784 /* We might have multiple got entries for this sym. 4785 Initialize them all. */ 4786 do 4787 { 4788 int tls_ty = 0; 4789 4790 if ((tls_m & TLS_LD) != 0) 4791 { 4792 tls_ty = TLS_TLS | TLS_LD; 4793 tls_m &= ~TLS_LD; 4794 } 4795 else if ((tls_m & TLS_GD) != 0) 4796 { 4797 tls_ty = TLS_TLS | TLS_GD; 4798 tls_m &= ~TLS_GD; 4799 } 4800 else if ((tls_m & TLS_DTPREL) != 0) 4801 { 4802 tls_ty = TLS_TLS | TLS_DTPREL; 4803 tls_m &= ~TLS_DTPREL; 4804 } 4805 else if ((tls_m & (TLS_TPREL | TLS_TPRELGD)) != 0) 4806 { 4807 tls_ty = TLS_TLS | TLS_TPREL; 4808 tls_m = 0; 4809 } 4810 4811 /* Generate relocs for the dynamic linker. */ 4812 if (info->shared || indx != 0) 4813 { 4814 outrel.r_offset = (htab->got->output_section->vma 4815 + htab->got->output_offset 4816 + off); 4817 outrel.r_addend = 0; 4818 if (tls_ty & (TLS_LD | TLS_GD)) 4819 { 4820 outrel.r_info = ELF32_R_INFO (indx, R_PPC_DTPMOD32); 4821 if (tls_ty == (TLS_TLS | TLS_GD)) 4822 { 4823 loc = htab->relgot->contents; 4824 loc += (htab->relgot->reloc_count++ 4825 * sizeof (Elf32_External_Rela)); 4826 bfd_elf32_swap_reloca_out (output_bfd, 4827 &outrel, loc); 4828 outrel.r_offset += 4; 4829 outrel.r_info 4830 = ELF32_R_INFO (indx, R_PPC_DTPREL32); 4831 } 4832 } 4833 else if (tls_ty == (TLS_TLS | TLS_DTPREL)) 4834 outrel.r_info = ELF32_R_INFO (indx, R_PPC_DTPREL32); 4835 else if (tls_ty == (TLS_TLS | TLS_TPREL)) 4836 outrel.r_info = ELF32_R_INFO (indx, R_PPC_TPREL32); 4837 else if (indx == 0) 4838 outrel.r_info = ELF32_R_INFO (indx, R_PPC_RELATIVE); 4839 else 4840 outrel.r_info = ELF32_R_INFO (indx, R_PPC_GLOB_DAT); 4841 if (indx == 0) 4842 { 4843 outrel.r_addend += relocation; 4844 if (tls_ty & (TLS_GD | TLS_DTPREL | TLS_TPREL)) 4845 outrel.r_addend -= htab->tls_sec->vma; 4846 } 4847 loc = htab->relgot->contents; 4848 loc += (htab->relgot->reloc_count++ 4849 * sizeof (Elf32_External_Rela)); 4850 bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc); 4851 } 4852 4853 /* Init the .got section contents if we're not 4854 emitting a reloc. */ 4855 else 4856 { 4857 bfd_vma value = relocation; 4858 4859 if (tls_ty == (TLS_TLS | TLS_LD)) 4860 value = 1; 4861 else if (tls_ty != 0) 4862 { 4863 value -= htab->tls_sec->vma + DTP_OFFSET; 4864 if (tls_ty == (TLS_TLS | TLS_TPREL)) 4865 value += DTP_OFFSET - TP_OFFSET; 4866 4867 if (tls_ty == (TLS_TLS | TLS_GD)) 4868 { 4869 bfd_put_32 (output_bfd, value, 4870 htab->got->contents + off + 4); 4871 value = 1; 4872 } 4873 } 4874 bfd_put_32 (output_bfd, value, 4875 htab->got->contents + off); 4876 } 4877 4878 off += 4; 4879 if (tls_ty & (TLS_LD | TLS_GD)) 4880 off += 4; 4881 } 4882 while (tls_m != 0); 4883 4884 off = *offp; 4885 *offp = off | 1; 4886 } 4887 4888 if (off >= (bfd_vma) -2) 4889 abort (); 4890 4891 if ((tls_type & TLS_TLS) != 0) 4892 { 4893 if (tls_type != (TLS_TLS | TLS_LD)) 4894 { 4895 if ((tls_mask & TLS_LD) != 0 4896 && !(h == NULL 4897 || !(h->elf_link_hash_flags 4898 & ELF_LINK_HASH_DEF_DYNAMIC))) 4899 off += 8; 4900 if (tls_type != (TLS_TLS | TLS_GD)) 4901 { 4902 if ((tls_mask & TLS_GD) != 0) 4903 off += 8; 4904 if (tls_type != (TLS_TLS | TLS_DTPREL)) 4905 { 4906 if ((tls_mask & TLS_DTPREL) != 0) 4907 off += 4; 4908 } 4909 } 4910 } 4911 } 4912 4913 relocation = htab->got->output_offset + off - 4; 4914 4915 /* Addends on got relocations don't make much sense. 4916 x+off@got is actually x@got+off, and since the got is 4917 generated by a hash table traversal, the value in the 4918 got at entry m+n bears little relation to the entry m. */ 4919 if (addend != 0) 4920 (*_bfd_error_handler) 4921 (_("%s(%s+0x%lx): non-zero addend on %s reloc against `%s'"), 4922 bfd_archive_filename (input_bfd), 4923 bfd_get_section_name (input_bfd, input_section), 4924 (long) rel->r_offset, 4925 howto->name, 4926 sym_name); 4927 } 4928 break; 4929 3149 4930 /* Relocations that need no special processing. */ 3150 case (int)R_PPC_LOCAL24PC:4931 case R_PPC_LOCAL24PC: 3151 4932 /* It makes no sense to point a local relocation 3152 4933 at a symbol not in this object. */ 3153 if (h != NULL 3154 && (h->root.type == bfd_link_hash_defined 3155 || h->root.type == bfd_link_hash_defweak) 3156 && sec->output_section == NULL) 4934 if (unresolved_reloc) 3157 4935 { 3158 4936 if (! (*info->callbacks->undefined_symbol) (info, … … 3161 4939 input_section, 3162 4940 rel->r_offset, 3163 true))3164 return false;4941 TRUE)) 4942 return FALSE; 3165 4943 continue; 3166 4944 } 3167 4945 break; 3168 4946 3169 /* Relocations that may need to be propagated if this is a shared 3170 object. */ 3171 case (int) R_PPC_REL24: 3172 case (int) R_PPC_REL32: 3173 case (int) R_PPC_REL14: 4947 case R_PPC_DTPREL16: 4948 case R_PPC_DTPREL16_LO: 4949 case R_PPC_DTPREL16_HI: 4950 case R_PPC_DTPREL16_HA: 4951 addend -= htab->tls_sec->vma + DTP_OFFSET; 4952 break; 4953 4954 /* Relocations that may need to be propagated if this is a shared 4955 object. */ 4956 case R_PPC_TPREL16: 4957 case R_PPC_TPREL16_LO: 4958 case R_PPC_TPREL16_HI: 4959 case R_PPC_TPREL16_HA: 4960 addend -= htab->tls_sec->vma + TP_OFFSET; 4961 /* The TPREL16 relocs shouldn't really be used in shared 4962 libs as they will result in DT_TEXTREL being set, but 4963 support them anyway. */ 4964 goto dodyn; 4965 4966 case R_PPC_TPREL32: 4967 addend -= htab->tls_sec->vma + TP_OFFSET; 4968 goto dodyn; 4969 4970 case R_PPC_DTPREL32: 4971 addend -= htab->tls_sec->vma + DTP_OFFSET; 4972 goto dodyn; 4973 4974 case R_PPC_DTPMOD32: 4975 relocation = 1; 4976 addend = 0; 4977 goto dodyn; 4978 4979 case R_PPC_REL24: 4980 case R_PPC_REL32: 4981 case R_PPC_REL14: 4982 case R_PPC_REL14_BRTAKEN: 4983 case R_PPC_REL14_BRNTAKEN: 3174 4984 /* If these relocations are not to a named symbol, they can be 3175 4985 handled right here, no need to bother the dynamic linker. */ … … 3178 4988 || SYMBOL_REFERENCES_LOCAL (info, h)) 3179 4989 break; 3180 /* fall through */ 3181 3182 /* Relocations that always need to be propagated if this is a shared 3183 object. */ 3184 case (int) R_PPC_NONE: 3185 case (int) R_PPC_ADDR32: 3186 case (int) R_PPC_ADDR24: 3187 case (int) R_PPC_ADDR16: 3188 case (int) R_PPC_ADDR16_LO: 3189 case (int) R_PPC_ADDR16_HI: 3190 case (int) R_PPC_ADDR16_HA: 3191 case (int) R_PPC_ADDR14: 3192 case (int) R_PPC_UADDR32: 3193 case (int) R_PPC_UADDR16: 3194 if (info->shared) 4990 /* fall through */ 4991 4992 /* Relocations that always need to be propagated if this is a shared 4993 object. */ 4994 case R_PPC_ADDR32: 4995 case R_PPC_ADDR24: 4996 case R_PPC_ADDR16: 4997 case R_PPC_ADDR16_LO: 4998 case R_PPC_ADDR16_HI: 4999 case R_PPC_ADDR16_HA: 5000 case R_PPC_ADDR14: 5001 case R_PPC_ADDR14_BRTAKEN: 5002 case R_PPC_ADDR14_BRNTAKEN: 5003 case R_PPC_UADDR32: 5004 case R_PPC_UADDR16: 5005 /* r_symndx will be zero only for relocs against symbols 5006 from removed linkonce sections, or sections discarded by 5007 a linker script. */ 5008 dodyn: 5009 if (r_symndx == 0) 5010 break; 5011 /* Fall thru. */ 5012 5013 if ((info->shared 5014 && (MUST_BE_DYN_RELOC (r_type) 5015 || (h != NULL 5016 && h->dynindx != -1 5017 && (!info->symbolic 5018 || (h->elf_link_hash_flags 5019 & ELF_LINK_HASH_DEF_REGULAR) == 0)))) 5020 || (ELIMINATE_COPY_RELOCS 5021 && !info->shared 5022 && (input_section->flags & SEC_ALLOC) != 0 5023 && h != NULL 5024 && h->dynindx != -1 5025 && (h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0 5026 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0 5027 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)) 3195 5028 { 3196 Elf_Internal_Rela outrel; 3197 boolean skip; 5029 int skip; 3198 5030 3199 5031 #ifdef DEBUG 3200 5032 fprintf (stderr, "ppc_elf_relocate_section need to create relocation for %s\n", 3201 (h && h->root.root.string) ? h->root.root.string : "<unknown>"); 5033 (h && h->root.root.string 5034 ? h->root.root.string : "<unknown>")); 3202 5035 #endif 3203 5036 3204 5037 /* When generating a shared object, these relocations 3205 are copied into the output file to be resolved at run 3206 time. */ 3207 5038 are copied into the output file to be resolved at run 5039 time. */ 3208 5040 if (sreloc == NULL) 3209 5041 { … … 3215 5047 elf_section_data (input_section)->rel_hdr.sh_name)); 3216 5048 if (name == NULL) 3217 return false;5049 return FALSE; 3218 5050 3219 5051 BFD_ASSERT (strncmp (name, ".rela", 5) == 0 … … 3222 5054 name + 5) == 0); 3223 5055 3224 sreloc = bfd_get_section_by_name ( dynobj, name);5056 sreloc = bfd_get_section_by_name (htab->elf.dynobj, name); 3225 5057 BFD_ASSERT (sreloc != NULL); 3226 5058 } 3227 5059 3228 skip = false; 3229 3230 if (elf_section_data (input_section)->stab_info == NULL) 3231 outrel.r_offset = rel->r_offset; 3232 else 3233 { 3234 bfd_vma off; 3235 3236 off = (_bfd_stab_section_offset 3237 (output_bfd, &elf_hash_table (info)->stab_info, 3238 input_section, 3239 &elf_section_data (input_section)->stab_info, 3240 rel->r_offset)); 3241 if (off == (bfd_vma) -1) 3242 skip = true; 3243 outrel.r_offset = off; 3244 } 3245 5060 skip = 0; 5061 5062 outrel.r_offset = 5063 _bfd_elf_section_offset (output_bfd, info, input_section, 5064 rel->r_offset); 5065 if (outrel.r_offset == (bfd_vma) -1 5066 || outrel.r_offset == (bfd_vma) -2) 5067 skip = (int) outrel.r_offset; 3246 5068 outrel.r_offset += (input_section->output_section->vma 3247 5069 + input_section->output_offset); … … 3249 5071 if (skip) 3250 5072 memset (&outrel, 0, sizeof outrel); 3251 /* h->dynindx may be -1 if this symbol was marked to 3252 become local. */ 3253 else if (! will_become_local) 5073 else if (h != NULL 5074 && !SYMBOL_REFERENCES_LOCAL (info, h)) 3254 5075 { 5076 unresolved_reloc = FALSE; 3255 5077 outrel.r_info = ELF32_R_INFO (h->dynindx, r_type); 3256 5078 outrel.r_addend = rel->r_addend; … … 3258 5080 else 3259 5081 { 5082 outrel.r_addend = relocation + rel->r_addend; 5083 3260 5084 if (r_type == R_PPC_ADDR32) 3261 { 3262 outrel.r_info = ELF32_R_INFO (0, R_PPC_RELATIVE); 3263 outrel.r_addend = relocation + rel->r_addend; 3264 } 5085 outrel.r_info = ELF32_R_INFO (0, R_PPC_RELATIVE); 3265 5086 else 3266 5087 { 3267 5088 long indx; 3268 5089 3269 if (h == NULL) 3270 sec = local_sections[r_symndx]; 3271 else 3272 { 3273 BFD_ASSERT (h->root.type == bfd_link_hash_defined 3274 || (h->root.type 3275 == bfd_link_hash_defweak)); 3276 sec = h->root.u.def.section; 3277 } 3278 if (sec != NULL && bfd_is_abs_section (sec)) 5090 if (bfd_is_abs_section (sec)) 3279 5091 indx = 0; 3280 5092 else if (sec == NULL || sec->owner == NULL) 3281 5093 { 3282 5094 bfd_set_error (bfd_error_bad_value); 3283 return false;5095 return FALSE; 3284 5096 } 3285 5097 else … … 3287 5099 asection *osec; 3288 5100 5101 /* We are turning this relocation into one 5102 against a section symbol. It would be 5103 proper to subtract the symbol's value, 5104 osec->vma, from the emitted reloc addend, 5105 but ld.so expects buggy relocs. */ 3289 5106 osec = sec->output_section; 3290 5107 indx = elf_section_data (osec)->dynindx; … … 3294 5111 { 3295 5112 printf ("indx=%d section=%s flags=%08x name=%s\n", 3296 indx, osec->name, osec->flags,3297 h->root.root.string);5113 indx, osec->name, osec->flags, 5114 h->root.root.string); 3298 5115 } 3299 5116 #endif … … 3301 5118 3302 5119 outrel.r_info = ELF32_R_INFO (indx, r_type); 3303 outrel.r_addend = relocation + rel->r_addend;3304 5120 } 3305 5121 } 3306 5122 3307 bfd_elf32_swap_reloca_out (output_bfd, &outrel, 3308 (((Elf32_External_Rela *) 3309 sreloc->contents) 3310 + sreloc->reloc_count)); 3311 ++sreloc->reloc_count; 3312 3313 /* This reloc will be computed at runtime, so there's no 3314 need to do anything now, unless this is a RELATIVE 3315 reloc in an unallocated section. */ 3316 if (skip 3317 || (input_section->flags & SEC_ALLOC) != 0 3318 || ELF32_R_TYPE (outrel.r_info) != R_PPC_RELATIVE) 5123 loc = sreloc->contents; 5124 loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela); 5125 bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc); 5126 5127 if (skip == -1) 3319 5128 continue; 3320 } 3321 3322 /* Arithmetic adjust relocations that aren't going into a 3323 shared object. */ 3324 if (r_type == R_PPC_ADDR16_HA 3325 /* It's just possible that this symbol is a weak symbol 3326 that's not actually defined anywhere. In that case, 3327 'sec' would be NULL, and we should leave the symbol 3328 alone (it will be set to zero elsewhere in the link). */ 3329 && sec != NULL) 3330 { 3331 addend += ((relocation + addend) & 0x8000) << 1; 5129 5130 /* This reloc will be computed at runtime. We clear the memory 5131 so that it contains predictable value. */ 5132 if (! skip 5133 && ((input_section->flags & SEC_ALLOC) != 0 5134 || ELF32_R_TYPE (outrel.r_info) != R_PPC_RELATIVE)) 5135 { 5136 relocation = howto->pc_relative ? outrel.r_offset : 0; 5137 addend = 0; 5138 break; 5139 } 3332 5140 } 3333 5141 break; 3334 5142 3335 /* branch taken prediction relocations */ 3336 case (int) R_PPC_ADDR14_BRTAKEN: 3337 case (int) R_PPC_REL14_BRTAKEN: 3338 insn = bfd_get_32 (output_bfd, contents + offset); 3339 if ((relocation - offset) & 0x8000) 3340 insn &= ~BRANCH_PREDICT_BIT; 3341 else 3342 insn |= BRANCH_PREDICT_BIT; 3343 bfd_put_32 (output_bfd, insn, contents + offset); 5143 /* Indirect .sdata relocation. */ 5144 case R_PPC_EMB_SDAI16: 5145 BFD_ASSERT (htab->sdata != NULL); 5146 relocation 5147 = bfd_elf32_finish_pointer_linker_section (output_bfd, input_bfd, 5148 info, htab->sdata, h, 5149 relocation, rel, 5150 R_PPC_RELATIVE); 3344 5151 break; 3345 5152 3346 /* branch not taken predicition relocations */ 3347 case (int) R_PPC_ADDR14_BRNTAKEN: 3348 case (int) R_PPC_REL14_BRNTAKEN: 3349 insn = bfd_get_32 (output_bfd, contents + offset); 3350 if ((relocation - offset) & 0x8000) 3351 insn |= BRANCH_PREDICT_BIT; 3352 else 3353 insn &= ~BRANCH_PREDICT_BIT; 3354 bfd_put_32 (output_bfd, insn, contents + offset); 5153 /* Indirect .sdata2 relocation. */ 5154 case R_PPC_EMB_SDA2I16: 5155 BFD_ASSERT (htab->sdata2 != NULL); 5156 relocation 5157 = bfd_elf32_finish_pointer_linker_section (output_bfd, input_bfd, 5158 info, htab->sdata2, h, 5159 relocation, rel, 5160 R_PPC_RELATIVE); 3355 5161 break; 3356 5162 3357 /* GOT16 relocations */ 3358 case (int) R_PPC_GOT16: 3359 case (int) R_PPC_GOT16_LO: 3360 case (int) R_PPC_GOT16_HI: 3361 case (int) R_PPC_GOT16_HA: 3362 /* Relocation is to the entry for this symbol in the global 3363 offset table. */ 3364 BFD_ASSERT (sgot != NULL); 3365 3366 if (h != NULL) 3367 { 3368 bfd_vma off; 3369 3370 off = h->got.offset; 3371 BFD_ASSERT (off != (bfd_vma) -1); 3372 3373 if (! elf_hash_table (info)->dynamic_sections_created 3374 || (info->shared 3375 && SYMBOL_REFERENCES_LOCAL (info, h))) 3376 { 3377 /* This is actually a static link, or it is a 3378 -Bsymbolic link and the symbol is defined 3379 locally. We must initialize this entry in the 3380 global offset table. Since the offset must 3381 always be a multiple of 4, we use the least 3382 significant bit to record whether we have 3383 initialized it already. 3384 3385 When doing a dynamic link, we create a .rela.got 3386 relocation entry to initialize the value. This 3387 is done in the finish_dynamic_symbol routine. */ 3388 if ((off & 1) != 0) 3389 off &= ~1; 3390 else 3391 { 3392 bfd_put_32 (output_bfd, relocation, 3393 sgot->contents + off); 3394 h->got.offset |= 1; 3395 } 3396 } 3397 3398 relocation = sgot->output_offset + off - 4; 3399 } 3400 else 3401 { 3402 bfd_vma off; 3403 3404 BFD_ASSERT (local_got_offsets != NULL 3405 && local_got_offsets[r_symndx] != (bfd_vma) -1); 3406 3407 off = local_got_offsets[r_symndx]; 3408 3409 /* The offset must always be a multiple of 4. We use 3410 the least significant bit to record whether we have 3411 already processed this entry. */ 3412 if ((off & 1) != 0) 3413 off &= ~1; 3414 else 3415 { 3416 bfd_put_32 (output_bfd, relocation, sgot->contents + off); 3417 3418 if (info->shared) 3419 { 3420 asection *srelgot; 3421 Elf_Internal_Rela outrel; 3422 3423 /* We need to generate a R_PPC_RELATIVE reloc 3424 for the dynamic linker. */ 3425 srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); 3426 BFD_ASSERT (srelgot != NULL); 3427 3428 outrel.r_offset = (sgot->output_section->vma 3429 + sgot->output_offset 3430 + off); 3431 outrel.r_info = ELF32_R_INFO (0, R_PPC_RELATIVE); 3432 outrel.r_addend = relocation; 3433 bfd_elf32_swap_reloca_out (output_bfd, &outrel, 3434 (((Elf32_External_Rela *) 3435 srelgot->contents) 3436 + srelgot->reloc_count)); 3437 ++srelgot->reloc_count; 3438 } 3439 3440 local_got_offsets[r_symndx] |= 1; 3441 } 3442 3443 relocation = sgot->output_offset + off - 4; 3444 } 3445 break; 3446 3447 /* Indirect .sdata relocation */ 3448 case (int) R_PPC_EMB_SDAI16: 3449 BFD_ASSERT (sdata != NULL); 3450 relocation = bfd_elf32_finish_pointer_linker_section (output_bfd, input_bfd, info, 3451 sdata, h, relocation, rel, 3452 R_PPC_RELATIVE); 3453 break; 3454 3455 /* Indirect .sdata2 relocation */ 3456 case (int) R_PPC_EMB_SDA2I16: 3457 BFD_ASSERT (sdata2 != NULL); 3458 relocation = bfd_elf32_finish_pointer_linker_section (output_bfd, input_bfd, info, 3459 sdata2, h, relocation, rel, 3460 R_PPC_RELATIVE); 3461 break; 3462 3463 /* Handle the TOC16 reloc. We want to use the offset within the .got 3464 section, not the actual VMA. This is appropriate when generating 3465 an embedded ELF object, for which the .got section acts like the 3466 AIX .toc section. */ 3467 case (int) R_PPC_TOC16: /* phony GOT16 relocations */ 5163 /* Handle the TOC16 reloc. We want to use the offset within the .got 5164 section, not the actual VMA. This is appropriate when generating 5165 an embedded ELF object, for which the .got section acts like the 5166 AIX .toc section. */ 5167 case R_PPC_TOC16: /* phony GOT16 relocations */ 3468 5168 BFD_ASSERT (sec != (asection *) 0); 3469 5169 BFD_ASSERT (bfd_is_und_section (sec) … … 3471 5171 || strcmp (bfd_get_section_name (abfd, sec), ".cgot") == 0) 3472 5172 3473 addend -= sec->output_section->vma + sec->output_offset + 0x8000;5173 addend -= sec->output_section->vma + sec->output_offset + 0x8000; 3474 5174 break; 3475 5175 3476 case (int)R_PPC_PLTREL24:5176 case R_PPC_PLTREL24: 3477 5177 /* Relocation is to the entry for this symbol in the 3478 5178 procedure linkage table. */ 3479 5179 BFD_ASSERT (h != NULL); 3480 5180 3481 5181 if (h->plt.offset == (bfd_vma) -1 3482 || splt == NULL)5182 || htab->plt == NULL) 3483 5183 { 3484 5184 /* We didn't make a PLT entry for this symbol. This 3485 3486 5185 happens when statically linking PIC code, or when 5186 using -Bsymbolic. */ 3487 5187 break; 3488 5188 } 3489 5189 3490 relocation = (splt->output_section->vma 3491 + splt->output_offset 5190 unresolved_reloc = FALSE; 5191 relocation = (htab->plt->output_section->vma 5192 + htab->plt->output_offset 3492 5193 + h->plt.offset); 3493 5194 break; 3494 5195 3495 /* relocate against _SDA_BASE_*/3496 case (int)R_PPC_SDAREL16:5196 /* Relocate against _SDA_BASE_. */ 5197 case R_PPC_SDAREL16: 3497 5198 { 3498 5199 const char *name; 5200 const struct elf_link_hash_entry *sh; 3499 5201 3500 5202 BFD_ASSERT (sec != (asection *) 0); 3501 5203 name = bfd_get_section_name (abfd, sec->output_section); 3502 if (strcmp (name, ".sdata") != 0 3503 && strcmp (name, ".sbss") != 0) 5204 if (! ((strncmp (name, ".sdata", 6) == 0 5205 && (name[6] == 0 || name[6] == '.')) 5206 || (strncmp (name, ".sbss", 5) == 0 5207 && (name[5] == 0 || name[5] == '.')))) 3504 5208 { 3505 (*_bfd_error_handler) (_("%s: The target (%s) of a %s relocation is in the wrong output section (%s)"),3506 bfd_ get_filename (input_bfd),5209 (*_bfd_error_handler) (_("%s: the target (%s) of a %s relocation is in the wrong output section (%s)"), 5210 bfd_archive_filename (input_bfd), 3507 5211 sym_name, 3508 ppc_elf_howto_table[(int) r_type]->name,5212 howto->name, 3509 5213 name); 3510 5214 } 3511 addend -= (sdata->sym_hash->root.u.def.value 3512 + sdata->sym_hash->root.u.def.section->output_section->vma 3513 + sdata->sym_hash->root.u.def.section->output_offset); 5215 sh = htab->sdata->sym_hash; 5216 addend -= (sh->root.u.def.value 5217 + sh->root.u.def.section->output_section->vma 5218 + sh->root.u.def.section->output_offset); 3514 5219 } 3515 5220 break; 3516 5221 3517 /* relocate against _SDA2_BASE_*/3518 case (int)R_PPC_EMB_SDA2REL:5222 /* Relocate against _SDA2_BASE_. */ 5223 case R_PPC_EMB_SDA2REL: 3519 5224 { 3520 5225 const char *name; 5226 const struct elf_link_hash_entry *sh; 3521 5227 3522 5228 BFD_ASSERT (sec != (asection *) 0); 3523 5229 name = bfd_get_section_name (abfd, sec->output_section); 3524 if (strcmp (name, ".sdata2") != 0 && strcmp (name, ".sbss2") != 0) 5230 if (! (strncmp (name, ".sdata2", 7) == 0 5231 || strncmp (name, ".sbss2", 6) == 0)) 3525 5232 { 3526 (*_bfd_error_handler) (_("%s: The target (%s) of a %s relocation is in the wrong output section (%s)"),3527 bfd_ get_filename (input_bfd),5233 (*_bfd_error_handler) (_("%s: the target (%s) of a %s relocation is in the wrong output section (%s)"), 5234 bfd_archive_filename (input_bfd), 3528 5235 sym_name, 3529 ppc_elf_howto_table[(int) r_type]->name,5236 howto->name, 3530 5237 name); 3531 5238 3532 5239 bfd_set_error (bfd_error_bad_value); 3533 ret = false;5240 ret = FALSE; 3534 5241 continue; 3535 5242 } 3536 addend -= (sdata2->sym_hash->root.u.def.value 3537 + sdata2->sym_hash->root.u.def.section->output_section->vma 3538 + sdata2->sym_hash->root.u.def.section->output_offset); 5243 sh = htab->sdata2->sym_hash; 5244 addend -= (sh->root.u.def.value 5245 + sh->root.u.def.section->output_section->vma 5246 + sh->root.u.def.section->output_offset); 3539 5247 } 3540 5248 break; 3541 5249 3542 /* relocate against either _SDA_BASE_, _SDA2_BASE_, or 0*/3543 case (int)R_PPC_EMB_SDA21:3544 case (int)R_PPC_EMB_RELSDA:5250 /* Relocate against either _SDA_BASE_, _SDA2_BASE_, or 0. */ 5251 case R_PPC_EMB_SDA21: 5252 case R_PPC_EMB_RELSDA: 3545 5253 { 3546 5254 const char *name; 5255 const struct elf_link_hash_entry *sh; 3547 5256 int reg; 3548 5257 3549 5258 BFD_ASSERT (sec != (asection *) 0); 3550 5259 name = bfd_get_section_name (abfd, sec->output_section); 3551 if (strcmp (name, ".sdata") == 0 || strcmp (name, ".sbss") == 0) 5260 if (((strncmp (name, ".sdata", 6) == 0 5261 && (name[6] == 0 || name[6] == '.')) 5262 || (strncmp (name, ".sbss", 5) == 0 5263 && (name[5] == 0 || name[5] == '.')))) 3552 5264 { 3553 5265 reg = 13; 3554 addend -= (sdata->sym_hash->root.u.def.value 3555 + sdata->sym_hash->root.u.def.section->output_section->vma 3556 + sdata->sym_hash->root.u.def.section->output_offset); 5266 sh = htab->sdata->sym_hash; 5267 addend -= (sh->root.u.def.value 5268 + sh->root.u.def.section->output_section->vma 5269 + sh->root.u.def.section->output_offset); 3557 5270 } 3558 5271 3559 else if (str cmp (name, ".sdata2") == 03560 || str cmp (name, ".sbss2") == 0)5272 else if (strncmp (name, ".sdata2", 7) == 0 5273 || strncmp (name, ".sbss2", 6) == 0) 3561 5274 { 3562 5275 reg = 2; 3563 addend -= (sdata2->sym_hash->root.u.def.value 3564 + sdata2->sym_hash->root.u.def.section->output_section->vma 3565 + sdata2->sym_hash->root.u.def.section->output_offset); 5276 sh = htab->sdata2->sym_hash; 5277 addend -= (sh->root.u.def.value 5278 + sh->root.u.def.section->output_section->vma 5279 + sh->root.u.def.section->output_offset); 3566 5280 } 3567 5281 … … 3574 5288 else 3575 5289 { 3576 (*_bfd_error_handler) (_("%s: The target (%s) of a %s relocation is in the wrong output section (%s)"),3577 bfd_ get_filename (input_bfd),5290 (*_bfd_error_handler) (_("%s: the target (%s) of a %s relocation is in the wrong output section (%s)"), 5291 bfd_archive_filename (input_bfd), 3578 5292 sym_name, 3579 ppc_elf_howto_table[(int) r_type]->name,5293 howto->name, 3580 5294 name); 3581 5295 3582 5296 bfd_set_error (bfd_error_bad_value); 3583 ret = false;5297 ret = FALSE; 3584 5298 continue; 3585 5299 } … … 3587 5301 if (r_type == R_PPC_EMB_SDA21) 3588 5302 { /* fill in register field */ 3589 insn = bfd_get_32 (output_bfd, contents + offset);5303 insn = bfd_get_32 (output_bfd, contents + rel->r_offset); 3590 5304 insn = (insn & ~RA_REGISTER_MASK) | (reg << RA_REGISTER_SHIFT); 3591 bfd_put_32 (output_bfd, insn, contents + offset);5305 bfd_put_32 (output_bfd, insn, contents + rel->r_offset); 3592 5306 } 3593 5307 } 3594 5308 break; 3595 5309 3596 /* Relocate against the beginning of the section */ 3597 case (int) R_PPC_SECTOFF: 3598 case (int) R_PPC_SECTOFF_LO: 3599 case (int) R_PPC_SECTOFF_HI: 5310 /* Relocate against the beginning of the section. */ 5311 case R_PPC_SECTOFF: 5312 case R_PPC_SECTOFF_LO: 5313 case R_PPC_SECTOFF_HI: 5314 case R_PPC_SECTOFF_HA: 3600 5315 BFD_ASSERT (sec != (asection *) 0); 3601 5316 addend -= sec->output_section->vma; 3602 5317 break; 3603 5318 3604 case (int) R_PPC_SECTOFF_HA: 3605 BFD_ASSERT (sec != (asection *) 0); 3606 addend -= sec->output_section->vma; 3607 addend += ((relocation + addend) & 0x8000) << 1; 3608 break; 3609 3610 /* Negative relocations */ 3611 case (int) R_PPC_EMB_NADDR32: 3612 case (int) R_PPC_EMB_NADDR16: 3613 case (int) R_PPC_EMB_NADDR16_LO: 3614 case (int) R_PPC_EMB_NADDR16_HI: 5319 /* Negative relocations. */ 5320 case R_PPC_EMB_NADDR32: 5321 case R_PPC_EMB_NADDR16: 5322 case R_PPC_EMB_NADDR16_LO: 5323 case R_PPC_EMB_NADDR16_HI: 5324 case R_PPC_EMB_NADDR16_HA: 3615 5325 addend -= 2 * relocation; 3616 5326 break; 3617 5327 3618 case (int) R_PPC_EMB_NADDR16_HA: 3619 addend -= 2 * relocation; 3620 addend += ((relocation + addend) & 0x8000) << 1; 5328 case R_PPC_COPY: 5329 case R_PPC_GLOB_DAT: 5330 case R_PPC_JMP_SLOT: 5331 case R_PPC_RELATIVE: 5332 case R_PPC_PLT32: 5333 case R_PPC_PLTREL32: 5334 case R_PPC_PLT16_LO: 5335 case R_PPC_PLT16_HI: 5336 case R_PPC_PLT16_HA: 5337 case R_PPC_ADDR30: 5338 case R_PPC_EMB_RELSEC16: 5339 case R_PPC_EMB_RELST_LO: 5340 case R_PPC_EMB_RELST_HI: 5341 case R_PPC_EMB_RELST_HA: 5342 case R_PPC_EMB_BIT_FLD: 5343 (*_bfd_error_handler) 5344 (_("%s: relocation %s is not yet supported for symbol %s."), 5345 bfd_archive_filename (input_bfd), 5346 howto->name, 5347 sym_name); 5348 5349 bfd_set_error (bfd_error_invalid_operation); 5350 ret = FALSE; 5351 continue; 5352 } 5353 5354 /* Do any further special processing. */ 5355 switch (r_type) 5356 { 5357 default: 3621 5358 break; 3622 5359 3623 /* NOP relocation that prevents garbage collecting linkers from omitting a 3624 reference. */ 3625 case (int) R_PPC_EMB_MRKREF: 3626 continue; 3627 3628 case (int) R_PPC_COPY: 3629 case (int) R_PPC_GLOB_DAT: 3630 case (int) R_PPC_JMP_SLOT: 3631 case (int) R_PPC_RELATIVE: 3632 case (int) R_PPC_PLT32: 3633 case (int) R_PPC_PLTREL32: 3634 case (int) R_PPC_PLT16_LO: 3635 case (int) R_PPC_PLT16_HI: 3636 case (int) R_PPC_PLT16_HA: 3637 case (int) R_PPC_EMB_RELSEC16: 3638 case (int) R_PPC_EMB_RELST_LO: 3639 case (int) R_PPC_EMB_RELST_HI: 3640 case (int) R_PPC_EMB_RELST_HA: 3641 case (int) R_PPC_EMB_BIT_FLD: 3642 (*_bfd_error_handler) (_("%s: Relocation %s is not yet supported for symbol %s."), 3643 bfd_get_filename (input_bfd), 3644 ppc_elf_howto_table[(int) r_type]->name, 3645 sym_name); 3646 3647 bfd_set_error (bfd_error_invalid_operation); 3648 ret = false; 3649 continue; 3650 3651 case (int) R_PPC_GNU_VTINHERIT: 3652 case (int) R_PPC_GNU_VTENTRY: 3653 /* These are no-ops in the end. */ 3654 continue; 5360 case R_PPC_ADDR16_HA: 5361 case R_PPC_GOT16_HA: 5362 case R_PPC_PLT16_HA: 5363 case R_PPC_SECTOFF_HA: 5364 case R_PPC_TPREL16_HA: 5365 case R_PPC_DTPREL16_HA: 5366 case R_PPC_GOT_TLSGD16_HA: 5367 case R_PPC_GOT_TLSLD16_HA: 5368 case R_PPC_GOT_TPREL16_HA: 5369 case R_PPC_GOT_DTPREL16_HA: 5370 case R_PPC_EMB_NADDR16_HA: 5371 case R_PPC_EMB_RELST_HA: 5372 /* It's just possible that this symbol is a weak symbol 5373 that's not actually defined anywhere. In that case, 5374 'sec' would be NULL, and we should leave the symbol 5375 alone (it will be set to zero elsewhere in the link). */ 5376 if (sec != NULL) 5377 /* Add 0x10000 if sign bit in 0:15 is set. 5378 Bits 0:15 are not used. */ 5379 addend += 0x8000; 5380 break; 3655 5381 } 3656 5382 … … 3661 5387 sym_name, 3662 5388 r_symndx, 3663 (long) offset,5389 (long) rel->r_offset, 3664 5390 (long) addend); 3665 5391 #endif 5392 5393 if (unresolved_reloc 5394 && !((input_section->flags & SEC_DEBUGGING) != 0 5395 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0)) 5396 { 5397 (*_bfd_error_handler) 5398 (_("%s(%s+0x%lx): unresolvable %s relocation against symbol `%s'"), 5399 bfd_archive_filename (input_bfd), 5400 bfd_get_section_name (input_bfd, input_section), 5401 (long) rel->r_offset, 5402 howto->name, 5403 sym_name); 5404 ret = FALSE; 5405 } 3666 5406 3667 5407 r = _bfd_final_link_relocate (howto, … … 3669 5409 input_section, 3670 5410 contents, 3671 offset,5411 rel->r_offset, 3672 5412 relocation, 3673 5413 addend); 3674 5414 3675 if (r == bfd_reloc_ok) 3676 ; 3677 else if (r == bfd_reloc_overflow) 5415 if (r != bfd_reloc_ok) 3678 5416 { 3679 const char *name;3680 3681 if ( h != NULL)5417 if (sym_name == NULL) 5418 sym_name = "(null)"; 5419 if (r == bfd_reloc_overflow) 3682 5420 { 3683 if (h->root.type == bfd_link_hash_undefweak 5421 if (warned) 5422 continue; 5423 if (h != NULL 5424 && h->root.type == bfd_link_hash_undefweak 3684 5425 && howto->pc_relative) 3685 5426 { … … 3693 5434 } 3694 5435 3695 name = h->root.root.string; 5436 if (! (*info->callbacks->reloc_overflow) (info, 5437 sym_name, 5438 howto->name, 5439 rel->r_addend, 5440 input_bfd, 5441 input_section, 5442 rel->r_offset)) 5443 return FALSE; 3696 5444 } 3697 5445 else 3698 5446 { 3699 name = bfd_elf_string_from_elf_section (input_bfd, 3700 symtab_hdr->sh_link, 3701 sym->st_name); 3702 if (name == NULL) 3703 continue; 3704 if (*name == '\0') 3705 name = bfd_section_name (input_bfd, sec); 5447 (*_bfd_error_handler) 5448 (_("%s(%s+0x%lx): %s reloc against `%s': error %d"), 5449 bfd_archive_filename (input_bfd), 5450 bfd_get_section_name (input_bfd, input_section), 5451 (long) rel->r_offset, howto->name, sym_name, (int) r); 5452 ret = FALSE; 3706 5453 } 3707 3708 if (! (*info->callbacks->reloc_overflow) (info,3709 name,3710 howto->name,3711 (bfd_vma) 0,3712 input_bfd,3713 input_section,3714 offset))3715 return false;3716 5454 } 3717 else3718 ret = false;3719 5455 } 3720 5456 … … 3724 5460 3725 5461 return ret; 5462 } 5463 5464 static enum elf_reloc_type_class 5465 ppc_elf_reloc_type_class (rela) 5466 const Elf_Internal_Rela *rela; 5467 { 5468 switch ((int) ELF32_R_TYPE (rela->r_info)) 5469 { 5470 case R_PPC_RELATIVE: 5471 return reloc_class_relative; 5472 case R_PPC_REL24: 5473 case R_PPC_ADDR24: 5474 case R_PPC_JMP_SLOT: 5475 return reloc_class_plt; 5476 case R_PPC_COPY: 5477 return reloc_class_copy; 5478 default: 5479 return reloc_class_normal; 5480 } 5481 } 5482 5483 5484 /* Support for core dump NOTE sections. */ 5485 5486 static bfd_boolean 5487 ppc_elf_grok_prstatus (abfd, note) 5488 bfd *abfd; 5489 Elf_Internal_Note *note; 5490 { 5491 int offset; 5492 unsigned int raw_size; 5493 5494 switch (note->descsz) 5495 { 5496 default: 5497 return FALSE; 5498 5499 case 268: /* Linux/PPC. */ 5500 /* pr_cursig */ 5501 elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12); 5502 5503 /* pr_pid */ 5504 elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24); 5505 5506 /* pr_reg */ 5507 offset = 72; 5508 raw_size = 192; 5509 5510 break; 5511 } 5512 5513 /* Make a ".reg/999" section. */ 5514 return _bfd_elfcore_make_pseudosection (abfd, ".reg", 5515 raw_size, note->descpos + offset); 5516 } 5517 5518 static bfd_boolean 5519 ppc_elf_grok_psinfo (abfd, note) 5520 bfd *abfd; 5521 Elf_Internal_Note *note; 5522 { 5523 switch (note->descsz) 5524 { 5525 default: 5526 return FALSE; 5527 5528 case 128: /* Linux/PPC elf_prpsinfo. */ 5529 elf_tdata (abfd)->core_program 5530 = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16); 5531 elf_tdata (abfd)->core_command 5532 = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80); 5533 } 5534 5535 /* Note that for some reason, a spurious space is tacked 5536 onto the end of the args in some (at least one anyway) 5537 implementations, so strip it off if it exists. */ 5538 5539 { 5540 char *command = elf_tdata (abfd)->core_command; 5541 int n = strlen (command); 5542 5543 if (0 < n && command[n - 1] == ' ') 5544 command[n - 1] = '\0'; 5545 } 5546 5547 return TRUE; 5548 } 5549 5550 5551 /* Very simple linked list structure for recording apuinfo values. */ 5552 typedef struct apuinfo_list 5553 { 5554 struct apuinfo_list *next; 5555 unsigned long value; 5556 } 5557 apuinfo_list; 5558 5559 static apuinfo_list * head; 5560 5561 static void apuinfo_list_init PARAMS ((void)); 5562 static void apuinfo_list_add PARAMS ((unsigned long)); 5563 static unsigned apuinfo_list_length PARAMS ((void)); 5564 static unsigned long apuinfo_list_element PARAMS ((unsigned long)); 5565 static void apuinfo_list_finish PARAMS ((void)); 5566 5567 extern void ppc_elf_begin_write_processing 5568 PARAMS ((bfd *, struct bfd_link_info *)); 5569 extern void ppc_elf_final_write_processing 5570 PARAMS ((bfd *, bfd_boolean)); 5571 extern bfd_boolean ppc_elf_write_section 5572 PARAMS ((bfd *, asection *, bfd_byte *)); 5573 5574 5575 static void 5576 apuinfo_list_init PARAMS ((void)) 5577 { 5578 head = NULL; 5579 } 5580 5581 static void 5582 apuinfo_list_add (value) 5583 unsigned long value; 5584 { 5585 apuinfo_list *entry = head; 5586 5587 while (entry != NULL) 5588 { 5589 if (entry->value == value) 5590 return; 5591 entry = entry->next; 5592 } 5593 5594 entry = bfd_malloc (sizeof (* entry)); 5595 if (entry == NULL) 5596 return; 5597 5598 entry->value = value; 5599 entry->next = head; 5600 head = entry; 5601 } 5602 5603 static unsigned 5604 apuinfo_list_length PARAMS ((void)) 5605 { 5606 apuinfo_list *entry; 5607 unsigned long count; 5608 5609 for (entry = head, count = 0; 5610 entry; 5611 entry = entry->next) 5612 ++ count; 5613 5614 return count; 5615 } 5616 5617 static inline unsigned long 5618 apuinfo_list_element (number) 5619 unsigned long number; 5620 { 5621 apuinfo_list * entry; 5622 5623 for (entry = head; 5624 entry && number --; 5625 entry = entry->next) 5626 ; 5627 5628 return entry ? entry->value : 0; 5629 } 5630 5631 static void 5632 apuinfo_list_finish PARAMS ((void)) 5633 { 5634 apuinfo_list *entry; 5635 5636 for (entry = head; entry;) 5637 { 5638 apuinfo_list *next = entry->next; 5639 free (entry); 5640 entry = next; 5641 } 5642 5643 head = NULL; 5644 } 5645 5646 #define APUINFO_SECTION_NAME ".PPC.EMB.apuinfo" 5647 #define APUINFO_LABEL "APUinfo" 5648 5649 /* Scan the input BFDs and create a linked list of 5650 the APUinfo values that will need to be emitted. */ 5651 5652 void 5653 ppc_elf_begin_write_processing (abfd, link_info) 5654 bfd *abfd; 5655 struct bfd_link_info *link_info; 5656 { 5657 bfd *ibfd; 5658 asection *asec; 5659 char *buffer; 5660 unsigned num_input_sections; 5661 bfd_size_type output_section_size; 5662 unsigned i; 5663 unsigned num_entries; 5664 unsigned long offset; 5665 unsigned long length; 5666 const char *error_message = NULL; 5667 5668 if (link_info == NULL) 5669 return; 5670 5671 /* Scan the input bfds, looking for apuinfo sections. */ 5672 num_input_sections = 0; 5673 output_section_size = 0; 5674 5675 for (ibfd = link_info->input_bfds; ibfd; ibfd = ibfd->link_next) 5676 { 5677 asec = bfd_get_section_by_name (ibfd, APUINFO_SECTION_NAME); 5678 if (asec) 5679 { 5680 ++ num_input_sections; 5681 output_section_size += asec->_raw_size; 5682 } 5683 } 5684 5685 /* We need at least one input sections 5686 in order to make merging worthwhile. */ 5687 if (num_input_sections < 1) 5688 return; 5689 5690 /* Just make sure that the output section exists as well. */ 5691 asec = bfd_get_section_by_name (abfd, APUINFO_SECTION_NAME); 5692 if (asec == NULL) 5693 return; 5694 5695 /* Allocate a buffer for the contents of the input sections. */ 5696 buffer = bfd_malloc (output_section_size); 5697 if (buffer == NULL) 5698 return; 5699 5700 offset = 0; 5701 apuinfo_list_init (); 5702 5703 /* Read in the input sections contents. */ 5704 for (ibfd = link_info->input_bfds; ibfd; ibfd = ibfd->link_next) 5705 { 5706 unsigned long datum; 5707 char *ptr; 5708 5709 asec = bfd_get_section_by_name (ibfd, APUINFO_SECTION_NAME); 5710 if (asec == NULL) 5711 continue; 5712 5713 length = asec->_raw_size; 5714 if (length < 24) 5715 { 5716 error_message = _("corrupt or empty %s section in %s"); 5717 goto fail; 5718 } 5719 5720 if (bfd_seek (ibfd, asec->filepos, SEEK_SET) != 0 5721 || (bfd_bread (buffer + offset, length, ibfd) != length)) 5722 { 5723 error_message = _("unable to read in %s section from %s"); 5724 goto fail; 5725 } 5726 5727 /* Process the contents of the section. */ 5728 ptr = buffer + offset; 5729 error_message = _("corrupt %s section in %s"); 5730 5731 /* Verify the contents of the header. Note - we have to 5732 extract the values this way in order to allow for a 5733 host whose endian-ness is different from the target. */ 5734 datum = bfd_get_32 (ibfd, ptr); 5735 if (datum != sizeof APUINFO_LABEL) 5736 goto fail; 5737 5738 datum = bfd_get_32 (ibfd, ptr + 8); 5739 if (datum != 0x2) 5740 goto fail; 5741 5742 if (strcmp (ptr + 12, APUINFO_LABEL) != 0) 5743 goto fail; 5744 5745 /* Get the number of apuinfo entries. */ 5746 datum = bfd_get_32 (ibfd, ptr + 4); 5747 if ((datum * 4 + 20) != length) 5748 goto fail; 5749 5750 /* Make sure that we do not run off the end of the section. */ 5751 if (offset + length > output_section_size) 5752 goto fail; 5753 5754 /* Scan the apuinfo section, building a list of apuinfo numbers. */ 5755 for (i = 0; i < datum; i++) 5756 apuinfo_list_add (bfd_get_32 (ibfd, ptr + 20 + (i * 4))); 5757 5758 /* Update the offset. */ 5759 offset += length; 5760 } 5761 5762 error_message = NULL; 5763 5764 /* Compute the size of the output section. */ 5765 num_entries = apuinfo_list_length (); 5766 output_section_size = 20 + num_entries * 4; 5767 5768 asec = bfd_get_section_by_name (abfd, APUINFO_SECTION_NAME); 5769 5770 if (! bfd_set_section_size (abfd, asec, output_section_size)) 5771 ibfd = abfd, 5772 error_message = _("warning: unable to set size of %s section in %s"); 5773 5774 fail: 5775 free (buffer); 5776 5777 if (error_message) 5778 (*_bfd_error_handler) (error_message, APUINFO_SECTION_NAME, 5779 bfd_archive_filename (ibfd)); 5780 } 5781 5782 5783 /* Prevent the output section from accumulating the input sections' 5784 contents. We have already stored this in our linked list structure. */ 5785 5786 bfd_boolean 5787 ppc_elf_write_section (abfd, asec, contents) 5788 bfd *abfd ATTRIBUTE_UNUSED; 5789 asection *asec; 5790 bfd_byte *contents ATTRIBUTE_UNUSED; 5791 { 5792 return (apuinfo_list_length () 5793 && strcmp (asec->name, APUINFO_SECTION_NAME) == 0); 5794 } 5795 5796 5797 /* Finally we can generate the output section. */ 5798 5799 void 5800 ppc_elf_final_write_processing (abfd, linker) 5801 bfd *abfd; 5802 bfd_boolean linker ATTRIBUTE_UNUSED; 5803 { 5804 bfd_byte *buffer; 5805 asection *asec; 5806 unsigned i; 5807 unsigned num_entries; 5808 bfd_size_type length; 5809 5810 asec = bfd_get_section_by_name (abfd, APUINFO_SECTION_NAME); 5811 if (asec == NULL) 5812 return; 5813 5814 if (apuinfo_list_length () == 0) 5815 return; 5816 5817 length = asec->_raw_size; 5818 if (length < 20) 5819 return; 5820 5821 buffer = bfd_malloc (length); 5822 if (buffer == NULL) 5823 { 5824 (*_bfd_error_handler) 5825 (_("failed to allocate space for new APUinfo section.")); 5826 return; 5827 } 5828 5829 /* Create the apuinfo header. */ 5830 num_entries = apuinfo_list_length (); 5831 bfd_put_32 (abfd, sizeof APUINFO_LABEL, buffer); 5832 bfd_put_32 (abfd, num_entries, buffer + 4); 5833 bfd_put_32 (abfd, 0x2, buffer + 8); 5834 strcpy (buffer + 12, APUINFO_LABEL); 5835 5836 length = 20; 5837 for (i = 0; i < num_entries; i++) 5838 { 5839 bfd_put_32 (abfd, apuinfo_list_element (i), buffer + length); 5840 length += 4; 5841 } 5842 5843 if (length != asec->_raw_size) 5844 (*_bfd_error_handler) (_("failed to compute new APUinfo section.")); 5845 5846 if (! bfd_set_section_contents (abfd, asec, buffer, (file_ptr) 0, length)) 5847 (*_bfd_error_handler) (_("failed to install new APUinfo section.")); 5848 5849 free (buffer); 5850 5851 apuinfo_list_finish (); 3726 5852 } 3727 5853 … … 3747 5873 #define elf_backend_got_symbol_offset 4 3748 5874 #define elf_backend_can_gc_sections 1 5875 #define elf_backend_can_refcount 1 3749 5876 #define elf_backend_got_header_size 12 3750 5877 #define elf_backend_plt_header_size PLT_INITIAL_ENTRY_SIZE 3751 3752 #define bfd_elf32_bfd_copy_private_bfd_data ppc_elf_copy_private_bfd_data 5878 #define elf_backend_rela_normal 1 5879 3753 5880 #define bfd_elf32_bfd_merge_private_bfd_data ppc_elf_merge_private_bfd_data 3754 #define bfd_elf32_bfd_relax_section 5881 #define bfd_elf32_bfd_relax_section ppc_elf_relax_section 3755 5882 #define bfd_elf32_bfd_reloc_type_lookup ppc_elf_reloc_type_lookup 3756 5883 #define bfd_elf32_bfd_set_private_flags ppc_elf_set_private_flags 3757 #define bfd_elf32_bfd_final_link _bfd_elf32_gc_common_final_link 3758 5884 #define bfd_elf32_bfd_link_hash_table_create ppc_elf_link_hash_table_create 5885 5886 #define elf_backend_object_p ppc_elf_object_p 3759 5887 #define elf_backend_gc_mark_hook ppc_elf_gc_mark_hook 3760 5888 #define elf_backend_gc_sweep_hook ppc_elf_gc_sweep_hook … … 3763 5891 #define elf_backend_create_dynamic_sections ppc_elf_create_dynamic_sections 3764 5892 #define elf_backend_check_relocs ppc_elf_check_relocs 5893 #define elf_backend_copy_indirect_symbol ppc_elf_copy_indirect_symbol 3765 5894 #define elf_backend_adjust_dynamic_symbol ppc_elf_adjust_dynamic_symbol 3766 5895 #define elf_backend_add_symbol_hook ppc_elf_add_symbol_hook … … 3771 5900 #define elf_backend_additional_program_headers ppc_elf_additional_program_headers 3772 5901 #define elf_backend_modify_segment_map ppc_elf_modify_segment_map 5902 #define elf_backend_grok_prstatus ppc_elf_grok_prstatus 5903 #define elf_backend_grok_psinfo ppc_elf_grok_psinfo 5904 #define elf_backend_reloc_type_class ppc_elf_reloc_type_class 5905 #define elf_backend_begin_write_processing ppc_elf_begin_write_processing 5906 #define elf_backend_final_write_processing ppc_elf_final_write_processing 5907 #define elf_backend_write_section ppc_elf_write_section 3773 5908 3774 5909 #include "elf32-target.h" -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.