1 /* Motorola MCore specific support for 32-bit ELF 2 Copyright (C) 1994-2014 Free Software Foundation, Inc. 3 4 This file is part of BFD, the Binary File Descriptor library. 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 3 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 19 MA 02110-1301, USA. */ 20 21 22 /* This file is based on a preliminary RCE ELF ABI. The 23 information may not match the final RCE ELF ABI. */ 24 25 #include "sysdep.h" 26 #include "bfd.h" 27 #include "bfdlink.h" 28 #include "libbfd.h" 29 #include "elf-bfd.h" 30 #include "elf/mcore.h" 31 #include <assert.h> 32 33 /* RELA relocs are used here... */ 34 35 /* Function to set whether a module needs the -mrelocatable bit set. */ 36 37 static bfd_boolean 38 mcore_elf_set_private_flags (bfd * abfd, flagword flags) 39 { 40 BFD_ASSERT (! elf_flags_init (abfd) 41 || elf_elfheader (abfd)->e_flags == flags); 42 43 elf_elfheader (abfd)->e_flags = flags; 44 elf_flags_init (abfd) = TRUE; 45 return TRUE; 46 } 47 48 /* Merge backend specific data from an object file to the output 49 object file when linking. */ 50 51 static bfd_boolean 52 mcore_elf_merge_private_bfd_data (bfd * ibfd, bfd * obfd) 53 { 54 flagword old_flags; 55 flagword new_flags; 56 57 /* Check if we have the same endianness. */ 58 if (! _bfd_generic_verify_endian_match (ibfd, obfd)) 59 return FALSE; 60 61 if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour 62 || bfd_get_flavour (obfd) != bfd_target_elf_flavour) 63 return TRUE; 64 65 new_flags = elf_elfheader (ibfd)->e_flags; 66 old_flags = elf_elfheader (obfd)->e_flags; 67 68 if (! elf_flags_init (obfd)) 69 { 70 /* First call, no flags set. */ 71 elf_flags_init (obfd) = TRUE; 72 elf_elfheader (obfd)->e_flags = new_flags; 73 } 74 else if (new_flags == old_flags) 75 /* Compatible flags are OK. */ 76 ; 77 else 78 { 79 /* FIXME */ 80 } 81 82 return TRUE; 83 } 84 85 /* Don't pretend we can deal with unsupported relocs. */ 87 88 static bfd_reloc_status_type 89 mcore_elf_unsupported_reloc (bfd * abfd, 90 arelent * reloc_entry, 91 asymbol * symbol ATTRIBUTE_UNUSED, 92 void * data ATTRIBUTE_UNUSED, 93 asection * input_section ATTRIBUTE_UNUSED, 94 bfd * output_bfd ATTRIBUTE_UNUSED, 95 char ** error_message ATTRIBUTE_UNUSED) 96 { 97 BFD_ASSERT (reloc_entry->howto != (reloc_howto_type *)0); 98 99 _bfd_error_handler (_("%B: Relocation %s (%d) is not currently supported.\n"), 100 abfd, 101 reloc_entry->howto->name, 102 reloc_entry->howto->type); 103 104 return bfd_reloc_notsupported; 105 } 106 107 static reloc_howto_type * mcore_elf_howto_table [(int) R_MCORE_max]; 108 109 static reloc_howto_type mcore_elf_howto_raw[] = 110 { 111 /* This reloc does nothing. */ 112 HOWTO (R_MCORE_NONE, /* type */ 113 0, /* rightshift */ 114 2, /* size (0 = byte, 1 = short, 2 = long) */ 115 32, /* bitsize */ 116 FALSE, /* pc_relative */ 117 0, /* bitpos */ 118 complain_overflow_bitfield, /* complain_on_overflow */ 119 NULL, /* special_function */ 120 "R_MCORE_NONE", /* name */ 121 FALSE, /* partial_inplace */ 122 0, /* src_mask */ 123 0, /* dst_mask */ 124 FALSE), /* pcrel_offset */ 125 126 /* A standard 32 bit relocation. */ 127 HOWTO (R_MCORE_ADDR32, /* type */ 128 0, /* rightshift */ 129 2, /* size (0 = byte, 1 = short, 2 = long) */ 130 32, /* bitsize */ 131 FALSE, /* pc_relative */ 132 0, /* bitpos */ 133 complain_overflow_bitfield, /* complain_on_overflow */ 134 bfd_elf_generic_reloc, /* special_function */ 135 "ADDR32", /* name *//* For compatibility with coff/pe port. */ 136 FALSE, /* partial_inplace */ 137 0x0, /* src_mask */ 138 0xffffffff, /* dst_mask */ 139 FALSE), /* pcrel_offset */ 140 141 /* 8 bits + 2 zero bits; jmpi/jsri/lrw instructions. 142 Should not appear in object files. */ 143 HOWTO (R_MCORE_PCRELIMM8BY4, /* type */ 144 2, /* rightshift */ 145 1, /* size (0 = byte, 1 = short, 2 = long) */ 146 8, /* bitsize */ 147 TRUE, /* pc_relative */ 148 0, /* bitpos */ 149 complain_overflow_bitfield, /* complain_on_overflow */ 150 mcore_elf_unsupported_reloc, /* special_function */ 151 "R_MCORE_PCRELIMM8BY4",/* name */ 152 FALSE, /* partial_inplace */ 153 0, /* src_mask */ 154 0, /* dst_mask */ 155 TRUE), /* pcrel_offset */ 156 157 /* bsr/bt/bf/br instructions; 11 bits + 1 zero bit 158 Span 2k instructions == 4k bytes. 159 Only useful pieces at the relocated address are the opcode (5 bits) */ 160 HOWTO (R_MCORE_PCRELIMM11BY2,/* type */ 161 1, /* rightshift */ 162 1, /* size (0 = byte, 1 = short, 2 = long) */ 163 11, /* bitsize */ 164 TRUE, /* pc_relative */ 165 0, /* bitpos */ 166 complain_overflow_signed, /* complain_on_overflow */ 167 bfd_elf_generic_reloc, /* special_function */ 168 "R_MCORE_PCRELIMM11BY2",/* name */ 169 FALSE, /* partial_inplace */ 170 0x0, /* src_mask */ 171 0x7ff, /* dst_mask */ 172 TRUE), /* pcrel_offset */ 173 174 /* 4 bits + 1 zero bit; 'loopt' instruction only; unsupported. */ 175 HOWTO (R_MCORE_PCRELIMM4BY2, /* type */ 176 1, /* rightshift */ 177 1, /* size (0 = byte, 1 = short, 2 = long) */ 178 4, /* bitsize */ 179 TRUE, /* pc_relative */ 180 0, /* bitpos */ 181 complain_overflow_bitfield, /* complain_on_overflow */ 182 mcore_elf_unsupported_reloc,/* special_function */ 183 "R_MCORE_PCRELIMM4BY2",/* name */ 184 FALSE, /* partial_inplace */ 185 0, /* src_mask */ 186 0, /* dst_mask */ 187 TRUE), /* pcrel_offset */ 188 189 /* 32-bit pc-relative. Eventually this will help support PIC code. */ 190 HOWTO (R_MCORE_PCREL32, /* type */ 191 0, /* rightshift */ 192 2, /* size (0 = byte, 1 = short, 2 = long) */ 193 32, /* bitsize */ 194 TRUE, /* pc_relative */ 195 0, /* bitpos */ 196 complain_overflow_bitfield, /* complain_on_overflow */ 197 bfd_elf_generic_reloc, /* special_function */ 198 "R_MCORE_PCREL32", /* name */ 199 FALSE, /* partial_inplace */ 200 0x0, /* src_mask */ 201 0xffffffff, /* dst_mask */ 202 TRUE), /* pcrel_offset */ 203 204 /* Like PCRELIMM11BY2, this relocation indicates that there is a 205 'jsri' at the specified address. There is a separate relocation 206 entry for the literal pool entry that it references, but we 207 might be able to change the jsri to a bsr if the target turns out 208 to be close enough [even though we won't reclaim the literal pool 209 entry, we'll get some runtime efficiency back]. Note that this 210 is a relocation that we are allowed to safely ignore. */ 211 HOWTO (R_MCORE_PCRELJSR_IMM11BY2,/* type */ 212 1, /* rightshift */ 213 1, /* size (0 = byte, 1 = short, 2 = long) */ 214 11, /* bitsize */ 215 TRUE, /* pc_relative */ 216 0, /* bitpos */ 217 complain_overflow_signed, /* complain_on_overflow */ 218 bfd_elf_generic_reloc, /* special_function */ 219 "R_MCORE_PCRELJSR_IMM11BY2", /* name */ 220 FALSE, /* partial_inplace */ 221 0x0, /* src_mask */ 222 0x7ff, /* dst_mask */ 223 TRUE), /* pcrel_offset */ 224 225 /* GNU extension to record C++ vtable hierarchy. */ 226 HOWTO (R_MCORE_GNU_VTINHERIT, /* type */ 227 0, /* rightshift */ 228 2, /* size (0 = byte, 1 = short, 2 = long) */ 229 0, /* bitsize */ 230 FALSE, /* pc_relative */ 231 0, /* bitpos */ 232 complain_overflow_dont, /* complain_on_overflow */ 233 NULL, /* special_function */ 234 "R_MCORE_GNU_VTINHERIT", /* name */ 235 FALSE, /* partial_inplace */ 236 0, /* src_mask */ 237 0, /* dst_mask */ 238 FALSE), /* pcrel_offset */ 239 240 /* GNU extension to record C++ vtable member usage. */ 241 HOWTO (R_MCORE_GNU_VTENTRY, /* type */ 242 0, /* rightshift */ 243 2, /* size (0 = byte, 1 = short, 2 = long) */ 244 0, /* bitsize */ 245 FALSE, /* pc_relative */ 246 0, /* bitpos */ 247 complain_overflow_dont,/* complain_on_overflow */ 248 _bfd_elf_rel_vtable_reloc_fn, /* special_function */ 249 "R_MCORE_GNU_VTENTRY", /* name */ 250 FALSE, /* partial_inplace */ 251 0, /* src_mask */ 252 0, /* dst_mask */ 253 FALSE), /* pcrel_offset */ 254 255 HOWTO (R_MCORE_RELATIVE, /* type */ 256 0, /* rightshift */ 257 2, /* size (0 = byte, 1 = short, 2 = long) */ 258 32, /* bitsize */ 259 FALSE, /* pc_relative */ 260 0, /* bitpos */ 261 complain_overflow_signed, /* complain_on_overflow */ 262 NULL, /* special_function */ 263 "R_MCORE_RELATIVE", /* name */ 264 TRUE, /* partial_inplace */ 265 0xffffffff, /* src_mask */ 266 0xffffffff, /* dst_mask */ 267 FALSE) /* pcrel_offset */ 268 }; 269 270 #ifndef NUM_ELEM 271 #define NUM_ELEM(a) (sizeof (a) / sizeof (a)[0]) 272 #endif 273 274 /* Initialize the mcore_elf_howto_table, so that linear accesses can be done. */ 276 static void 277 mcore_elf_howto_init (void) 278 { 279 unsigned int i; 280 281 for (i = NUM_ELEM (mcore_elf_howto_raw); i--;) 282 { 283 unsigned int type; 284 285 type = mcore_elf_howto_raw[i].type; 286 287 BFD_ASSERT (type < NUM_ELEM (mcore_elf_howto_table)); 288 289 mcore_elf_howto_table [type] = & mcore_elf_howto_raw [i]; 290 } 291 } 292 293 static reloc_howto_type * 295 mcore_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED, 296 bfd_reloc_code_real_type code) 297 { 298 enum elf_mcore_reloc_type mcore_reloc = R_MCORE_NONE; 299 300 switch (code) 301 { 302 case BFD_RELOC_NONE: mcore_reloc = R_MCORE_NONE; break; 303 case BFD_RELOC_32: mcore_reloc = R_MCORE_ADDR32; break; 304 case BFD_RELOC_MCORE_PCREL_IMM8BY4: mcore_reloc = R_MCORE_PCRELIMM8BY4; break; 305 case BFD_RELOC_MCORE_PCREL_IMM11BY2: mcore_reloc = R_MCORE_PCRELIMM11BY2; break; 306 case BFD_RELOC_MCORE_PCREL_IMM4BY2: mcore_reloc = R_MCORE_PCRELIMM4BY2; break; 307 case BFD_RELOC_32_PCREL: mcore_reloc = R_MCORE_PCREL32; break; 308 case BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2: mcore_reloc = R_MCORE_PCRELJSR_IMM11BY2; break; 309 case BFD_RELOC_VTABLE_INHERIT: mcore_reloc = R_MCORE_GNU_VTINHERIT; break; 310 case BFD_RELOC_VTABLE_ENTRY: mcore_reloc = R_MCORE_GNU_VTENTRY; break; 311 case BFD_RELOC_RVA: mcore_reloc = R_MCORE_RELATIVE; break; 312 default: 313 return NULL; 314 } 315 316 if (! mcore_elf_howto_table [R_MCORE_PCRELIMM8BY4]) 317 /* Initialize howto table if needed. */ 318 mcore_elf_howto_init (); 319 320 return mcore_elf_howto_table [(int) mcore_reloc]; 321 }; 322 323 static reloc_howto_type * 324 mcore_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, 325 const char *r_name) 326 { 327 unsigned int i; 328 329 for (i = 0; 330 i < sizeof (mcore_elf_howto_raw) / sizeof (mcore_elf_howto_raw[0]); 331 i++) 332 if (mcore_elf_howto_raw[i].name != NULL 333 && strcasecmp (mcore_elf_howto_raw[i].name, r_name) == 0) 334 return &mcore_elf_howto_raw[i]; 335 336 return NULL; 337 } 338 339 /* Set the howto pointer for a RCE ELF reloc. */ 340 341 static void 342 mcore_elf_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED, 343 arelent * cache_ptr, 344 Elf_Internal_Rela * dst) 345 { 346 if (! mcore_elf_howto_table [R_MCORE_PCRELIMM8BY4]) 347 /* Initialize howto table if needed. */ 348 mcore_elf_howto_init (); 349 350 BFD_ASSERT (ELF32_R_TYPE (dst->r_info) < (unsigned int) R_MCORE_max); 351 352 cache_ptr->howto = mcore_elf_howto_table [ELF32_R_TYPE (dst->r_info)]; 353 } 354 355 /* The RELOCATE_SECTION function is called by the ELF backend linker 357 to handle the relocations for a section. 358 359 The relocs are always passed as Rela structures; if the section 360 actually uses Rel structures, the r_addend field will always be 361 zero. 362 363 This function is responsible for adjust the section contents as 364 necessary, and (if using Rela relocs and generating a 365 relocatable output file) adjusting the reloc addend as 366 necessary. 367 368 This function does not have to worry about setting the reloc 369 address or the reloc symbol index. 370 371 LOCAL_SYMS is a pointer to the swapped in local symbols. 372 373 LOCAL_SECTIONS is an array giving the section in the input file 374 corresponding to the st_shndx field of each local symbol. 375 376 The global hash table entry for the global symbols can be found 377 via elf_sym_hashes (input_bfd). 378 379 When generating relocatable output, this function must handle 380 STB_LOCAL/STT_SECTION symbols specially. The output symbol is 381 going to be the section symbol corresponding to the output 382 section, which means that the addend must be adjusted 383 accordingly. */ 384 385 static bfd_boolean 386 mcore_elf_relocate_section (bfd * output_bfd, 387 struct bfd_link_info * info, 388 bfd * input_bfd, 389 asection * input_section, 390 bfd_byte * contents, 391 Elf_Internal_Rela * relocs, 392 Elf_Internal_Sym * local_syms, 393 asection ** local_sections) 394 { 395 Elf_Internal_Shdr * symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr; 396 struct elf_link_hash_entry ** sym_hashes = elf_sym_hashes (input_bfd); 397 Elf_Internal_Rela * rel = relocs; 398 Elf_Internal_Rela * relend = relocs + input_section->reloc_count; 399 bfd_boolean ret = TRUE; 400 401 #ifdef DEBUG 402 _bfd_error_handler 403 ("mcore_elf_relocate_section called for %B section %A, %ld relocations%s", 404 input_bfd, 405 input_section, 406 (long) input_section->reloc_count, 407 (info->relocatable) ? " (relocatable)" : ""); 408 #endif 409 410 if (! mcore_elf_howto_table [R_MCORE_PCRELIMM8BY4]) /* Initialize howto table if needed */ 411 mcore_elf_howto_init (); 412 413 for (; rel < relend; rel++) 414 { 415 enum elf_mcore_reloc_type r_type = (enum elf_mcore_reloc_type) ELF32_R_TYPE (rel->r_info); 416 bfd_vma offset = rel->r_offset; 417 bfd_vma addend = rel->r_addend; 418 bfd_reloc_status_type r = bfd_reloc_other; 419 asection * sec = NULL; 420 reloc_howto_type * howto; 421 bfd_vma relocation; 422 Elf_Internal_Sym * sym = NULL; 423 unsigned long r_symndx; 424 struct elf_link_hash_entry * h = NULL; 425 unsigned short oldinst = 0; 426 427 /* Unknown relocation handling. */ 428 if ((unsigned) r_type >= (unsigned) R_MCORE_max 429 || ! mcore_elf_howto_table [(int)r_type]) 430 { 431 _bfd_error_handler (_("%B: Unknown relocation type %d\n"), 432 input_bfd, (int) r_type); 433 434 bfd_set_error (bfd_error_bad_value); 435 ret = FALSE; 436 continue; 437 } 438 439 howto = mcore_elf_howto_table [(int) r_type]; 440 r_symndx = ELF32_R_SYM (rel->r_info); 441 442 /* Complain about known relocation that are not yet supported. */ 443 if (howto->special_function == mcore_elf_unsupported_reloc) 444 { 445 _bfd_error_handler (_("%B: Relocation %s (%d) is not currently supported.\n"), 446 input_bfd, 447 howto->name, 448 (int)r_type); 449 450 bfd_set_error (bfd_error_bad_value); 451 ret = FALSE; 452 continue; 453 } 454 455 if (r_symndx < symtab_hdr->sh_info) 456 { 457 sym = local_syms + r_symndx; 458 sec = local_sections [r_symndx]; 459 relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel); 460 addend = rel->r_addend; 461 } 462 else 463 { 464 bfd_boolean unresolved_reloc, warned, ignored; 465 466 RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, 467 r_symndx, symtab_hdr, sym_hashes, 468 h, sec, relocation, 469 unresolved_reloc, warned, ignored); 470 } 471 472 if (sec != NULL && discarded_section (sec)) 473 RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, 474 rel, 1, relend, howto, 0, contents); 475 476 if (info->relocatable) 477 continue; 478 479 switch (r_type) 480 { 481 default: 482 break; 483 484 case R_MCORE_PCRELJSR_IMM11BY2: 485 oldinst = bfd_get_16 (input_bfd, contents + offset); 486 #define MCORE_INST_BSR 0xF800 487 bfd_put_16 (input_bfd, (bfd_vma) MCORE_INST_BSR, contents + offset); 488 break; 489 } 490 491 #ifdef DEBUG 492 fprintf (stderr, "\ttype = %s (%d), symbol index = %ld, offset = %ld, addend = %ld\n", 493 howto->name, r_type, r_symndx, (long) offset, (long) addend); 494 #endif 495 496 r = _bfd_final_link_relocate 497 (howto, input_bfd, input_section, contents, offset, relocation, addend); 498 499 if (r != bfd_reloc_ok && r_type == R_MCORE_PCRELJSR_IMM11BY2) 500 { 501 /* Wasn't ok, back it out and give up. */ 502 bfd_put_16 (input_bfd, (bfd_vma) oldinst, contents + offset); 503 r = bfd_reloc_ok; 504 } 505 506 if (r != bfd_reloc_ok) 507 { 508 ret = FALSE; 509 510 switch (r) 511 { 512 default: 513 break; 514 515 case bfd_reloc_overflow: 516 { 517 const char * name; 518 519 if (h != NULL) 520 name = NULL; 521 else 522 { 523 name = bfd_elf_string_from_elf_section 524 (input_bfd, symtab_hdr->sh_link, sym->st_name); 525 526 if (name == NULL) 527 break; 528 529 if (* name == '\0') 530 name = bfd_section_name (input_bfd, sec); 531 } 532 533 (*info->callbacks->reloc_overflow) 534 (info, (h ? &h->root : NULL), name, howto->name, 535 (bfd_vma) 0, input_bfd, input_section, offset); 536 } 537 break; 538 } 539 } 540 } 541 542 #ifdef DEBUG 543 fprintf (stderr, "\n"); 544 #endif 545 546 return ret; 547 } 548 549 /* Return the section that should be marked against GC for a given 551 relocation. */ 552 553 static asection * 554 mcore_elf_gc_mark_hook (asection *sec, 555 struct bfd_link_info *info, 556 Elf_Internal_Rela *rel, 557 struct elf_link_hash_entry *h, 558 Elf_Internal_Sym *sym) 559 { 560 if (h != NULL) 561 switch (ELF32_R_TYPE (rel->r_info)) 562 { 563 case R_MCORE_GNU_VTINHERIT: 564 case R_MCORE_GNU_VTENTRY: 565 return NULL; 566 } 567 568 return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym); 569 } 570 571 /* Update the got entry reference counts for the section being removed. */ 572 573 static bfd_boolean 574 mcore_elf_gc_sweep_hook (bfd * abfd ATTRIBUTE_UNUSED, 575 struct bfd_link_info * info ATTRIBUTE_UNUSED, 576 asection * sec ATTRIBUTE_UNUSED, 577 const Elf_Internal_Rela * relocs ATTRIBUTE_UNUSED) 578 { 579 return TRUE; 580 } 581 582 /* Look through the relocs for a section during the first phase. 583 Since we don't do .gots or .plts, we just need to consider the 584 virtual table relocs for gc. */ 585 586 static bfd_boolean 587 mcore_elf_check_relocs (bfd * abfd, 588 struct bfd_link_info * info, 589 asection * sec, 590 const Elf_Internal_Rela * relocs) 591 { 592 Elf_Internal_Shdr * symtab_hdr; 593 struct elf_link_hash_entry ** sym_hashes; 594 const Elf_Internal_Rela * rel; 595 const Elf_Internal_Rela * rel_end; 596 597 if (info->relocatable) 598 return TRUE; 599 600 symtab_hdr = & elf_tdata (abfd)->symtab_hdr; 601 sym_hashes = elf_sym_hashes (abfd); 602 603 rel_end = relocs + sec->reloc_count; 604 605 for (rel = relocs; rel < rel_end; rel++) 606 { 607 struct elf_link_hash_entry * h; 608 unsigned long r_symndx; 609 610 r_symndx = ELF32_R_SYM (rel->r_info); 611 612 if (r_symndx < symtab_hdr->sh_info) 613 h = NULL; 614 else 615 { 616 h = sym_hashes [r_symndx - symtab_hdr->sh_info]; 617 while (h->root.type == bfd_link_hash_indirect 618 || h->root.type == bfd_link_hash_warning) 619 h = (struct elf_link_hash_entry *) h->root.u.i.link; 620 621 /* PR15323, ref flags aren't set for references in the same 622 object. */ 623 h->root.non_ir_ref = 1; 624 } 625 626 switch (ELF32_R_TYPE (rel->r_info)) 627 { 628 /* This relocation describes the C++ object vtable hierarchy. 629 Reconstruct it for later use during GC. */ 630 case R_MCORE_GNU_VTINHERIT: 631 if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) 632 return FALSE; 633 break; 634 635 /* This relocation describes which C++ vtable entries are actually 636 used. Record for later use during GC. */ 637 case R_MCORE_GNU_VTENTRY: 638 BFD_ASSERT (h != NULL); 639 if (h != NULL 640 && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend)) 641 return FALSE; 642 break; 643 } 644 } 645 646 return TRUE; 647 } 648 649 static const struct bfd_elf_special_section mcore_elf_special_sections[]= 650 { 651 { STRING_COMMA_LEN (".ctors"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, 652 { STRING_COMMA_LEN (".dtors"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, 653 { NULL, 0, 0, 0, 0 } 654 }; 655 656 #define TARGET_BIG_SYM mcore_elf32_be_vec 657 #define TARGET_BIG_NAME "elf32-mcore-big" 658 #define TARGET_LITTLE_SYM mcore_elf32_le_vec 659 #define TARGET_LITTLE_NAME "elf32-mcore-little" 660 661 #define ELF_ARCH bfd_arch_mcore 662 #define ELF_MACHINE_CODE EM_MCORE 663 #define ELF_MAXPAGESIZE 0x1000 /* 4k, if we ever have 'em */ 664 #define elf_info_to_howto mcore_elf_info_to_howto 665 #define elf_info_to_howto_rel NULL 666 667 #define bfd_elf32_bfd_merge_private_bfd_data mcore_elf_merge_private_bfd_data 668 #define bfd_elf32_bfd_set_private_flags mcore_elf_set_private_flags 669 #define bfd_elf32_bfd_reloc_type_lookup mcore_elf_reloc_type_lookup 670 #define bfd_elf32_bfd_reloc_name_lookup mcore_elf_reloc_name_lookup 671 #define elf_backend_relocate_section mcore_elf_relocate_section 672 #define elf_backend_gc_mark_hook mcore_elf_gc_mark_hook 673 #define elf_backend_gc_sweep_hook mcore_elf_gc_sweep_hook 674 #define elf_backend_check_relocs mcore_elf_check_relocs 675 #define elf_backend_special_sections mcore_elf_special_sections 676 677 #define elf_backend_can_gc_sections 1 678 #define elf_backend_rela_normal 1 679 680 #include "elf32-target.h" 681