00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "bfd.h"
00026 #include "sysdep.h"
00027 #include "libbfd.h"
00028 #include "elf-bfd.h"
00029 #include "elf/mn10300.h"
00030
00031 static bfd_reloc_status_type mn10300_elf_final_link_relocate
00032 PARAMS ((reloc_howto_type *, bfd *, bfd *, asection *, bfd_byte *,
00033 bfd_vma, bfd_vma, bfd_vma,
00034 struct elf_link_hash_entry *, unsigned long, struct bfd_link_info *,
00035 asection *, int));
00036 static bfd_boolean mn10300_elf_relocate_section
00037 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
00038 Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
00039 static bfd_boolean mn10300_elf_relax_section
00040 PARAMS ((bfd *, asection *, struct bfd_link_info *, bfd_boolean *));
00041 static bfd_byte * mn10300_elf_get_relocated_section_contents
00042 PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
00043 bfd_byte *, bfd_boolean, asymbol **));
00044 static unsigned long elf_mn10300_mach
00045 PARAMS ((flagword));
00046 void _bfd_mn10300_elf_final_write_processing
00047 PARAMS ((bfd *, bfd_boolean));
00048 bfd_boolean _bfd_mn10300_elf_object_p
00049 PARAMS ((bfd *));
00050 bfd_boolean _bfd_mn10300_elf_merge_private_bfd_data
00051 PARAMS ((bfd *,bfd *));
00052
00053
00054
00055
00056
00057
00058
00059 struct elf32_mn10300_link_hash_entry {
00060
00061 struct elf_link_hash_entry root;
00062
00063
00064
00065 unsigned int direct_calls;
00066
00067
00068
00069
00070
00071
00072 unsigned char stack_size;
00073
00074
00075
00076
00077 unsigned char movm_args;
00078
00079
00080
00081
00082 unsigned char movm_stack_size;
00083
00084
00085
00086 #define MN10300_CONVERT_CALL_TO_CALLS 0x1
00087
00088
00089
00090 #define MN10300_DELETED_PROLOGUE_BYTES 0x2
00091 unsigned char flags;
00092 };
00093
00094
00095
00096
00097 struct elf32_mn10300_link_hash_table {
00098
00099 struct elf_link_hash_table root;
00100
00101
00102
00103
00104 struct elf32_mn10300_link_hash_table *static_hash_table;
00105
00106
00107 #define MN10300_HASH_ENTRIES_INITIALIZED 0x1
00108 char flags;
00109 };
00110
00111
00112
00113
00114
00115 #define elf32_mn10300_hash_table(p) \
00116 ((struct elf32_mn10300_link_hash_table *) ((p)->hash))
00117
00118 #define elf32_mn10300_link_hash_traverse(table, func, info) \
00119 (elf_link_hash_traverse \
00120 (&(table)->root, \
00121 (bfd_boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \
00122 (info)))
00123
00124 static struct bfd_hash_entry *elf32_mn10300_link_hash_newfunc
00125 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
00126 static struct bfd_link_hash_table *elf32_mn10300_link_hash_table_create
00127 PARAMS ((bfd *));
00128 static void elf32_mn10300_link_hash_table_free
00129 PARAMS ((struct bfd_link_hash_table *));
00130
00131 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
00132 PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
00133 static void mn10300_info_to_howto
00134 PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
00135 static bfd_boolean mn10300_elf_check_relocs
00136 PARAMS ((bfd *, struct bfd_link_info *, asection *,
00137 const Elf_Internal_Rela *));
00138 static asection *mn10300_elf_gc_mark_hook
00139 PARAMS ((asection *, struct bfd_link_info *info, Elf_Internal_Rela *,
00140 struct elf_link_hash_entry *, Elf_Internal_Sym *));
00141 static bfd_boolean mn10300_elf_relax_delete_bytes
00142 PARAMS ((bfd *, asection *, bfd_vma, int));
00143 static bfd_boolean mn10300_elf_symbol_address_p
00144 PARAMS ((bfd *, asection *, Elf_Internal_Sym *, bfd_vma));
00145 static bfd_boolean elf32_mn10300_finish_hash_table_entry
00146 PARAMS ((struct bfd_hash_entry *, PTR));
00147 static void compute_function_info
00148 PARAMS ((bfd *, struct elf32_mn10300_link_hash_entry *,
00149 bfd_vma, unsigned char *));
00150
00151 static bfd_boolean _bfd_mn10300_elf_create_got_section
00152 PARAMS ((bfd *, struct bfd_link_info *));
00153 static bfd_boolean _bfd_mn10300_elf_create_dynamic_sections
00154 PARAMS ((bfd *, struct bfd_link_info *));
00155 static bfd_boolean _bfd_mn10300_elf_adjust_dynamic_symbol
00156 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
00157 static bfd_boolean _bfd_mn10300_elf_size_dynamic_sections
00158 PARAMS ((bfd *, struct bfd_link_info *));
00159 static bfd_boolean _bfd_mn10300_elf_finish_dynamic_symbol
00160 PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
00161 Elf_Internal_Sym *));
00162 static bfd_boolean _bfd_mn10300_elf_finish_dynamic_sections
00163 PARAMS ((bfd *, struct bfd_link_info *));
00164
00165 static reloc_howto_type elf_mn10300_howto_table[] = {
00166
00167 HOWTO (R_MN10300_NONE,
00168 0,
00169 2,
00170 16,
00171 FALSE,
00172 0,
00173 complain_overflow_bitfield,
00174 bfd_elf_generic_reloc,
00175 "R_MN10300_NONE",
00176 FALSE,
00177 0,
00178 0,
00179 FALSE),
00180
00181 HOWTO (R_MN10300_32,
00182 0,
00183 2,
00184 32,
00185 FALSE,
00186 0,
00187 complain_overflow_bitfield,
00188 bfd_elf_generic_reloc,
00189 "R_MN10300_32",
00190 FALSE,
00191 0xffffffff,
00192 0xffffffff,
00193 FALSE),
00194
00195 HOWTO (R_MN10300_16,
00196 0,
00197 1,
00198 16,
00199 FALSE,
00200 0,
00201 complain_overflow_bitfield,
00202 bfd_elf_generic_reloc,
00203 "R_MN10300_16",
00204 FALSE,
00205 0xffff,
00206 0xffff,
00207 FALSE),
00208
00209 HOWTO (R_MN10300_8,
00210 0,
00211 0,
00212 8,
00213 FALSE,
00214 0,
00215 complain_overflow_bitfield,
00216 bfd_elf_generic_reloc,
00217 "R_MN10300_8",
00218 FALSE,
00219 0xff,
00220 0xff,
00221 FALSE),
00222
00223 HOWTO (R_MN10300_PCREL32,
00224 0,
00225 2,
00226 32,
00227 TRUE,
00228 0,
00229 complain_overflow_bitfield,
00230 bfd_elf_generic_reloc,
00231 "R_MN10300_PCREL32",
00232 FALSE,
00233 0xffffffff,
00234 0xffffffff,
00235 TRUE),
00236
00237 HOWTO (R_MN10300_PCREL16,
00238 0,
00239 1,
00240 16,
00241 TRUE,
00242 0,
00243 complain_overflow_bitfield,
00244 bfd_elf_generic_reloc,
00245 "R_MN10300_PCREL16",
00246 FALSE,
00247 0xffff,
00248 0xffff,
00249 TRUE),
00250
00251 HOWTO (R_MN10300_PCREL8,
00252 0,
00253 0,
00254 8,
00255 TRUE,
00256 0,
00257 complain_overflow_bitfield,
00258 bfd_elf_generic_reloc,
00259 "R_MN10300_PCREL8",
00260 FALSE,
00261 0xff,
00262 0xff,
00263 TRUE),
00264
00265
00266 HOWTO (R_MN10300_GNU_VTINHERIT,
00267 0,
00268 0,
00269 0,
00270 FALSE,
00271 0,
00272 complain_overflow_dont,
00273 NULL,
00274 "R_MN10300_GNU_VTINHERIT",
00275 FALSE,
00276 0,
00277 0,
00278 FALSE),
00279
00280
00281 HOWTO (R_MN10300_GNU_VTENTRY,
00282 0,
00283 0,
00284 0,
00285 FALSE,
00286 0,
00287 complain_overflow_dont,
00288 NULL,
00289 "R_MN10300_GNU_VTENTRY",
00290 FALSE,
00291 0,
00292 0,
00293 FALSE),
00294
00295
00296 HOWTO (R_MN10300_24,
00297 0,
00298 2,
00299 24,
00300 FALSE,
00301 0,
00302 complain_overflow_bitfield,
00303 bfd_elf_generic_reloc,
00304 "R_MN10300_24",
00305 FALSE,
00306 0xffffff,
00307 0xffffff,
00308 FALSE),
00309 HOWTO (R_MN10300_GOTPC32,
00310 0,
00311 2,
00312 32,
00313 TRUE,
00314 0,
00315 complain_overflow_bitfield,
00316 bfd_elf_generic_reloc,
00317 "R_MN10300_GOTPC32",
00318 FALSE,
00319 0xffffffff,
00320 0xffffffff,
00321 TRUE),
00322
00323 HOWTO (R_MN10300_GOTPC16,
00324 0,
00325 1,
00326 16,
00327 TRUE,
00328 0,
00329 complain_overflow_bitfield,
00330 bfd_elf_generic_reloc,
00331 "R_MN10300_GOTPC16",
00332 FALSE,
00333 0xffff,
00334 0xffff,
00335 TRUE),
00336
00337 HOWTO (R_MN10300_GOTOFF32,
00338 0,
00339 2,
00340 32,
00341 FALSE,
00342 0,
00343 complain_overflow_bitfield,
00344 bfd_elf_generic_reloc,
00345 "R_MN10300_GOTOFF32",
00346 FALSE,
00347 0xffffffff,
00348 0xffffffff,
00349 FALSE),
00350
00351 HOWTO (R_MN10300_GOTOFF24,
00352 0,
00353 2,
00354 24,
00355 FALSE,
00356 0,
00357 complain_overflow_bitfield,
00358 bfd_elf_generic_reloc,
00359 "R_MN10300_GOTOFF24",
00360 FALSE,
00361 0xffffff,
00362 0xffffff,
00363 FALSE),
00364
00365 HOWTO (R_MN10300_GOTOFF16,
00366 0,
00367 1,
00368 16,
00369 FALSE,
00370 0,
00371 complain_overflow_bitfield,
00372 bfd_elf_generic_reloc,
00373 "R_MN10300_GOTOFF16",
00374 FALSE,
00375 0xffff,
00376 0xffff,
00377 FALSE),
00378
00379 HOWTO (R_MN10300_PLT32,
00380 0,
00381 2,
00382 32,
00383 TRUE,
00384 0,
00385 complain_overflow_bitfield,
00386 bfd_elf_generic_reloc,
00387 "R_MN10300_PLT32",
00388 FALSE,
00389 0xffffffff,
00390 0xffffffff,
00391 TRUE),
00392
00393 HOWTO (R_MN10300_PLT16,
00394 0,
00395 1,
00396 16,
00397 TRUE,
00398 0,
00399 complain_overflow_bitfield,
00400 bfd_elf_generic_reloc,
00401 "R_MN10300_PLT16",
00402 FALSE,
00403 0xffff,
00404 0xffff,
00405 TRUE),
00406
00407 HOWTO (R_MN10300_GOT32,
00408 0,
00409 2,
00410 32,
00411 FALSE,
00412 0,
00413 complain_overflow_bitfield,
00414 bfd_elf_generic_reloc,
00415 "R_MN10300_GOT32",
00416 FALSE,
00417 0xffffffff,
00418 0xffffffff,
00419 FALSE),
00420
00421 HOWTO (R_MN10300_GOT24,
00422 0,
00423 2,
00424 24,
00425 FALSE,
00426 0,
00427 complain_overflow_bitfield,
00428 bfd_elf_generic_reloc,
00429 "R_MN10300_GOT24",
00430 FALSE,
00431 0xffffffff,
00432 0xffffffff,
00433 FALSE),
00434
00435 HOWTO (R_MN10300_GOT16,
00436 0,
00437 1,
00438 16,
00439 FALSE,
00440 0,
00441 complain_overflow_bitfield,
00442 bfd_elf_generic_reloc,
00443 "R_MN10300_GOT16",
00444 FALSE,
00445 0xffffffff,
00446 0xffffffff,
00447 FALSE),
00448
00449 HOWTO (R_MN10300_COPY,
00450 0,
00451 2,
00452 32,
00453 FALSE,
00454 0,
00455 complain_overflow_bitfield,
00456 bfd_elf_generic_reloc,
00457 "R_MN10300_COPY",
00458 FALSE,
00459 0xffffffff,
00460 0xffffffff,
00461 FALSE),
00462
00463 HOWTO (R_MN10300_GLOB_DAT,
00464 0,
00465 2,
00466 32,
00467 FALSE,
00468 0,
00469 complain_overflow_bitfield,
00470 bfd_elf_generic_reloc,
00471 "R_MN10300_GLOB_DAT",
00472 FALSE,
00473 0xffffffff,
00474 0xffffffff,
00475 FALSE),
00476
00477 HOWTO (R_MN10300_JMP_SLOT,
00478 0,
00479 2,
00480 32,
00481 FALSE,
00482 0,
00483 complain_overflow_bitfield,
00484 bfd_elf_generic_reloc,
00485 "R_MN10300_JMP_SLOT",
00486 FALSE,
00487 0xffffffff,
00488 0xffffffff,
00489 FALSE),
00490
00491 HOWTO (R_MN10300_RELATIVE,
00492 0,
00493 2,
00494 32,
00495 FALSE,
00496 0,
00497 complain_overflow_bitfield,
00498 bfd_elf_generic_reloc,
00499 "R_MN10300_RELATIVE",
00500 FALSE,
00501 0xffffffff,
00502 0xffffffff,
00503 FALSE),
00504
00505 };
00506
00507 struct mn10300_reloc_map {
00508 bfd_reloc_code_real_type bfd_reloc_val;
00509 unsigned char elf_reloc_val;
00510 };
00511
00512 static const struct mn10300_reloc_map mn10300_reloc_map[] = {
00513 { BFD_RELOC_NONE, R_MN10300_NONE, },
00514 { BFD_RELOC_32, R_MN10300_32, },
00515 { BFD_RELOC_16, R_MN10300_16, },
00516 { BFD_RELOC_8, R_MN10300_8, },
00517 { BFD_RELOC_32_PCREL, R_MN10300_PCREL32, },
00518 { BFD_RELOC_16_PCREL, R_MN10300_PCREL16, },
00519 { BFD_RELOC_8_PCREL, R_MN10300_PCREL8, },
00520 { BFD_RELOC_24, R_MN10300_24, },
00521 { BFD_RELOC_VTABLE_INHERIT, R_MN10300_GNU_VTINHERIT },
00522 { BFD_RELOC_VTABLE_ENTRY, R_MN10300_GNU_VTENTRY },
00523 { BFD_RELOC_32_GOT_PCREL, R_MN10300_GOTPC32 },
00524 { BFD_RELOC_16_GOT_PCREL, R_MN10300_GOTPC16 },
00525 { BFD_RELOC_32_GOTOFF, R_MN10300_GOTOFF32 },
00526 { BFD_RELOC_MN10300_GOTOFF24, R_MN10300_GOTOFF24 },
00527 { BFD_RELOC_16_GOTOFF, R_MN10300_GOTOFF16 },
00528 { BFD_RELOC_32_PLT_PCREL, R_MN10300_PLT32 },
00529 { BFD_RELOC_16_PLT_PCREL, R_MN10300_PLT16 },
00530 { BFD_RELOC_MN10300_GOT32, R_MN10300_GOT32 },
00531 { BFD_RELOC_MN10300_GOT24, R_MN10300_GOT24 },
00532 { BFD_RELOC_MN10300_GOT16, R_MN10300_GOT16 },
00533 { BFD_RELOC_MN10300_COPY, R_MN10300_COPY },
00534 { BFD_RELOC_MN10300_GLOB_DAT, R_MN10300_GLOB_DAT },
00535 { BFD_RELOC_MN10300_JMP_SLOT, R_MN10300_JMP_SLOT },
00536 { BFD_RELOC_MN10300_RELATIVE, R_MN10300_RELATIVE },
00537 };
00538
00539
00540
00541 static bfd_boolean
00542 _bfd_mn10300_elf_create_got_section (abfd, info)
00543 bfd * abfd;
00544 struct bfd_link_info * info;
00545 {
00546 flagword flags;
00547 flagword pltflags;
00548 asection * s;
00549 struct bfd_link_hash_entry * bh;
00550 struct elf_link_hash_entry * h;
00551 const struct elf_backend_data * bed = get_elf_backend_data (abfd);
00552 int ptralign;
00553
00554
00555 if (bfd_get_section_by_name (abfd, ".got") != NULL)
00556 return TRUE;
00557
00558 switch (bed->s->arch_size)
00559 {
00560 case 32:
00561 ptralign = 2;
00562 break;
00563
00564 case 64:
00565 ptralign = 3;
00566 break;
00567
00568 default:
00569 bfd_set_error (bfd_error_bad_value);
00570 return FALSE;
00571 }
00572
00573 flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
00574 | SEC_LINKER_CREATED);
00575
00576 pltflags = flags;
00577 pltflags |= SEC_CODE;
00578 if (bed->plt_not_loaded)
00579 pltflags &= ~ (SEC_LOAD | SEC_HAS_CONTENTS);
00580 if (bed->plt_readonly)
00581 pltflags |= SEC_READONLY;
00582
00583 s = bfd_make_section (abfd, ".plt");
00584 if (s == NULL
00585 || ! bfd_set_section_flags (abfd, s, pltflags)
00586 || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
00587 return FALSE;
00588
00589 if (bed->want_plt_sym)
00590 {
00591
00592
00593 bh = NULL;
00594 if (! (_bfd_generic_link_add_one_symbol
00595 (info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s,
00596 (bfd_vma) 0, (const char *) NULL, FALSE,
00597 get_elf_backend_data (abfd)->collect, &bh)))
00598 return FALSE;
00599 h = (struct elf_link_hash_entry *) bh;
00600 h->def_regular = 1;
00601 h->type = STT_OBJECT;
00602
00603 if (info->shared
00604 && ! bfd_elf_link_record_dynamic_symbol (info, h))
00605 return FALSE;
00606 }
00607
00608 s = bfd_make_section (abfd, ".got");
00609 if (s == NULL
00610 || ! bfd_set_section_flags (abfd, s, flags)
00611 || ! bfd_set_section_alignment (abfd, s, ptralign))
00612 return FALSE;
00613
00614 if (bed->want_got_plt)
00615 {
00616 s = bfd_make_section (abfd, ".got.plt");
00617 if (s == NULL
00618 || ! bfd_set_section_flags (abfd, s, flags)
00619 || ! bfd_set_section_alignment (abfd, s, ptralign))
00620 return FALSE;
00621 }
00622
00623
00624
00625
00626
00627 bh = NULL;
00628 if (!(_bfd_generic_link_add_one_symbol
00629 (info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s,
00630 bed->got_symbol_offset, (const char *) NULL, FALSE,
00631 bed->collect, &bh)))
00632 return FALSE;
00633 h = (struct elf_link_hash_entry *) bh;
00634 h->def_regular = 1;
00635 h->type = STT_OBJECT;
00636
00637 if (info->shared
00638 && ! bfd_elf_link_record_dynamic_symbol (info, h))
00639 return FALSE;
00640
00641 elf_hash_table (info)->hgot = h;
00642
00643
00644 s->size += bed->got_header_size + bed->got_symbol_offset;
00645
00646 return TRUE;
00647 }
00648
00649 static reloc_howto_type *
00650 bfd_elf32_bfd_reloc_type_lookup (abfd, code)
00651 bfd *abfd ATTRIBUTE_UNUSED;
00652 bfd_reloc_code_real_type code;
00653 {
00654 unsigned int i;
00655
00656 for (i = 0;
00657 i < sizeof (mn10300_reloc_map) / sizeof (struct mn10300_reloc_map);
00658 i++)
00659 {
00660 if (mn10300_reloc_map[i].bfd_reloc_val == code)
00661 return &elf_mn10300_howto_table[mn10300_reloc_map[i].elf_reloc_val];
00662 }
00663
00664 return NULL;
00665 }
00666
00667
00668
00669 static void
00670 mn10300_info_to_howto (abfd, cache_ptr, dst)
00671 bfd *abfd ATTRIBUTE_UNUSED;
00672 arelent *cache_ptr;
00673 Elf_Internal_Rela *dst;
00674 {
00675 unsigned int r_type;
00676
00677 r_type = ELF32_R_TYPE (dst->r_info);
00678 BFD_ASSERT (r_type < (unsigned int) R_MN10300_MAX);
00679 cache_ptr->howto = &elf_mn10300_howto_table[r_type];
00680 }
00681
00682
00683
00684
00685
00686 static bfd_boolean
00687 mn10300_elf_check_relocs (abfd, info, sec, relocs)
00688 bfd *abfd;
00689 struct bfd_link_info *info;
00690 asection *sec;
00691 const Elf_Internal_Rela *relocs;
00692 {
00693 Elf_Internal_Shdr *symtab_hdr;
00694 struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
00695 const Elf_Internal_Rela *rel;
00696 const Elf_Internal_Rela *rel_end;
00697 bfd * dynobj;
00698 bfd_vma * local_got_offsets;
00699 asection * sgot;
00700 asection * srelgot;
00701 asection * sreloc;
00702
00703 sgot = NULL;
00704 srelgot = NULL;
00705 sreloc = NULL;
00706
00707 if (info->relocatable)
00708 return TRUE;
00709
00710 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
00711 sym_hashes = elf_sym_hashes (abfd);
00712 sym_hashes_end = sym_hashes + symtab_hdr->sh_size/sizeof (Elf32_External_Sym);
00713 if (!elf_bad_symtab (abfd))
00714 sym_hashes_end -= symtab_hdr->sh_info;
00715
00716 dynobj = elf_hash_table (info)->dynobj;
00717 local_got_offsets = elf_local_got_offsets (abfd);
00718 rel_end = relocs + sec->reloc_count;
00719 for (rel = relocs; rel < rel_end; rel++)
00720 {
00721 struct elf_link_hash_entry *h;
00722 unsigned long r_symndx;
00723
00724 r_symndx = ELF32_R_SYM (rel->r_info);
00725 if (r_symndx < symtab_hdr->sh_info)
00726 h = NULL;
00727 else
00728 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
00729
00730
00731 if (dynobj == NULL)
00732 {
00733 switch (ELF32_R_TYPE (rel->r_info))
00734 {
00735 case R_MN10300_GOT32:
00736 case R_MN10300_GOT24:
00737 case R_MN10300_GOT16:
00738 case R_MN10300_GOTOFF32:
00739 case R_MN10300_GOTOFF24:
00740 case R_MN10300_GOTOFF16:
00741 case R_MN10300_GOTPC32:
00742 case R_MN10300_GOTPC16:
00743 elf_hash_table (info)->dynobj = dynobj = abfd;
00744 if (! _bfd_mn10300_elf_create_got_section (dynobj, info))
00745 return FALSE;
00746 break;
00747
00748 default:
00749 break;
00750 }
00751 }
00752
00753 switch (ELF32_R_TYPE (rel->r_info))
00754 {
00755
00756
00757 case R_MN10300_GNU_VTINHERIT:
00758 if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
00759 return FALSE;
00760 break;
00761
00762
00763
00764 case R_MN10300_GNU_VTENTRY:
00765 if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
00766 return FALSE;
00767 break;
00768 case R_MN10300_GOT32:
00769 case R_MN10300_GOT24:
00770 case R_MN10300_GOT16:
00771
00772
00773 if (sgot == NULL)
00774 {
00775 sgot = bfd_get_section_by_name (dynobj, ".got");
00776 BFD_ASSERT (sgot != NULL);
00777 }
00778
00779 if (srelgot == NULL
00780 && (h != NULL || info->shared))
00781 {
00782 srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
00783 if (srelgot == NULL)
00784 {
00785 srelgot = bfd_make_section (dynobj, ".rela.got");
00786 if (srelgot == NULL
00787 || ! bfd_set_section_flags (dynobj, srelgot,
00788 (SEC_ALLOC
00789 | SEC_LOAD
00790 | SEC_HAS_CONTENTS
00791 | SEC_IN_MEMORY
00792 | SEC_LINKER_CREATED
00793 | SEC_READONLY))
00794 || ! bfd_set_section_alignment (dynobj, srelgot, 2))
00795 return FALSE;
00796 }
00797 }
00798
00799 if (h != NULL)
00800 {
00801 if (h->got.offset != (bfd_vma) -1)
00802
00803 break;
00804
00805 h->got.offset = sgot->size;
00806
00807
00808 if (h->dynindx == -1)
00809 {
00810 if (! bfd_elf_link_record_dynamic_symbol (info, h))
00811 return FALSE;
00812 }
00813
00814 srelgot->size += sizeof (Elf32_External_Rela);
00815 }
00816 else
00817 {
00818
00819
00820 if (local_got_offsets == NULL)
00821 {
00822 size_t size;
00823 unsigned int i;
00824
00825 size = symtab_hdr->sh_info * sizeof (bfd_vma);
00826 local_got_offsets = (bfd_vma *) bfd_alloc (abfd, size);
00827
00828 if (local_got_offsets == NULL)
00829 return FALSE;
00830 elf_local_got_offsets (abfd) = local_got_offsets;
00831
00832 for (i = 0; i < symtab_hdr->sh_info; i++)
00833 local_got_offsets[i] = (bfd_vma) -1;
00834 }
00835
00836 if (local_got_offsets[r_symndx] != (bfd_vma) -1)
00837
00838 break;
00839
00840 local_got_offsets[r_symndx] = sgot->size;
00841
00842 if (info->shared)
00843
00844
00845
00846 srelgot->size += sizeof (Elf32_External_Rela);
00847 }
00848
00849 sgot->size += 4;
00850
00851 break;
00852
00853 case R_MN10300_PLT32:
00854 case R_MN10300_PLT16:
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864 if (h == NULL)
00865 continue;
00866
00867 if (ELF_ST_VISIBILITY (h->other) == STV_INTERNAL
00868 || ELF_ST_VISIBILITY (h->other) == STV_HIDDEN)
00869 break;
00870
00871 h->needs_plt = 1;
00872
00873 break;
00874
00875 case R_MN10300_24:
00876 case R_MN10300_16:
00877 case R_MN10300_8:
00878 case R_MN10300_PCREL32:
00879 case R_MN10300_PCREL16:
00880 case R_MN10300_PCREL8:
00881 if (h != NULL)
00882 h->non_got_ref = 1;
00883 break;
00884
00885 case R_MN10300_32:
00886 if (h != NULL)
00887 h->non_got_ref = 1;
00888
00889
00890
00891 if (info->shared
00892 && (sec->flags & SEC_ALLOC) != 0)
00893 {
00894
00895
00896
00897 if (sreloc == NULL)
00898 {
00899 const char * name;
00900
00901 name = (bfd_elf_string_from_elf_section
00902 (abfd,
00903 elf_elfheader (abfd)->e_shstrndx,
00904 elf_section_data (sec)->rel_hdr.sh_name));
00905 if (name == NULL)
00906 return FALSE;
00907
00908 BFD_ASSERT (strncmp (name, ".rela", 5) == 0
00909 && strcmp (bfd_get_section_name (abfd, sec),
00910 name + 5) == 0);
00911
00912 sreloc = bfd_get_section_by_name (dynobj, name);
00913 if (sreloc == NULL)
00914 {
00915 flagword flags;
00916
00917 sreloc = bfd_make_section (dynobj, name);
00918 flags = (SEC_HAS_CONTENTS | SEC_READONLY
00919 | SEC_IN_MEMORY | SEC_LINKER_CREATED);
00920 if ((sec->flags & SEC_ALLOC) != 0)
00921 flags |= SEC_ALLOC | SEC_LOAD;
00922 if (sreloc == NULL
00923 || ! bfd_set_section_flags (dynobj, sreloc, flags)
00924 || ! bfd_set_section_alignment (dynobj, sreloc, 2))
00925 return FALSE;
00926 }
00927 }
00928
00929 sreloc->size += sizeof (Elf32_External_Rela);
00930 }
00931
00932 break;
00933 }
00934 }
00935
00936 return TRUE;
00937 }
00938
00939
00940
00941
00942 static asection *
00943 mn10300_elf_gc_mark_hook (sec, info, rel, h, sym)
00944 asection *sec;
00945 struct bfd_link_info *info ATTRIBUTE_UNUSED;
00946 Elf_Internal_Rela *rel;
00947 struct elf_link_hash_entry *h;
00948 Elf_Internal_Sym *sym;
00949 {
00950 if (h != NULL)
00951 {
00952 switch (ELF32_R_TYPE (rel->r_info))
00953 {
00954 case R_MN10300_GNU_VTINHERIT:
00955 case R_MN10300_GNU_VTENTRY:
00956 break;
00957
00958 default:
00959 switch (h->root.type)
00960 {
00961 case bfd_link_hash_defined:
00962 case bfd_link_hash_defweak:
00963 return h->root.u.def.section;
00964
00965 case bfd_link_hash_common:
00966 return h->root.u.c.p->section;
00967
00968 default:
00969 break;
00970 }
00971 }
00972 }
00973 else
00974 return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
00975
00976 return NULL;
00977 }
00978
00979
00980 static bfd_reloc_status_type
00981 mn10300_elf_final_link_relocate (howto, input_bfd, output_bfd,
00982 input_section, contents, offset, value,
00983 addend, h, symndx, info, sym_sec, is_local)
00984 reloc_howto_type *howto;
00985 bfd *input_bfd;
00986 bfd *output_bfd ATTRIBUTE_UNUSED;
00987 asection *input_section;
00988 bfd_byte *contents;
00989 bfd_vma offset;
00990 bfd_vma value;
00991 bfd_vma addend;
00992 struct elf_link_hash_entry * h;
00993 unsigned long symndx;
00994 struct bfd_link_info *info;
00995 asection *sym_sec ATTRIBUTE_UNUSED;
00996 int is_local ATTRIBUTE_UNUSED;
00997 {
00998 unsigned long r_type = howto->type;
00999 bfd_byte *hit_data = contents + offset;
01000 bfd * dynobj;
01001 bfd_vma * local_got_offsets;
01002 asection * sgot;
01003 asection * splt;
01004 asection * sreloc;
01005
01006 dynobj = elf_hash_table (info)->dynobj;
01007 local_got_offsets = elf_local_got_offsets (input_bfd);
01008
01009 sgot = NULL;
01010 splt = NULL;
01011 sreloc = NULL;
01012
01013 switch (r_type)
01014 {
01015 case R_MN10300_24:
01016 case R_MN10300_16:
01017 case R_MN10300_8:
01018 case R_MN10300_PCREL8:
01019 case R_MN10300_PCREL16:
01020 case R_MN10300_PCREL32:
01021 case R_MN10300_GOTOFF32:
01022 case R_MN10300_GOTOFF24:
01023 case R_MN10300_GOTOFF16:
01024 if (info->shared
01025 && (input_section->flags & SEC_ALLOC) != 0
01026 && h != NULL
01027 && ! SYMBOL_REFERENCES_LOCAL (info, h))
01028 return bfd_reloc_dangerous;
01029 }
01030
01031 switch (r_type)
01032 {
01033 case R_MN10300_NONE:
01034 return bfd_reloc_ok;
01035
01036 case R_MN10300_32:
01037 if (info->shared
01038 && (input_section->flags & SEC_ALLOC) != 0)
01039 {
01040 Elf_Internal_Rela outrel;
01041 bfd_boolean skip, relocate;
01042
01043
01044
01045
01046 if (sreloc == NULL)
01047 {
01048 const char * name;
01049
01050 name = (bfd_elf_string_from_elf_section
01051 (input_bfd,
01052 elf_elfheader (input_bfd)->e_shstrndx,
01053 elf_section_data (input_section)->rel_hdr.sh_name));
01054 if (name == NULL)
01055 return FALSE;
01056
01057 BFD_ASSERT (strncmp (name, ".rela", 5) == 0
01058 && strcmp (bfd_get_section_name (input_bfd,
01059 input_section),
01060 name + 5) == 0);
01061
01062 sreloc = bfd_get_section_by_name (dynobj, name);
01063 BFD_ASSERT (sreloc != NULL);
01064 }
01065
01066 skip = FALSE;
01067
01068 outrel.r_offset = _bfd_elf_section_offset (input_bfd, info,
01069 input_section, offset);
01070 if (outrel.r_offset == (bfd_vma) -1)
01071 skip = TRUE;
01072
01073 outrel.r_offset += (input_section->output_section->vma
01074 + input_section->output_offset);
01075
01076 if (skip)
01077 {
01078 memset (&outrel, 0, sizeof outrel);
01079 relocate = FALSE;
01080 }
01081 else
01082 {
01083
01084
01085 if (h == NULL
01086 || SYMBOL_REFERENCES_LOCAL (info, h))
01087 {
01088 relocate = TRUE;
01089 outrel.r_info = ELF32_R_INFO (0, R_MN10300_RELATIVE);
01090 outrel.r_addend = value + addend;
01091 }
01092 else
01093 {
01094 BFD_ASSERT (h->dynindx != -1);
01095 relocate = FALSE;
01096 outrel.r_info = ELF32_R_INFO (h->dynindx, R_MN10300_32);
01097 outrel.r_addend = value + addend;
01098 }
01099 }
01100
01101 bfd_elf32_swap_reloca_out (output_bfd, &outrel,
01102 (bfd_byte *) (((Elf32_External_Rela *) sreloc->contents)
01103 + sreloc->reloc_count));
01104 ++sreloc->reloc_count;
01105
01106
01107
01108
01109
01110 if (! relocate)
01111 return bfd_reloc_ok;
01112 }
01113 value += addend;
01114 bfd_put_32 (input_bfd, value, hit_data);
01115 return bfd_reloc_ok;
01116
01117 case R_MN10300_24:
01118 value += addend;
01119
01120 if ((long) value > 0x7fffff || (long) value < -0x800000)
01121 return bfd_reloc_overflow;
01122
01123 bfd_put_8 (input_bfd, value & 0xff, hit_data);
01124 bfd_put_8 (input_bfd, (value >> 8) & 0xff, hit_data + 1);
01125 bfd_put_8 (input_bfd, (value >> 16) & 0xff, hit_data + 2);
01126 return bfd_reloc_ok;
01127
01128 case R_MN10300_16:
01129 value += addend;
01130
01131 if ((long) value > 0x7fff || (long) value < -0x8000)
01132 return bfd_reloc_overflow;
01133
01134 bfd_put_16 (input_bfd, value, hit_data);
01135 return bfd_reloc_ok;
01136
01137 case R_MN10300_8:
01138 value += addend;
01139
01140 if ((long) value > 0x7f || (long) value < -0x80)
01141 return bfd_reloc_overflow;
01142
01143 bfd_put_8 (input_bfd, value, hit_data);
01144 return bfd_reloc_ok;
01145
01146 case R_MN10300_PCREL8:
01147 value -= (input_section->output_section->vma
01148 + input_section->output_offset);
01149 value -= offset;
01150 value += addend;
01151
01152 if ((long) value > 0xff || (long) value < -0x100)
01153 return bfd_reloc_overflow;
01154
01155 bfd_put_8 (input_bfd, value, hit_data);
01156 return bfd_reloc_ok;
01157
01158 case R_MN10300_PCREL16:
01159 value -= (input_section->output_section->vma
01160 + input_section->output_offset);
01161 value -= offset;
01162 value += addend;
01163
01164 if ((long) value > 0xffff || (long) value < -0x10000)
01165 return bfd_reloc_overflow;
01166
01167 bfd_put_16 (input_bfd, value, hit_data);
01168 return bfd_reloc_ok;
01169
01170 case R_MN10300_PCREL32:
01171 value -= (input_section->output_section->vma
01172 + input_section->output_offset);
01173 value -= offset;
01174 value += addend;
01175
01176 bfd_put_32 (input_bfd, value, hit_data);
01177 return bfd_reloc_ok;
01178
01179 case R_MN10300_GNU_VTINHERIT:
01180 case R_MN10300_GNU_VTENTRY:
01181 return bfd_reloc_ok;
01182
01183 case R_MN10300_GOTPC32:
01184
01185
01186 value = bfd_get_section_by_name (dynobj,
01187 ".got")->output_section->vma;
01188 value -= (input_section->output_section->vma
01189 + input_section->output_offset);
01190 value -= offset;
01191 value += addend;
01192
01193 bfd_put_32 (input_bfd, value, hit_data);
01194 return bfd_reloc_ok;
01195
01196 case R_MN10300_GOTPC16:
01197
01198
01199 value = bfd_get_section_by_name (dynobj,
01200 ".got")->output_section->vma;
01201 value -= (input_section->output_section->vma
01202 + input_section->output_offset);
01203 value -= offset;
01204 value += addend;
01205
01206 if ((long) value > 0xffff || (long) value < -0x10000)
01207 return bfd_reloc_overflow;
01208
01209 bfd_put_16 (input_bfd, value, hit_data);
01210 return bfd_reloc_ok;
01211
01212 case R_MN10300_GOTOFF32:
01213 value -= bfd_get_section_by_name (dynobj,
01214 ".got")->output_section->vma;
01215 value += addend;
01216
01217 bfd_put_32 (input_bfd, value, hit_data);
01218 return bfd_reloc_ok;
01219
01220 case R_MN10300_GOTOFF24:
01221 value -= bfd_get_section_by_name (dynobj,
01222 ".got")->output_section->vma;
01223 value += addend;
01224
01225 if ((long) value > 0x7fffff || (long) value < -0x800000)
01226 return bfd_reloc_overflow;
01227
01228 bfd_put_8 (input_bfd, value, hit_data);
01229 bfd_put_8 (input_bfd, (value >> 8) & 0xff, hit_data + 1);
01230 bfd_put_8 (input_bfd, (value >> 16) & 0xff, hit_data + 2);
01231 return bfd_reloc_ok;
01232
01233 case R_MN10300_GOTOFF16:
01234 value -= bfd_get_section_by_name (dynobj,
01235 ".got")->output_section->vma;
01236 value += addend;
01237
01238 if ((long) value > 0xffff || (long) value < -0x10000)
01239 return bfd_reloc_overflow;
01240
01241 bfd_put_16 (input_bfd, value, hit_data);
01242 return bfd_reloc_ok;
01243
01244 case R_MN10300_PLT32:
01245 if (h != NULL
01246 && ELF_ST_VISIBILITY (h->other) != STV_INTERNAL
01247 && ELF_ST_VISIBILITY (h->other) != STV_HIDDEN
01248 && h->plt.offset != (bfd_vma) -1)
01249 {
01250 asection * splt;
01251
01252 splt = bfd_get_section_by_name (dynobj, ".plt");
01253
01254 value = (splt->output_section->vma
01255 + splt->output_offset
01256 + h->plt.offset) - value;
01257 }
01258
01259 value -= (input_section->output_section->vma
01260 + input_section->output_offset);
01261 value -= offset;
01262 value += addend;
01263
01264 bfd_put_32 (input_bfd, value, hit_data);
01265 return bfd_reloc_ok;
01266
01267 case R_MN10300_PLT16:
01268 if (h != NULL
01269 && ELF_ST_VISIBILITY (h->other) != STV_INTERNAL
01270 && ELF_ST_VISIBILITY (h->other) != STV_HIDDEN
01271 && h->plt.offset != (bfd_vma) -1)
01272 {
01273 asection * splt;
01274
01275 splt = bfd_get_section_by_name (dynobj, ".plt");
01276
01277 value = (splt->output_section->vma
01278 + splt->output_offset
01279 + h->plt.offset) - value;
01280 }
01281
01282 value -= (input_section->output_section->vma
01283 + input_section->output_offset);
01284 value -= offset;
01285 value += addend;
01286
01287 if ((long) value > 0xffff || (long) value < -0x10000)
01288 return bfd_reloc_overflow;
01289
01290 bfd_put_16 (input_bfd, value, hit_data);
01291 return bfd_reloc_ok;
01292
01293 case R_MN10300_GOT32:
01294 case R_MN10300_GOT24:
01295 case R_MN10300_GOT16:
01296 {
01297 asection * sgot;
01298
01299 sgot = bfd_get_section_by_name (dynobj, ".got");
01300
01301 if (h != NULL)
01302 {
01303 bfd_vma off;
01304
01305 off = h->got.offset;
01306 BFD_ASSERT (off != (bfd_vma) -1);
01307
01308 if (! elf_hash_table (info)->dynamic_sections_created
01309 || SYMBOL_REFERENCES_LOCAL (info, h))
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319 bfd_put_32 (output_bfd, value,
01320 sgot->contents + off);
01321
01322 value = sgot->output_offset + off;
01323 }
01324 else
01325 {
01326 bfd_vma off;
01327
01328 off = elf_local_got_offsets (input_bfd)[symndx];
01329
01330 bfd_put_32 (output_bfd, value, sgot->contents + off);
01331
01332 if (info->shared)
01333 {
01334 asection * srelgot;
01335 Elf_Internal_Rela outrel;
01336
01337 srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
01338 BFD_ASSERT (srelgot != NULL);
01339
01340 outrel.r_offset = (sgot->output_section->vma
01341 + sgot->output_offset
01342 + off);
01343 outrel.r_info = ELF32_R_INFO (0, R_MN10300_RELATIVE);
01344 outrel.r_addend = value;
01345 bfd_elf32_swap_reloca_out (output_bfd, &outrel,
01346 (bfd_byte *) (((Elf32_External_Rela *)
01347 srelgot->contents)
01348 + srelgot->reloc_count));
01349 ++ srelgot->reloc_count;
01350 }
01351
01352 value = sgot->output_offset + off;
01353 }
01354 }
01355
01356 value += addend;
01357
01358 if (r_type == R_MN10300_GOT32)
01359 {
01360 bfd_put_32 (input_bfd, value, hit_data);
01361 return bfd_reloc_ok;
01362 }
01363 else if (r_type == R_MN10300_GOT24)
01364 {
01365 if ((long) value > 0x7fffff || (long) value < -0x800000)
01366 return bfd_reloc_overflow;
01367
01368 bfd_put_8 (input_bfd, value & 0xff, hit_data);
01369 bfd_put_8 (input_bfd, (value >> 8) & 0xff, hit_data + 1);
01370 bfd_put_8 (input_bfd, (value >> 16) & 0xff, hit_data + 2);
01371 return bfd_reloc_ok;
01372 }
01373 else if (r_type == R_MN10300_GOT16)
01374 {
01375 if ((long) value > 0xffff || (long) value < -0x10000)
01376 return bfd_reloc_overflow;
01377
01378 bfd_put_16 (input_bfd, value, hit_data);
01379 return bfd_reloc_ok;
01380 }
01381
01382
01383 default:
01384 return bfd_reloc_notsupported;
01385 }
01386 }
01387
01388
01389 static bfd_boolean
01390 mn10300_elf_relocate_section (output_bfd, info, input_bfd, input_section,
01391 contents, relocs, local_syms, local_sections)
01392 bfd *output_bfd;
01393 struct bfd_link_info *info;
01394 bfd *input_bfd;
01395 asection *input_section;
01396 bfd_byte *contents;
01397 Elf_Internal_Rela *relocs;
01398 Elf_Internal_Sym *local_syms;
01399 asection **local_sections;
01400 {
01401 Elf_Internal_Shdr *symtab_hdr;
01402 struct elf_link_hash_entry **sym_hashes;
01403 Elf_Internal_Rela *rel, *relend;
01404
01405 if (info->relocatable)
01406 return TRUE;
01407
01408 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
01409 sym_hashes = elf_sym_hashes (input_bfd);
01410
01411 rel = relocs;
01412 relend = relocs + input_section->reloc_count;
01413 for (; rel < relend; rel++)
01414 {
01415 int r_type;
01416 reloc_howto_type *howto;
01417 unsigned long r_symndx;
01418 Elf_Internal_Sym *sym;
01419 asection *sec;
01420 struct elf32_mn10300_link_hash_entry *h;
01421 bfd_vma relocation;
01422 bfd_reloc_status_type r;
01423
01424 r_symndx = ELF32_R_SYM (rel->r_info);
01425 r_type = ELF32_R_TYPE (rel->r_info);
01426 howto = elf_mn10300_howto_table + r_type;
01427
01428
01429 if (r_type == R_MN10300_GNU_VTINHERIT
01430 || r_type == R_MN10300_GNU_VTENTRY)
01431 continue;
01432
01433 h = NULL;
01434 sym = NULL;
01435 sec = NULL;
01436 if (r_symndx < symtab_hdr->sh_info)
01437 {
01438 sym = local_syms + r_symndx;
01439 sec = local_sections[r_symndx];
01440 relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
01441 }
01442 else
01443 {
01444 bfd_boolean unresolved_reloc;
01445 bfd_boolean warned;
01446 struct elf_link_hash_entry *hh;
01447
01448 RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
01449 r_symndx, symtab_hdr, sym_hashes,
01450 hh, sec, relocation,
01451 unresolved_reloc, warned);
01452
01453 h = (struct elf32_mn10300_link_hash_entry *) hh;
01454
01455 if ((h->root.root.type == bfd_link_hash_defined
01456 || h->root.root.type == bfd_link_hash_defweak)
01457 && ( r_type == R_MN10300_GOTPC32
01458 || r_type == R_MN10300_GOTPC16
01459 || (( r_type == R_MN10300_PLT32
01460 || r_type == R_MN10300_PLT16)
01461 && ELF_ST_VISIBILITY (h->root.other) != STV_INTERNAL
01462 && ELF_ST_VISIBILITY (h->root.other) != STV_HIDDEN
01463 && h->root.plt.offset != (bfd_vma) -1)
01464 || (( r_type == R_MN10300_GOT32
01465 || r_type == R_MN10300_GOT24
01466 || r_type == R_MN10300_GOT16)
01467 && elf_hash_table (info)->dynamic_sections_created
01468 && !SYMBOL_REFERENCES_LOCAL (info, hh))
01469 || (r_type == R_MN10300_32
01470 && !SYMBOL_REFERENCES_LOCAL (info, hh)
01471 && ((input_section->flags & SEC_ALLOC) != 0
01472
01473
01474
01475
01476 || ((input_section->flags & SEC_DEBUGGING) != 0
01477 && h->root.def_dynamic)))))
01478
01479
01480
01481 relocation = 0;
01482
01483 else if (unresolved_reloc)
01484 (*_bfd_error_handler)
01485 (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
01486 bfd_get_filename (input_bfd), h->root.root.root.string,
01487 bfd_get_section_name (input_bfd, input_section));
01488 }
01489
01490 r = mn10300_elf_final_link_relocate (howto, input_bfd, output_bfd,
01491 input_section,
01492 contents, rel->r_offset,
01493 relocation, rel->r_addend,
01494 (struct elf_link_hash_entry *)h,
01495 r_symndx,
01496 info, sec, h == NULL);
01497
01498 if (r != bfd_reloc_ok)
01499 {
01500 const char *name;
01501 const char *msg = (const char *) 0;
01502
01503 if (h != NULL)
01504 name = h->root.root.root.string;
01505 else
01506 {
01507 name = (bfd_elf_string_from_elf_section
01508 (input_bfd, symtab_hdr->sh_link, sym->st_name));
01509 if (name == NULL || *name == '\0')
01510 name = bfd_section_name (input_bfd, sec);
01511 }
01512
01513 switch (r)
01514 {
01515 case bfd_reloc_overflow:
01516 if (! ((*info->callbacks->reloc_overflow)
01517 (info, (h ? &h->root.root : NULL), name,
01518 howto->name, (bfd_vma) 0, input_bfd,
01519 input_section, rel->r_offset)))
01520 return FALSE;
01521 break;
01522
01523 case bfd_reloc_undefined:
01524 if (! ((*info->callbacks->undefined_symbol)
01525 (info, name, input_bfd, input_section,
01526 rel->r_offset, TRUE)))
01527 return FALSE;
01528 break;
01529
01530 case bfd_reloc_outofrange:
01531 msg = _("internal error: out of range error");
01532 goto common_error;
01533
01534 case bfd_reloc_notsupported:
01535 msg = _("internal error: unsupported relocation error");
01536 goto common_error;
01537
01538 case bfd_reloc_dangerous:
01539 msg = _("internal error: dangerous error");
01540 goto common_error;
01541
01542 default:
01543 msg = _("internal error: unknown error");
01544
01545
01546 common_error:
01547 if (!((*info->callbacks->warning)
01548 (info, msg, name, input_bfd, input_section,
01549 rel->r_offset)))
01550 return FALSE;
01551 break;
01552 }
01553 }
01554 }
01555
01556 return TRUE;
01557 }
01558
01559
01560 static bfd_boolean
01561 elf32_mn10300_finish_hash_table_entry (gen_entry, in_args)
01562 struct bfd_hash_entry *gen_entry;
01563 PTR in_args;
01564 {
01565 struct elf32_mn10300_link_hash_entry *entry;
01566 struct bfd_link_info *link_info = (struct bfd_link_info *)in_args;
01567 unsigned int byte_count = 0;
01568
01569 entry = (struct elf32_mn10300_link_hash_entry *) gen_entry;
01570
01571 if (entry->root.root.type == bfd_link_hash_warning)
01572 entry = (struct elf32_mn10300_link_hash_entry *) entry->root.root.u.i.link;
01573
01574
01575
01576 if (entry->flags == MN10300_CONVERT_CALL_TO_CALLS)
01577 return TRUE;
01578
01579
01580
01581
01582
01583
01584
01585 if (entry->direct_calls == 0
01586 || (entry->stack_size == 0 && entry->movm_args == 0)
01587 || (elf_hash_table (link_info)->dynamic_sections_created
01588 && ELF_ST_VISIBILITY (entry->root.other) != STV_INTERNAL
01589 && ELF_ST_VISIBILITY (entry->root.other) != STV_HIDDEN))
01590 {
01591
01592
01593 entry->flags |= MN10300_CONVERT_CALL_TO_CALLS;
01594 return TRUE;
01595 }
01596
01597
01598
01599
01600
01601
01602 if (entry->movm_args)
01603 byte_count += 2;
01604
01605
01606 if (entry->stack_size > 0)
01607 {
01608 if (entry->stack_size <= 128)
01609 byte_count += 3;
01610 else
01611 byte_count += 4;
01612 }
01613
01614
01615
01616 if (byte_count < entry->direct_calls)
01617 entry->flags |= MN10300_CONVERT_CALL_TO_CALLS;
01618
01619
01620 return TRUE;
01621 }
01622
01623
01624
01625
01626
01627
01628
01629
01630
01631
01632
01633
01634
01635
01636
01637
01638
01639
01640
01641
01642
01643
01644
01645
01646
01647
01648
01649
01650
01651
01652
01653
01654
01655
01656
01657
01658
01659
01660
01661
01662 static bfd_boolean
01663 mn10300_elf_relax_section (abfd, sec, link_info, again)
01664 bfd *abfd;
01665 asection *sec;
01666 struct bfd_link_info *link_info;
01667 bfd_boolean *again;
01668 {
01669 Elf_Internal_Shdr *symtab_hdr;
01670 Elf_Internal_Rela *internal_relocs = NULL;
01671 Elf_Internal_Rela *irel, *irelend;
01672 bfd_byte *contents = NULL;
01673 Elf_Internal_Sym *isymbuf = NULL;
01674 struct elf32_mn10300_link_hash_table *hash_table;
01675 asection *section = sec;
01676
01677
01678 *again = FALSE;
01679
01680
01681 hash_table = elf32_mn10300_hash_table (link_info);
01682
01683
01684 if ((hash_table->flags & MN10300_HASH_ENTRIES_INITIALIZED) == 0)
01685 {
01686 bfd *input_bfd;
01687
01688
01689 for (input_bfd = link_info->input_bfds;
01690 input_bfd != NULL;
01691 input_bfd = input_bfd->link_next)
01692 {
01693
01694 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
01695 if (symtab_hdr->sh_info != 0)
01696 {
01697 isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
01698 if (isymbuf == NULL)
01699 isymbuf = bfd_elf_get_elf_syms (input_bfd, symtab_hdr,
01700 symtab_hdr->sh_info, 0,
01701 NULL, NULL, NULL);
01702 if (isymbuf == NULL)
01703 goto error_return;
01704 }
01705
01706
01707 for (section = input_bfd->sections;
01708 section != NULL;
01709 section = section->next)
01710 {
01711 struct elf32_mn10300_link_hash_entry *hash;
01712 Elf_Internal_Sym *sym;
01713 asection *sym_sec = NULL;
01714 const char *sym_name;
01715 char *new_name;
01716
01717
01718 if (! (((section->flags & SEC_RELOC) != 0
01719 && section->reloc_count != 0)
01720 || (section->flags & SEC_CODE) != 0))
01721 continue;
01722
01723
01724 if (elf_section_data (section)->this_hdr.contents != NULL)
01725 contents = elf_section_data (section)->this_hdr.contents;
01726 else if (section->size != 0)
01727 {
01728
01729 if (!bfd_malloc_and_get_section (input_bfd, section,
01730 &contents))
01731 goto error_return;
01732 }
01733 else
01734 contents = NULL;
01735
01736
01737 if ((section->flags & SEC_RELOC) != 0
01738 && section->reloc_count != 0)
01739 {
01740
01741
01742 internal_relocs = (_bfd_elf_link_read_relocs
01743 (input_bfd, section, (PTR) NULL,
01744 (Elf_Internal_Rela *) NULL,
01745 link_info->keep_memory));
01746 if (internal_relocs == NULL)
01747 goto error_return;
01748
01749
01750 irel = internal_relocs;
01751 irelend = irel + section->reloc_count;
01752 for (; irel < irelend; irel++)
01753 {
01754 long r_type;
01755 unsigned long r_index;
01756 unsigned char code;
01757
01758 r_type = ELF32_R_TYPE (irel->r_info);
01759 r_index = ELF32_R_SYM (irel->r_info);
01760
01761 if (r_type < 0 || r_type >= (int) R_MN10300_MAX)
01762 goto error_return;
01763
01764
01765
01766 hash = NULL;
01767 sym = NULL;
01768 sym_sec = NULL;
01769
01770 if (r_index < symtab_hdr->sh_info)
01771 {
01772
01773 Elf_Internal_Sym *isym;
01774 struct elf_link_hash_table *elftab;
01775 bfd_size_type amt;
01776
01777 isym = isymbuf + r_index;
01778 if (isym->st_shndx == SHN_UNDEF)
01779 sym_sec = bfd_und_section_ptr;
01780 else if (isym->st_shndx == SHN_ABS)
01781 sym_sec = bfd_abs_section_ptr;
01782 else if (isym->st_shndx == SHN_COMMON)
01783 sym_sec = bfd_com_section_ptr;
01784 else
01785 sym_sec
01786 = bfd_section_from_elf_index (input_bfd,
01787 isym->st_shndx);
01788
01789 sym_name
01790 = bfd_elf_string_from_elf_section (input_bfd,
01791 (symtab_hdr
01792 ->sh_link),
01793 isym->st_name);
01794
01795
01796
01797 if (ELF_ST_TYPE (isym->st_info) != STT_FUNC)
01798 continue;
01799
01800
01801
01802 amt = strlen (sym_name) + 10;
01803 new_name = bfd_malloc (amt);
01804 if (new_name == 0)
01805 goto error_return;
01806
01807 sprintf (new_name, "%s_%08x", sym_name, sym_sec->id);
01808 sym_name = new_name;
01809
01810 elftab = &hash_table->static_hash_table->root;
01811 hash = ((struct elf32_mn10300_link_hash_entry *)
01812 elf_link_hash_lookup (elftab, sym_name,
01813 TRUE, TRUE, FALSE));
01814 free (new_name);
01815 }
01816 else
01817 {
01818 r_index -= symtab_hdr->sh_info;
01819 hash = (struct elf32_mn10300_link_hash_entry *)
01820 elf_sym_hashes (input_bfd)[r_index];
01821 }
01822
01823
01824
01825
01826 code = bfd_get_8 (input_bfd,
01827 contents + irel->r_offset - 1);
01828 if (code != 0xdd && code != 0xcd)
01829 hash->flags |= MN10300_CONVERT_CALL_TO_CALLS;
01830
01831
01832
01833
01834 if (r_type == R_MN10300_PCREL32
01835 || r_type == R_MN10300_PLT32
01836 || r_type == R_MN10300_PLT16
01837 || r_type == R_MN10300_PCREL16)
01838 hash->direct_calls++;
01839 else
01840 hash->flags |= MN10300_CONVERT_CALL_TO_CALLS;
01841 }
01842 }
01843
01844
01845
01846
01847 if ((section->flags & SEC_CODE) != 0)
01848 {
01849 Elf_Internal_Sym *isym, *isymend;
01850 unsigned int sec_shndx;
01851 struct elf_link_hash_entry **hashes;
01852 struct elf_link_hash_entry **end_hashes;
01853 unsigned int symcount;
01854
01855 sec_shndx = _bfd_elf_section_from_bfd_section (input_bfd,
01856 section);
01857
01858 symcount = (symtab_hdr->sh_size / sizeof (Elf32_External_Sym)
01859 - symtab_hdr->sh_info);
01860 hashes = elf_sym_hashes (input_bfd);
01861 end_hashes = hashes + symcount;
01862
01863
01864
01865 isymend = isymbuf + symtab_hdr->sh_info;
01866 for (isym = isymbuf; isym < isymend; isym++)
01867 {
01868 if (isym->st_shndx == sec_shndx
01869 && ELF_ST_TYPE (isym->st_info) == STT_FUNC)
01870 {
01871 struct elf_link_hash_table *elftab;
01872 bfd_size_type amt;
01873 struct elf_link_hash_entry **lhashes = hashes;
01874
01875
01876
01877 for (; lhashes < end_hashes; lhashes++)
01878 {
01879 hash = (struct elf32_mn10300_link_hash_entry *) *lhashes;
01880 if ((hash->root.root.type == bfd_link_hash_defined
01881 || hash->root.root.type == bfd_link_hash_defweak)
01882 && hash->root.root.u.def.section == section
01883 && hash->root.type == STT_FUNC
01884 && hash->root.root.u.def.value == isym->st_value)
01885 break;
01886 }
01887 if (lhashes != end_hashes)
01888 continue;
01889
01890 if (isym->st_shndx == SHN_UNDEF)
01891 sym_sec = bfd_und_section_ptr;
01892 else if (isym->st_shndx == SHN_ABS)
01893 sym_sec = bfd_abs_section_ptr;
01894 else if (isym->st_shndx == SHN_COMMON)
01895 sym_sec = bfd_com_section_ptr;
01896 else
01897 sym_sec
01898 = bfd_section_from_elf_index (input_bfd,
01899 isym->st_shndx);
01900
01901 sym_name = (bfd_elf_string_from_elf_section
01902 (input_bfd, symtab_hdr->sh_link,
01903 isym->st_name));
01904
01905
01906
01907 amt = strlen (sym_name) + 10;
01908 new_name = bfd_malloc (amt);
01909 if (new_name == 0)
01910 goto error_return;
01911
01912 sprintf (new_name, "%s_%08x", sym_name, sym_sec->id);
01913 sym_name = new_name;
01914
01915 elftab = &hash_table->static_hash_table->root;
01916 hash = ((struct elf32_mn10300_link_hash_entry *)
01917 elf_link_hash_lookup (elftab, sym_name,
01918 TRUE, TRUE, FALSE));
01919 free (new_name);
01920 compute_function_info (input_bfd, hash,
01921 isym->st_value, contents);
01922 }
01923 }
01924
01925 for (; hashes < end_hashes; hashes++)
01926 {
01927 hash = (struct elf32_mn10300_link_hash_entry *) *hashes;
01928 if ((hash->root.root.type == bfd_link_hash_defined
01929 || hash->root.root.type == bfd_link_hash_defweak)
01930 && hash->root.root.u.def.section == section
01931 && hash->root.type == STT_FUNC)
01932 compute_function_info (input_bfd, hash,
01933 (hash)->root.root.u.def.value,
01934 contents);
01935 }
01936 }
01937
01938
01939 if (internal_relocs != NULL
01940 && elf_section_data (section)->relocs != internal_relocs)
01941 free (internal_relocs);
01942 internal_relocs = NULL;
01943
01944
01945 if (contents != NULL
01946 && elf_section_data (section)->this_hdr.contents != contents)
01947 {
01948 if (! link_info->keep_memory)
01949 free (contents);
01950 else
01951 {
01952
01953 elf_section_data (section)->this_hdr.contents = contents;
01954 }
01955 }
01956 contents = NULL;
01957 }
01958
01959
01960 if (isymbuf != NULL
01961 && symtab_hdr->contents != (unsigned char *) isymbuf)
01962 {
01963 if (! link_info->keep_memory)
01964 free (isymbuf);
01965 else
01966 {
01967
01968 symtab_hdr->contents = (unsigned char *) isymbuf;
01969 }
01970 }
01971 isymbuf = NULL;
01972 }
01973
01974
01975
01976 elf32_mn10300_link_hash_traverse (hash_table,
01977 elf32_mn10300_finish_hash_table_entry,
01978 link_info);
01979 elf32_mn10300_link_hash_traverse (hash_table->static_hash_table,
01980 elf32_mn10300_finish_hash_table_entry,
01981 link_info);
01982
01983
01984 hash_table->flags |= MN10300_HASH_ENTRIES_INITIALIZED;
01985
01986
01987
01988
01989
01990 for (input_bfd = link_info->input_bfds;
01991 input_bfd != NULL;
01992 input_bfd = input_bfd->link_next)
01993 {
01994
01995 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
01996 if (symtab_hdr->sh_info != 0)
01997 {
01998 isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
01999 if (isymbuf == NULL)
02000 isymbuf = bfd_elf_get_elf_syms (input_bfd, symtab_hdr,
02001 symtab_hdr->sh_info, 0,
02002 NULL, NULL, NULL);
02003 if (isymbuf == NULL)
02004 goto error_return;
02005 }
02006
02007
02008 for (section = input_bfd->sections;
02009 section != NULL;
02010 section = section->next)
02011 {
02012 unsigned int sec_shndx;
02013 Elf_Internal_Sym *isym, *isymend;
02014 struct elf_link_hash_entry **hashes;
02015 struct elf_link_hash_entry **end_hashes;
02016 unsigned int symcount;
02017
02018
02019 if ((section->flags & SEC_CODE) == 0 || section->size == 0)
02020 continue;
02021
02022 if (section->reloc_count != 0)
02023 {
02024
02025 internal_relocs = (_bfd_elf_link_read_relocs
02026 (input_bfd, section, (PTR) NULL,
02027 (Elf_Internal_Rela *) NULL,
02028 link_info->keep_memory));
02029 if (internal_relocs == NULL)
02030 goto error_return;
02031 }
02032
02033
02034 if (elf_section_data (section)->this_hdr.contents != NULL)
02035 contents = elf_section_data (section)->this_hdr.contents;
02036 else
02037 {
02038
02039 if (!bfd_malloc_and_get_section (input_bfd, section,
02040 &contents))
02041 goto error_return;
02042 }
02043
02044 sec_shndx = _bfd_elf_section_from_bfd_section (input_bfd,
02045 section);
02046
02047
02048
02049 isymend = isymbuf + symtab_hdr->sh_info;
02050 for (isym = isymbuf; isym < isymend; isym++)
02051 {
02052 struct elf32_mn10300_link_hash_entry *sym_hash;
02053 asection *sym_sec = NULL;
02054 const char *sym_name;
02055 char *new_name;
02056 struct elf_link_hash_table *elftab;
02057 bfd_size_type amt;
02058
02059 if (isym->st_shndx != sec_shndx)
02060 continue;
02061
02062 if (isym->st_shndx == SHN_UNDEF)
02063 sym_sec = bfd_und_section_ptr;
02064 else if (isym->st_shndx == SHN_ABS)
02065 sym_sec = bfd_abs_section_ptr;
02066 else if (isym->st_shndx == SHN_COMMON)
02067 sym_sec = bfd_com_section_ptr;
02068 else
02069 sym_sec
02070 = bfd_section_from_elf_index (input_bfd, isym->st_shndx);
02071
02072 sym_name
02073 = bfd_elf_string_from_elf_section (input_bfd,
02074 symtab_hdr->sh_link,
02075 isym->st_name);
02076
02077
02078
02079 amt = strlen (sym_name) + 10;
02080 new_name = bfd_malloc (amt);
02081 if (new_name == 0)
02082 goto error_return;
02083 sprintf (new_name, "%s_%08x", sym_name, sym_sec->id);
02084 sym_name = new_name;
02085
02086 elftab = &hash_table->static_hash_table->root;
02087 sym_hash = ((struct elf32_mn10300_link_hash_entry *)
02088 elf_link_hash_lookup (elftab, sym_name,
02089 FALSE, FALSE, FALSE));
02090
02091 free (new_name);
02092 if (sym_hash == NULL)
02093 continue;
02094
02095 if (! (sym_hash->flags & MN10300_CONVERT_CALL_TO_CALLS)
02096 && ! (sym_hash->flags & MN10300_DELETED_PROLOGUE_BYTES))
02097 {
02098 int bytes = 0;
02099
02100
02101 elf_section_data (section)->relocs = internal_relocs;
02102 elf_section_data (section)->this_hdr.contents = contents;
02103 symtab_hdr->contents = (unsigned char *) isymbuf;
02104
02105
02106 if (sym_hash->movm_args)
02107 bytes += 2;
02108
02109 if (sym_hash->stack_size > 0)
02110 {
02111 if (sym_hash->stack_size <= 128)
02112 bytes += 3;
02113 else
02114 bytes += 4;
02115 }
02116
02117
02118
02119 sym_hash->flags |= MN10300_DELETED_PROLOGUE_BYTES;
02120
02121
02122 if (!mn10300_elf_relax_delete_bytes (input_bfd,
02123 section,
02124 isym->st_value,
02125 bytes))
02126 goto error_return;
02127
02128
02129
02130 *again = TRUE;
02131 }
02132 }
02133
02134
02135
02136 symcount = (symtab_hdr->sh_size / sizeof (Elf32_External_Sym)
02137 - symtab_hdr->sh_info);
02138 hashes = elf_sym_hashes (input_bfd);
02139 end_hashes = hashes + symcount;
02140 for (; hashes < end_hashes; hashes++)
02141 {
02142 struct elf32_mn10300_link_hash_entry *sym_hash;
02143
02144 sym_hash = (struct elf32_mn10300_link_hash_entry *) *hashes;
02145 if ((sym_hash->root.root.type == bfd_link_hash_defined
02146 || sym_hash->root.root.type == bfd_link_hash_defweak)
02147 && sym_hash->root.root.u.def.section == section
02148 && ! (sym_hash->flags & MN10300_CONVERT_CALL_TO_CALLS)
02149 && ! (sym_hash->flags & MN10300_DELETED_PROLOGUE_BYTES))
02150 {
02151 int bytes = 0;
02152 bfd_vma symval;
02153
02154
02155 elf_section_data (section)->relocs = internal_relocs;
02156 elf_section_data (section)->this_hdr.contents = contents;
02157 symtab_hdr->contents = (unsigned char *) isymbuf;
02158
02159
02160 if (sym_hash->movm_args)
02161 bytes += 2;
02162
02163 if (sym_hash->stack_size > 0)
02164 {
02165 if (sym_hash->stack_size <= 128)
02166 bytes += 3;
02167 else
02168 bytes += 4;
02169 }
02170
02171
02172
02173 sym_hash->flags |= MN10300_DELETED_PROLOGUE_BYTES;
02174
02175
02176 symval = sym_hash->root.root.u.def.value;
02177 if (!mn10300_elf_relax_delete_bytes (input_bfd,
02178 section,
02179 symval,
02180 bytes))
02181 goto error_return;
02182
02183
02184
02185 *again = TRUE;
02186 }
02187 }
02188
02189
02190 if (internal_relocs != NULL
02191 && elf_section_data (section)->relocs != internal_relocs)
02192 free (internal_relocs);
02193 internal_relocs = NULL;
02194
02195
02196 if (contents != NULL
02197 && elf_section_data (section)->this_hdr.contents != contents)
02198 {
02199 if (! link_info->keep_memory)
02200 free (contents);
02201 else
02202 {
02203
02204 elf_section_data (section)->this_hdr.contents = contents;
02205 }
02206 }
02207 contents = NULL;
02208 }
02209
02210
02211 if (isymbuf != NULL
02212 && symtab_hdr->contents != (unsigned char *) isymbuf)
02213 {
02214 if (! link_info->keep_memory)
02215 free (isymbuf);
02216 else
02217 {
02218
02219 symtab_hdr->contents = (unsigned char *) isymbuf;
02220 }
02221 }
02222 isymbuf = NULL;
02223 }
02224 }
02225
02226
02227 contents = NULL;
02228 internal_relocs = NULL;
02229 isymbuf = NULL;
02230
02231 section = sec;
02232
02233
02234
02235
02236 if (link_info->relocatable
02237 || (sec->flags & SEC_RELOC) == 0
02238 || sec->reloc_count == 0
02239 || (sec->flags & SEC_CODE) == 0)
02240 return TRUE;
02241
02242 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
02243
02244
02245 internal_relocs = (_bfd_elf_link_read_relocs
02246 (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
02247 link_info->keep_memory));
02248 if (internal_relocs == NULL)
02249 goto error_return;
02250
02251
02252 irelend = internal_relocs + sec->reloc_count;
02253 for (irel = internal_relocs; irel < irelend; irel++)
02254 {
02255 bfd_vma symval;
02256 struct elf32_mn10300_link_hash_entry *h = NULL;
02257
02258
02259
02260 if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_NONE
02261 || ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_8
02262 || ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_MAX)
02263 continue;
02264
02265
02266 if (contents == NULL)
02267 {
02268
02269 if (elf_section_data (sec)->this_hdr.contents != NULL)
02270 contents = elf_section_data (sec)->this_hdr.contents;
02271 else
02272 {
02273
02274 if (!bfd_malloc_and_get_section (abfd, sec, &contents))
02275 goto error_return;
02276 }
02277 }
02278
02279
02280 if (isymbuf == NULL && symtab_hdr->sh_info != 0)
02281 {
02282 isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
02283 if (isymbuf == NULL)
02284 isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
02285 symtab_hdr->sh_info, 0,
02286 NULL, NULL, NULL);
02287 if (isymbuf == NULL)
02288 goto error_return;
02289 }
02290
02291
02292 if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info)
02293 {
02294 Elf_Internal_Sym *isym;
02295 asection *sym_sec = NULL;
02296 const char *sym_name;
02297 char *new_name;
02298 bfd_vma saved_addend;
02299
02300
02301 isym = isymbuf + ELF32_R_SYM (irel->r_info);
02302 if (isym->st_shndx == SHN_UNDEF)
02303 sym_sec = bfd_und_section_ptr;
02304 else if (isym->st_shndx == SHN_ABS)
02305 sym_sec = bfd_abs_section_ptr;
02306 else if (isym->st_shndx == SHN_COMMON)
02307 sym_sec = bfd_com_section_ptr;
02308 else
02309 sym_sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
02310
02311 sym_name = bfd_elf_string_from_elf_section (abfd,
02312 symtab_hdr->sh_link,
02313 isym->st_name);
02314
02315 if ((sym_sec->flags & SEC_MERGE)
02316 && ELF_ST_TYPE (isym->st_info) == STT_SECTION
02317 && sym_sec->sec_info_type == ELF_INFO_TYPE_MERGE)
02318 {
02319 saved_addend = irel->r_addend;
02320 symval = _bfd_elf_rela_local_sym (abfd, isym, &sym_sec, irel);
02321 symval += irel->r_addend;
02322 irel->r_addend = saved_addend;
02323 }
02324 else
02325 {
02326 symval = (isym->st_value
02327 + sym_sec->output_section->vma
02328 + sym_sec->output_offset);
02329 }
02330
02331
02332 new_name = bfd_malloc ((bfd_size_type) strlen (sym_name) + 10);
02333 if (new_name == 0)
02334 goto error_return;
02335 sprintf (new_name, "%s_%08x", sym_name, sym_sec->id);
02336 sym_name = new_name;
02337
02338 h = (struct elf32_mn10300_link_hash_entry *)
02339 elf_link_hash_lookup (&hash_table->static_hash_table->root,
02340 sym_name, FALSE, FALSE, FALSE);
02341 free (new_name);
02342 }
02343 else
02344 {
02345 unsigned long indx;
02346
02347
02348 indx = ELF32_R_SYM (irel->r_info) - symtab_hdr->sh_info;
02349 h = (struct elf32_mn10300_link_hash_entry *)
02350 (elf_sym_hashes (abfd)[indx]);
02351 BFD_ASSERT (h != NULL);
02352 if (h->root.root.type != bfd_link_hash_defined
02353 && h->root.root.type != bfd_link_hash_defweak)
02354 {
02355
02356
02357
02358 continue;
02359 }
02360
02361 symval = (h->root.root.u.def.value
02362 + h->root.root.u.def.section->output_section->vma
02363 + h->root.root.u.def.section->output_offset);
02364 }
02365
02366
02367
02368
02369
02370
02371
02372
02373
02374
02375
02376
02377 if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_PCREL32
02378 || ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_PLT32)
02379 {
02380 bfd_vma value = symval;
02381
02382 if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_PLT32
02383 && h != NULL
02384 && ELF_ST_VISIBILITY (h->root.other) != STV_INTERNAL
02385 && ELF_ST_VISIBILITY (h->root.other) != STV_HIDDEN
02386 && h->root.plt.offset != (bfd_vma) -1)
02387 {
02388 asection * splt;
02389
02390 splt = bfd_get_section_by_name (elf_hash_table (link_info)
02391 ->dynobj, ".plt");
02392
02393 value = ((splt->output_section->vma
02394 + splt->output_offset
02395 + h->root.plt.offset)
02396 - (sec->output_section->vma
02397 + sec->output_offset
02398 + irel->r_offset));
02399 }
02400
02401
02402
02403 if (h && (h->flags & MN10300_CONVERT_CALL_TO_CALLS))
02404 {
02405 unsigned char code;
02406
02407
02408 code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
02409
02410
02411 if (code == 0xdd)
02412 {
02413
02414
02415 elf_section_data (sec)->relocs = internal_relocs;
02416 elf_section_data (sec)->this_hdr.contents = contents;
02417 symtab_hdr->contents = (unsigned char *) isymbuf;
02418
02419
02420 bfd_put_8 (abfd, 0xfc, contents + irel->r_offset - 1);
02421 bfd_put_8 (abfd, 0xff, contents + irel->r_offset);
02422
02423
02424 irel->r_offset += 1;
02425 irel->r_addend += 1;
02426
02427
02428 if (!mn10300_elf_relax_delete_bytes (abfd, sec,
02429 irel->r_offset + 3, 1))
02430 goto error_return;
02431
02432
02433
02434 *again = TRUE;
02435 }
02436 }
02437 else if (h)
02438 {
02439
02440
02441 unsigned char code;
02442
02443
02444 code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
02445
02446
02447
02448 if (code == 0xdd)
02449 {
02450 bfd_put_8 (abfd, h->movm_args, contents + irel->r_offset + 4);
02451 bfd_put_8 (abfd, h->stack_size + h->movm_stack_size,
02452 contents + irel->r_offset + 5);
02453 }
02454 }
02455
02456
02457 value -= (sec->output_section->vma + sec->output_offset);
02458 value -= irel->r_offset;
02459 value += irel->r_addend;
02460
02461
02462
02463
02464 if ((long) value < 0x8001 && (long) value > -0x8000)
02465 {
02466 unsigned char code;
02467
02468
02469 code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
02470
02471 if (code != 0xdc && code != 0xdd && code != 0xff)
02472 continue;
02473
02474
02475 elf_section_data (sec)->relocs = internal_relocs;
02476 elf_section_data (sec)->this_hdr.contents = contents;
02477 symtab_hdr->contents = (unsigned char *) isymbuf;
02478
02479
02480 if (code == 0xdc)
02481 bfd_put_8 (abfd, 0xcc, contents + irel->r_offset - 1);
02482 else if (code == 0xdd)
02483 bfd_put_8 (abfd, 0xcd, contents + irel->r_offset - 1);
02484 else if (code == 0xff)
02485 bfd_put_8 (abfd, 0xfa, contents + irel->r_offset - 2);
02486
02487
02488 irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
02489 (ELF32_R_TYPE (irel->r_info)
02490 == (int) R_MN10300_PLT32)
02491 ? R_MN10300_PLT16 :
02492 R_MN10300_PCREL16);
02493
02494
02495 if (!mn10300_elf_relax_delete_bytes (abfd, sec,
02496 irel->r_offset + 1, 2))
02497 goto error_return;
02498
02499
02500
02501 *again = TRUE;
02502 }
02503 }
02504
02505
02506
02507 if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_PCREL16)
02508 {
02509 bfd_vma value = symval;
02510
02511
02512
02513 if (h && (h->flags & MN10300_CONVERT_CALL_TO_CALLS))
02514 {
02515 unsigned char code;
02516
02517
02518 code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
02519
02520
02521 if (code == 0xcd)
02522 {
02523
02524
02525 elf_section_data (sec)->relocs = internal_relocs;
02526 elf_section_data (sec)->this_hdr.contents = contents;
02527 symtab_hdr->contents = (unsigned char *) isymbuf;
02528
02529
02530 bfd_put_8 (abfd, 0xfa, contents + irel->r_offset - 1);
02531 bfd_put_8 (abfd, 0xff, contents + irel->r_offset);
02532
02533
02534 irel->r_offset += 1;
02535 irel->r_addend += 1;
02536
02537
02538 if (!mn10300_elf_relax_delete_bytes (abfd, sec,
02539 irel->r_offset + 1, 1))
02540 goto error_return;
02541
02542
02543
02544 *again = TRUE;
02545 }
02546 }
02547 else if (h)
02548 {
02549 unsigned char code;
02550
02551
02552 code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
02553
02554
02555
02556 if (code == 0xcd)
02557 {
02558 bfd_put_8 (abfd, h->movm_args, contents + irel->r_offset + 2);
02559 bfd_put_8 (abfd, h->stack_size + h->movm_stack_size,
02560 contents + irel->r_offset + 3);
02561 }
02562 }
02563
02564
02565 value -= (sec->output_section->vma + sec->output_offset);
02566 value -= irel->r_offset;
02567 value += irel->r_addend;
02568
02569
02570
02571
02572 if ((long) value < 0x80 && (long) value > -0x80)
02573 {
02574 unsigned char code;
02575
02576
02577 code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
02578
02579 if (code != 0xcc)
02580 continue;
02581
02582
02583 elf_section_data (sec)->relocs = internal_relocs;
02584 elf_section_data (sec)->this_hdr.contents = contents;
02585 symtab_hdr->contents = (unsigned char *) isymbuf;
02586
02587
02588 bfd_put_8 (abfd, 0xca, contents + irel->r_offset - 1);
02589
02590
02591 irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
02592 R_MN10300_PCREL8);
02593
02594
02595 if (!mn10300_elf_relax_delete_bytes (abfd, sec,
02596 irel->r_offset + 1, 1))
02597 goto error_return;
02598
02599
02600
02601 *again = TRUE;
02602 }
02603 }
02604
02605
02606
02607
02608
02609
02610
02611
02612
02613
02614
02615
02616 if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_PCREL8)
02617 {
02618 Elf_Internal_Rela *nrel;
02619 bfd_vma value = symval;
02620 unsigned char code;
02621
02622
02623 value -= (sec->output_section->vma + sec->output_offset);
02624 value -= irel->r_offset;
02625 value += irel->r_addend;
02626
02627
02628 if (irel->r_offset == sec->size)
02629 continue;
02630
02631
02632
02633
02634 code = bfd_get_8 (abfd, contents + irel->r_offset + 1);
02635 if (code != 0xca)
02636 continue;
02637
02638
02639
02640 nrel = irel + 1;
02641 if (nrel == irelend
02642 || irel->r_offset + 2 != nrel->r_offset
02643 || ELF32_R_TYPE (nrel->r_info) != (int) R_MN10300_PCREL8)
02644 continue;
02645
02646
02647
02648 if (symval != (sec->output_section->vma + sec->output_offset
02649 + irel->r_offset + 3))
02650 continue;
02651
02652
02653
02654
02655
02656
02657
02658
02659 code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
02660 if (code != 0xc0 && code != 0xc1 && code != 0xc2
02661 && code != 0xc3 && code != 0xc4 && code != 0xc5
02662 && code != 0xc6 && code != 0xc7 && code != 0xc8
02663 && code != 0xc9 && code != 0xe8 && code != 0xe9
02664 && code != 0xea && code != 0xeb)
02665 continue;
02666
02667
02668
02669 if (mn10300_elf_symbol_address_p (abfd, sec, isymbuf,
02670 irel->r_offset + 1))
02671 continue;
02672
02673
02674 elf_section_data (sec)->relocs = internal_relocs;
02675 elf_section_data (sec)->this_hdr.contents = contents;
02676 symtab_hdr->contents = (unsigned char *) isymbuf;
02677
02678
02679 switch (code)
02680 {
02681 case 0xc8:
02682 code = 0xc9;
02683 break;
02684 case 0xc9:
02685 code = 0xc8;
02686 break;
02687 case 0xc0:
02688 code = 0xc2;
02689 break;
02690 case 0xc2:
02691 code = 0xc0;
02692 break;
02693 case 0xc3:
02694 code = 0xc1;
02695 break;
02696 case 0xc1:
02697 code = 0xc3;
02698 break;
02699 case 0xc4:
02700 code = 0xc6;
02701 break;
02702 case 0xc6:
02703 code = 0xc4;
02704 break;
02705 case 0xc7:
02706 code = 0xc5;
02707 break;
02708 case 0xc5:
02709 code = 0xc7;
02710 break;
02711 case 0xe8:
02712 code = 0xe9;
02713 break;
02714 case 0x9d:
02715 code = 0xe8;
02716 break;
02717 case 0xea:
02718 code = 0xeb;
02719 break;
02720 case 0xeb:
02721 code = 0xea;
02722 break;
02723 }
02724 bfd_put_8 (abfd, code, contents + irel->r_offset - 1);
02725
02726
02727
02728 irel->r_info = nrel->r_info;
02729
02730
02731 nrel->r_info = ELF32_R_INFO (ELF32_R_SYM (nrel->r_info),
02732 R_MN10300_NONE);
02733
02734
02735 if (!mn10300_elf_relax_delete_bytes (abfd, sec,
02736 irel->r_offset + 1, 2))
02737 goto error_return;
02738
02739
02740
02741 *again = TRUE;
02742 }
02743
02744
02745
02746 if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_24)
02747 {
02748 bfd_vma value = symval;
02749 value += irel->r_addend;
02750
02751
02752 if ((long) value < 0x7f && (long) value > -0x80)
02753 {
02754 unsigned char code;
02755
02756
02757
02758
02759
02760 code = bfd_get_8 (abfd, contents + irel->r_offset - 3);
02761
02762 if (code == 0xfd)
02763 {
02764
02765 code = bfd_get_8 (abfd, contents + irel->r_offset - 2);
02766
02767
02768
02769 if (code != 0x6b && code != 0x7b
02770 && code != 0x8b && code != 0x9b
02771 && ((code & 0x0f) == 0x09 || (code & 0x0f) == 0x08
02772 || (code & 0x0f) == 0x0a || (code & 0x0f) == 0x0b
02773 || (code & 0x0f) == 0x0e))
02774 {
02775
02776
02777
02778
02779 if ((value & 0x80) == 0)
02780 {
02781
02782
02783 elf_section_data (sec)->relocs = internal_relocs;
02784 elf_section_data (sec)->this_hdr.contents = contents;
02785 symtab_hdr->contents = (unsigned char *) isymbuf;
02786
02787
02788 bfd_put_8 (abfd, 0xfb, contents + irel->r_offset - 3);
02789 bfd_put_8 (abfd, code, contents + irel->r_offset - 2);
02790
02791
02792 irel->r_info =
02793 ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
02794 R_MN10300_8);
02795
02796
02797 if (!mn10300_elf_relax_delete_bytes (abfd, sec,
02798 irel->r_offset + 1, 2))
02799 goto error_return;
02800
02801
02802
02803
02804 *again = TRUE;
02805 break;
02806 }
02807 }
02808 }
02809 }
02810 }
02811
02812
02813
02814 if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_32
02815 || ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_GOT32
02816 || ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_GOTOFF32
02817 || ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_GOTPC32)
02818 {
02819 bfd_vma value = symval;
02820
02821 if (ELF32_R_TYPE (irel->r_info) != (int) R_MN10300_32)
02822 {
02823 asection * sgot;
02824
02825 sgot = bfd_get_section_by_name (elf_hash_table (link_info)
02826 ->dynobj, ".got");
02827
02828 if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_GOT32)
02829 {
02830 value = sgot->output_offset;
02831
02832 if (h)
02833 value += h->root.got.offset;
02834 else
02835 value += (elf_local_got_offsets
02836 (abfd)[ELF32_R_SYM (irel->r_info)]);
02837 }
02838 else if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_GOTOFF32)
02839 value -= sgot->output_section->vma;
02840 else if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_GOTPC32)
02841 value = (sgot->output_section->vma
02842 - (sec->output_section->vma
02843 + sec->output_offset
02844 + irel->r_offset));
02845 else
02846 abort ();
02847 }
02848
02849 value += irel->r_addend;
02850
02851
02852
02853
02854 if ((long) value < 0x7fffff && (long) value > -0x800000)
02855 {
02856 unsigned char code;
02857
02858
02859
02860
02861
02862 code = bfd_get_8 (abfd, contents + irel->r_offset - 3);
02863
02864 if (code == 0xfe)
02865 {
02866
02867 code = bfd_get_8 (abfd, contents + irel->r_offset - 2);
02868
02869
02870
02871
02872 if (code != 0x6b && code != 0x7b
02873 && code != 0x8b && code != 0x9b
02874 && (ELF32_R_TYPE (irel->r_info)
02875 != (int) R_MN10300_GOTPC32)
02876 && ((code & 0x0f) == 0x09 || (code & 0x0f) == 0x08
02877 || (code & 0x0f) == 0x0a || (code & 0x0f) == 0x0b
02878 || (code & 0x0f) == 0x0e))
02879 {
02880
02881
02882
02883
02884 if ((value & 0x8000) == 0)
02885 {
02886
02887
02888 elf_section_data (sec)->relocs = internal_relocs;
02889 elf_section_data (sec)->this_hdr.contents = contents;
02890 symtab_hdr->contents = (unsigned char *) isymbuf;
02891
02892
02893 bfd_put_8 (abfd, 0xfd, contents + irel->r_offset - 3);
02894 bfd_put_8 (abfd, code, contents + irel->r_offset - 2);
02895
02896
02897 irel->r_info =
02898 ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
02899 (ELF32_R_TYPE (irel->r_info)
02900 == (int) R_MN10300_GOTOFF32)
02901 ? R_MN10300_GOTOFF24
02902 : (ELF32_R_TYPE (irel->r_info)
02903 == (int) R_MN10300_GOT32)
02904 ? R_MN10300_GOT24 :
02905 R_MN10300_24);
02906
02907
02908 if (!mn10300_elf_relax_delete_bytes (abfd, sec,
02909 irel->r_offset + 3, 1))
02910 goto error_return;
02911
02912
02913
02914
02915 *again = TRUE;
02916 break;
02917 }
02918 }
02919 }
02920 }
02921
02922
02923
02924
02925 if ((long) value < 0x7fff && (long) value > -0x8000)
02926 {
02927 unsigned char code;
02928
02929
02930
02931
02932
02933
02934
02935
02936
02937
02938 code = bfd_get_8 (abfd, contents + irel->r_offset - 2);
02939
02940 if (code != 0xfc)
02941 continue;
02942
02943
02944 code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
02945
02946 if ((code & 0xf0) < 0x80)
02947 switch (code & 0xf0)
02948 {
02949
02950
02951
02952
02953
02954
02955
02956
02957 case 0x00:
02958 case 0x10:
02959 case 0x20:
02960 case 0x30:
02961 case 0x40:
02962 case 0x50:
02963 case 0x60:
02964 case 0x70:
02965
02966
02967
02968 if (code == 0xcc
02969 && (value & 0x8000))
02970 continue;
02971
02972
02973 elf_section_data (sec)->relocs = internal_relocs;
02974 elf_section_data (sec)->this_hdr.contents = contents;
02975 symtab_hdr->contents = (unsigned char *) isymbuf;
02976
02977
02978 bfd_put_8 (abfd, 0xfa, contents + irel->r_offset - 2);
02979 bfd_put_8 (abfd, code, contents + irel->r_offset - 1);
02980
02981
02982 irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
02983 (ELF32_R_TYPE (irel->r_info)
02984 == (int) R_MN10300_GOTOFF32)
02985 ? R_MN10300_GOTOFF16
02986 : (ELF32_R_TYPE (irel->r_info)
02987 == (int) R_MN10300_GOT32)
02988 ? R_MN10300_GOT16
02989 : (ELF32_R_TYPE (irel->r_info)
02990 == (int) R_MN10300_GOTPC32)
02991 ? R_MN10300_GOTPC16 :
02992 R_MN10300_16);
02993
02994
02995 if (!mn10300_elf_relax_delete_bytes (abfd, sec,
02996 irel->r_offset + 2, 2))
02997 goto error_return;
02998
02999
03000
03001 *again = TRUE;
03002 break;
03003 }
03004 else if ((code & 0xf0) == 0x80
03005 || (code & 0xf0) == 0x90)
03006 switch (code & 0xf3)
03007 {
03008
03009
03010
03011 case 0x81:
03012 case 0x82:
03013 case 0x83:
03014
03015 elf_section_data (sec)->relocs = internal_relocs;
03016 elf_section_data (sec)->this_hdr.contents = contents;
03017 symtab_hdr->contents = (unsigned char *) isymbuf;
03018
03019 if ((code & 0xf3) == 0x81)
03020 code = 0x01 + (code & 0x0c);
03021 else if ((code & 0xf3) == 0x82)
03022 code = 0x02 + (code & 0x0c);
03023 else if ((code & 0xf3) == 0x83)
03024 code = 0x03 + (code & 0x0c);
03025 else
03026 abort ();
03027
03028
03029 bfd_put_8 (abfd, code, contents + irel->r_offset - 2);
03030
03031
03032 irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
03033 (ELF32_R_TYPE (irel->r_info)
03034 == (int) R_MN10300_GOTOFF32)
03035 ? R_MN10300_GOTOFF16
03036 : (ELF32_R_TYPE (irel->r_info)
03037 == (int) R_MN10300_GOT32)
03038 ? R_MN10300_GOT16
03039 : (ELF32_R_TYPE (irel->r_info)
03040 == (int) R_MN10300_GOTPC32)
03041 ? R_MN10300_GOTPC16 :
03042 R_MN10300_16);
03043
03044
03045
03046 irel->r_offset -= 1;
03047
03048
03049 if (!mn10300_elf_relax_delete_bytes (abfd, sec,
03050 irel->r_offset + 1, 3))
03051 goto error_return;
03052
03053
03054
03055 *again = TRUE;
03056 break;
03057
03058
03059
03060
03061
03062
03063 case 0x80:
03064 case 0x90:
03065 case 0x91:
03066 case 0x92:
03067 case 0x93:
03068
03069 if (code >= 0x90 && code <= 0x93
03070 && (long)value < 0)
03071 continue;
03072
03073
03074 elf_section_data (sec)->relocs = internal_relocs;
03075 elf_section_data (sec)->this_hdr.contents = contents;
03076 symtab_hdr->contents = (unsigned char *) isymbuf;
03077
03078
03079 bfd_put_8 (abfd, 0xfa, contents + irel->r_offset - 2);
03080 bfd_put_8 (abfd, code, contents + irel->r_offset - 1);
03081
03082
03083 irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
03084 (ELF32_R_TYPE (irel->r_info)
03085 == (int) R_MN10300_GOTOFF32)
03086 ? R_MN10300_GOTOFF16
03087 : (ELF32_R_TYPE (irel->r_info)
03088 == (int) R_MN10300_GOT32)
03089 ? R_MN10300_GOT16
03090 : (ELF32_R_TYPE (irel->r_info)
03091 == (int) R_MN10300_GOTPC32)
03092 ? R_MN10300_GOTPC16 :
03093 R_MN10300_16);
03094
03095
03096 if (!mn10300_elf_relax_delete_bytes (abfd, sec,
03097 irel->r_offset + 2, 2))
03098 goto error_return;
03099
03100
03101
03102 *again = TRUE;
03103 break;
03104 }
03105 else if ((code & 0xf0) < 0xf0)
03106 switch (code & 0xfc)
03107 {
03108
03109
03110
03111
03112
03113 case 0xcc:
03114 case 0xdc:
03115 case 0xa4:
03116 case 0xa8:
03117 case 0xac:
03118
03119
03120
03121 if (code == 0xcc
03122 && (value & 0x8000))
03123 continue;
03124
03125
03126 if (code == 0xdc
03127 && (long)value < 0)
03128 continue;
03129
03130
03131 elf_section_data (sec)->relocs = internal_relocs;
03132 elf_section_data (sec)->this_hdr.contents = contents;
03133 symtab_hdr->contents = (unsigned char *) isymbuf;
03134
03135 if ((code & 0xfc) == 0xcc)
03136 code = 0x2c + (code & 0x03);
03137 else if ((code & 0xfc) == 0xdc)
03138 code = 0x24 + (code & 0x03);
03139 else if ((code & 0xfc) == 0xa4)
03140 code = 0x30 + (code & 0x03);
03141 else if ((code & 0xfc) == 0xa8)
03142 code = 0x34 + (code & 0x03);
03143 else if ((code & 0xfc) == 0xac)
03144 code = 0x38 + (code & 0x03);
03145 else
03146 abort ();
03147
03148
03149 bfd_put_8 (abfd, code, contents + irel->r_offset - 2);
03150
03151
03152 irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
03153 (ELF32_R_TYPE (irel->r_info)
03154 == (int) R_MN10300_GOTOFF32)
03155 ? R_MN10300_GOTOFF16
03156 : (ELF32_R_TYPE (irel->r_info)
03157 == (int) R_MN10300_GOT32)
03158 ? R_MN10300_GOT16
03159 : (ELF32_R_TYPE (irel->r_info)
03160 == (int) R_MN10300_GOTPC32)
03161 ? R_MN10300_GOTPC16 :
03162 R_MN10300_16);
03163
03164
03165
03166 irel->r_offset -= 1;
03167
03168
03169 if (!mn10300_elf_relax_delete_bytes (abfd, sec,
03170 irel->r_offset + 1, 3))
03171 goto error_return;
03172
03173
03174
03175 *again = TRUE;
03176 break;
03177
03178
03179
03180
03181
03182
03183
03184
03185
03186
03187
03188
03189
03190
03191
03192 case 0xa0:
03193 case 0xb0:
03194 case 0xb1:
03195 case 0xb2:
03196 case 0xb3:
03197 case 0xc0:
03198 case 0xc8:
03199
03200 case 0xd0:
03201 case 0xd8:
03202 case 0xe0:
03203 case 0xe1:
03204 case 0xe2:
03205 case 0xe3:
03206
03207 if (code == 0xdc
03208 && (long)value < 0)
03209 continue;
03210
03211
03212 if (code >= 0xb0 && code <= 0xb3
03213 && (long)value < 0)
03214 continue;
03215
03216
03217 elf_section_data (sec)->relocs = internal_relocs;
03218 elf_section_data (sec)->this_hdr.contents = contents;
03219 symtab_hdr->contents = (unsigned char *) isymbuf;
03220
03221
03222 bfd_put_8 (abfd, 0xfa, contents + irel->r_offset - 2);
03223 bfd_put_8 (abfd, code, contents + irel->r_offset - 1);
03224
03225
03226 irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
03227 (ELF32_R_TYPE (irel->r_info)
03228 == (int) R_MN10300_GOTOFF32)
03229 ? R_MN10300_GOTOFF16
03230 : (ELF32_R_TYPE (irel->r_info)
03231 == (int) R_MN10300_GOT32)
03232 ? R_MN10300_GOT16
03233 : (ELF32_R_TYPE (irel->r_info)
03234 == (int) R_MN10300_GOTPC32)
03235 ? R_MN10300_GOTPC16 :
03236 R_MN10300_16);
03237
03238
03239 if (!mn10300_elf_relax_delete_bytes (abfd, sec,
03240 irel->r_offset + 2, 2))
03241 goto error_return;
03242
03243
03244
03245 *again = TRUE;
03246 break;
03247 }
03248 else if (code == 0xfe)
03249 {
03250
03251
03252
03253 elf_section_data (sec)->relocs = internal_relocs;
03254 elf_section_data (sec)->this_hdr.contents = contents;
03255 symtab_hdr->contents = (unsigned char *) isymbuf;
03256
03257
03258 bfd_put_8 (abfd, 0xfa, contents + irel->r_offset - 2);
03259 bfd_put_8 (abfd, 0xfe, contents + irel->r_offset - 1);
03260
03261
03262 irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
03263 (ELF32_R_TYPE (irel->r_info)
03264 == (int) R_MN10300_GOT32)
03265 ? R_MN10300_GOT16
03266 : (ELF32_R_TYPE (irel->r_info)
03267 == (int) R_MN10300_GOTOFF32)
03268 ? R_MN10300_GOTOFF16
03269 : (ELF32_R_TYPE (irel->r_info)
03270 == (int) R_MN10300_GOTPC32)
03271 ? R_MN10300_GOTPC16 :
03272 R_MN10300_16);
03273
03274
03275 if (!mn10300_elf_relax_delete_bytes (abfd, sec,
03276 irel->r_offset + 2, 2))
03277 goto error_return;
03278
03279
03280
03281 *again = TRUE;
03282 break;
03283 }
03284 }
03285 }
03286 }
03287
03288 if (isymbuf != NULL
03289 && symtab_hdr->contents != (unsigned char *) isymbuf)
03290 {
03291 if (! link_info->keep_memory)
03292 free (isymbuf);
03293 else
03294 {
03295
03296 symtab_hdr->contents = (unsigned char *) isymbuf;
03297 }
03298 }
03299
03300 if (contents != NULL
03301 && elf_section_data (sec)->this_hdr.contents != contents)
03302 {
03303 if (! link_info->keep_memory)
03304 free (contents);
03305 else
03306 {
03307
03308 elf_section_data (sec)->this_hdr.contents = contents;
03309 }
03310 }
03311
03312 if (internal_relocs != NULL
03313 && elf_section_data (sec)->relocs != internal_relocs)
03314 free (internal_relocs);
03315
03316 return TRUE;
03317
03318 error_return:
03319 if (isymbuf != NULL
03320 && symtab_hdr->contents != (unsigned char *) isymbuf)
03321 free (isymbuf);
03322 if (contents != NULL
03323 && elf_section_data (section)->this_hdr.contents != contents)
03324 free (contents);
03325 if (internal_relocs != NULL
03326 && elf_section_data (section)->relocs != internal_relocs)
03327 free (internal_relocs);
03328
03329 return FALSE;
03330 }
03331
03332
03333
03334
03335 static void
03336 compute_function_info (abfd, hash, addr, contents)
03337 bfd *abfd;
03338 struct elf32_mn10300_link_hash_entry *hash;
03339 bfd_vma addr;
03340 unsigned char *contents;
03341 {
03342 unsigned char byte1, byte2;
03343
03344
03345
03346
03347
03348
03349
03350
03351
03352
03353 byte1 = bfd_get_8 (abfd, contents + addr);
03354 byte2 = bfd_get_8 (abfd, contents + addr + 1);
03355
03356 if (byte1 == 0xcf)
03357 {
03358 hash->movm_args = byte2;
03359 addr += 2;
03360 byte1 = bfd_get_8 (abfd, contents + addr);
03361 byte2 = bfd_get_8 (abfd, contents + addr + 1);
03362 }
03363
03364
03365
03366
03367 if (hash->movm_args)
03368 {
03369
03370 if (hash->movm_args & 0x80)
03371 hash->movm_stack_size += 4;
03372
03373
03374 if (hash->movm_args & 0x40)
03375 hash->movm_stack_size += 4;
03376
03377
03378 if (hash->movm_args & 0x20)
03379 hash->movm_stack_size += 4;
03380
03381
03382 if (hash->movm_args & 0x10)
03383 hash->movm_stack_size += 4;
03384
03385
03386 if (hash->movm_args & 0x08)
03387 hash->movm_stack_size += 8 * 4;
03388
03389 if (bfd_get_mach (abfd) == bfd_mach_am33
03390 || bfd_get_mach (abfd) == bfd_mach_am33_2)
03391 {
03392
03393 if (hash->movm_args & 0x1)
03394 hash->movm_stack_size += 6 * 4;
03395
03396
03397 if (hash->movm_args & 0x2)
03398 hash->movm_stack_size += 4 * 4;
03399
03400
03401 if (hash->movm_args & 0x4)
03402 hash->movm_stack_size += 2 * 4;
03403 }
03404 }
03405
03406
03407 if (byte1 == 0xf8 && byte2 == 0xfe)
03408 {
03409 int temp = bfd_get_8 (abfd, contents + addr + 2);
03410 temp = ((temp & 0xff) ^ (~0x7f)) + 0x80;
03411
03412 hash->stack_size = -temp;
03413 }
03414 else if (byte1 == 0xfa && byte2 == 0xfe)
03415 {
03416 int temp = bfd_get_16 (abfd, contents + addr + 2);
03417 temp = ((temp & 0xffff) ^ (~0x7fff)) + 0x8000;
03418 temp = -temp;
03419
03420 if (temp < 255)
03421 hash->stack_size = temp;
03422 }
03423
03424
03425
03426
03427 if (hash->stack_size + hash->movm_stack_size > 255)
03428 hash->stack_size = 0;
03429
03430 return;
03431 }
03432
03433
03434
03435 static bfd_boolean
03436 mn10300_elf_relax_delete_bytes (abfd, sec, addr, count)
03437 bfd *abfd;
03438 asection *sec;
03439 bfd_vma addr;
03440 int count;
03441 {
03442 Elf_Internal_Shdr *symtab_hdr;
03443 unsigned int sec_shndx;
03444 bfd_byte *contents;
03445 Elf_Internal_Rela *irel, *irelend;
03446 Elf_Internal_Rela *irelalign;
03447 bfd_vma toaddr;
03448 Elf_Internal_Sym *isym, *isymend;
03449 struct elf_link_hash_entry **sym_hashes;
03450 struct elf_link_hash_entry **end_hashes;
03451 unsigned int symcount;
03452
03453 sec_shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
03454
03455 contents = elf_section_data (sec)->this_hdr.contents;
03456
03457
03458
03459
03460 irelalign = NULL;
03461 toaddr = sec->size;
03462
03463 irel = elf_section_data (sec)->relocs;
03464 irelend = irel + sec->reloc_count;
03465
03466
03467 memmove (contents + addr, contents + addr + count,
03468 (size_t) (toaddr - addr - count));
03469 sec->size -= count;
03470
03471
03472 for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++)
03473 {
03474
03475 if ((irel->r_offset > addr
03476 && irel->r_offset < toaddr))
03477 irel->r_offset -= count;
03478 }
03479
03480
03481 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
03482 isym = (Elf_Internal_Sym *) symtab_hdr->contents;
03483 for (isymend = isym + symtab_hdr->sh_info; isym < isymend; isym++)
03484 {
03485 if (isym->st_shndx == sec_shndx
03486 && isym->st_value > addr
03487 && isym->st_value < toaddr)
03488 isym->st_value -= count;
03489 }
03490
03491
03492 symcount = (symtab_hdr->sh_size / sizeof (Elf32_External_Sym)
03493 - symtab_hdr->sh_info);
03494 sym_hashes = elf_sym_hashes (abfd);
03495 end_hashes = sym_hashes + symcount;
03496 for (; sym_hashes < end_hashes; sym_hashes++)
03497 {
03498 struct elf_link_hash_entry *sym_hash = *sym_hashes;
03499 if ((sym_hash->root.type == bfd_link_hash_defined
03500 || sym_hash->root.type == bfd_link_hash_defweak)
03501 && sym_hash->root.u.def.section == sec
03502 && sym_hash->root.u.def.value > addr
03503 && sym_hash->root.u.def.value < toaddr)
03504 {
03505 sym_hash->root.u.def.value -= count;
03506 }
03507 }
03508
03509 return TRUE;
03510 }
03511
03512
03513
03514 static bfd_boolean
03515 mn10300_elf_symbol_address_p (abfd, sec, isym, addr)
03516 bfd *abfd;
03517 asection *sec;
03518 Elf_Internal_Sym *isym;
03519 bfd_vma addr;
03520 {
03521 Elf_Internal_Shdr *symtab_hdr;
03522 unsigned int sec_shndx;
03523 Elf_Internal_Sym *isymend;
03524 struct elf_link_hash_entry **sym_hashes;
03525 struct elf_link_hash_entry **end_hashes;
03526 unsigned int symcount;
03527
03528 sec_shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
03529
03530
03531 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
03532 for (isymend = isym + symtab_hdr->sh_info; isym < isymend; isym++)
03533 {
03534 if (isym->st_shndx == sec_shndx
03535 && isym->st_value == addr)
03536 return TRUE;
03537 }
03538
03539 symcount = (symtab_hdr->sh_size / sizeof (Elf32_External_Sym)
03540 - symtab_hdr->sh_info);
03541 sym_hashes = elf_sym_hashes (abfd);
03542 end_hashes = sym_hashes + symcount;
03543 for (; sym_hashes < end_hashes; sym_hashes++)
03544 {
03545 struct elf_link_hash_entry *sym_hash = *sym_hashes;
03546 if ((sym_hash->root.type == bfd_link_hash_defined
03547 || sym_hash->root.type == bfd_link_hash_defweak)
03548 && sym_hash->root.u.def.section == sec
03549 && sym_hash->root.u.def.value == addr)
03550 return TRUE;
03551 }
03552
03553 return FALSE;
03554 }
03555
03556
03557
03558
03559 static bfd_byte *
03560 mn10300_elf_get_relocated_section_contents (output_bfd, link_info, link_order,
03561 data, relocatable, symbols)
03562 bfd *output_bfd;
03563 struct bfd_link_info *link_info;
03564 struct bfd_link_order *link_order;
03565 bfd_byte *data;
03566 bfd_boolean relocatable;
03567 asymbol **symbols;
03568 {
03569 Elf_Internal_Shdr *symtab_hdr;
03570 asection *input_section = link_order->u.indirect.section;
03571 bfd *input_bfd = input_section->owner;
03572 asection **sections = NULL;
03573 Elf_Internal_Rela *internal_relocs = NULL;
03574 Elf_Internal_Sym *isymbuf = NULL;
03575
03576
03577
03578 if (relocatable
03579 || elf_section_data (input_section)->this_hdr.contents == NULL)
03580 return bfd_generic_get_relocated_section_contents (output_bfd, link_info,
03581 link_order, data,
03582 relocatable,
03583 symbols);
03584
03585 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
03586
03587 memcpy (data, elf_section_data (input_section)->this_hdr.contents,
03588 (size_t) input_section->size);
03589
03590 if ((input_section->flags & SEC_RELOC) != 0
03591 && input_section->reloc_count > 0)
03592 {
03593 asection **secpp;
03594 Elf_Internal_Sym *isym, *isymend;
03595 bfd_size_type amt;
03596
03597 internal_relocs = (_bfd_elf_link_read_relocs
03598 (input_bfd, input_section, (PTR) NULL,
03599 (Elf_Internal_Rela *) NULL, FALSE));
03600 if (internal_relocs == NULL)
03601 goto error_return;
03602
03603 if (symtab_hdr->sh_info != 0)
03604 {
03605 isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
03606 if (isymbuf == NULL)
03607 isymbuf = bfd_elf_get_elf_syms (input_bfd, symtab_hdr,
03608 symtab_hdr->sh_info, 0,
03609 NULL, NULL, NULL);
03610 if (isymbuf == NULL)
03611 goto error_return;
03612 }
03613
03614 amt = symtab_hdr->sh_info;
03615 amt *= sizeof (asection *);
03616 sections = (asection **) bfd_malloc (amt);
03617 if (sections == NULL && amt != 0)
03618 goto error_return;
03619
03620 isymend = isymbuf + symtab_hdr->sh_info;
03621 for (isym = isymbuf, secpp = sections; isym < isymend; ++isym, ++secpp)
03622 {
03623 asection *isec;
03624
03625 if (isym->st_shndx == SHN_UNDEF)
03626 isec = bfd_und_section_ptr;
03627 else if (isym->st_shndx == SHN_ABS)
03628 isec = bfd_abs_section_ptr;
03629 else if (isym->st_shndx == SHN_COMMON)
03630 isec = bfd_com_section_ptr;
03631 else
03632 isec = bfd_section_from_elf_index (input_bfd, isym->st_shndx);
03633
03634 *secpp = isec;
03635 }
03636
03637 if (! mn10300_elf_relocate_section (output_bfd, link_info, input_bfd,
03638 input_section, data, internal_relocs,
03639 isymbuf, sections))
03640 goto error_return;
03641
03642 if (sections != NULL)
03643 free (sections);
03644 if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
03645 free (isymbuf);
03646 if (internal_relocs != elf_section_data (input_section)->relocs)
03647 free (internal_relocs);
03648 }
03649
03650 return data;
03651
03652 error_return:
03653 if (sections != NULL)
03654 free (sections);
03655 if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
03656 free (isymbuf);
03657 if (internal_relocs != NULL
03658 && internal_relocs != elf_section_data (input_section)->relocs)
03659 free (internal_relocs);
03660 return NULL;
03661 }
03662
03663
03664
03665
03666
03667
03668
03669 static struct bfd_hash_entry *
03670 elf32_mn10300_link_hash_newfunc (entry, table, string)
03671 struct bfd_hash_entry *entry;
03672 struct bfd_hash_table *table;
03673 const char *string;
03674 {
03675 struct elf32_mn10300_link_hash_entry *ret =
03676 (struct elf32_mn10300_link_hash_entry *) entry;
03677
03678
03679
03680 if (ret == (struct elf32_mn10300_link_hash_entry *) NULL)
03681 ret = ((struct elf32_mn10300_link_hash_entry *)
03682 bfd_hash_allocate (table,
03683 sizeof (struct elf32_mn10300_link_hash_entry)));
03684 if (ret == (struct elf32_mn10300_link_hash_entry *) NULL)
03685 return (struct bfd_hash_entry *) ret;
03686
03687
03688 ret = ((struct elf32_mn10300_link_hash_entry *)
03689 _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,
03690 table, string));
03691 if (ret != (struct elf32_mn10300_link_hash_entry *) NULL)
03692 {
03693 ret->direct_calls = 0;
03694 ret->stack_size = 0;
03695 ret->movm_args = 0;
03696 ret->movm_stack_size = 0;
03697 ret->flags = 0;
03698 }
03699
03700 return (struct bfd_hash_entry *) ret;
03701 }
03702
03703
03704
03705 static struct bfd_link_hash_table *
03706 elf32_mn10300_link_hash_table_create (abfd)
03707 bfd *abfd;
03708 {
03709 struct elf32_mn10300_link_hash_table *ret;
03710 bfd_size_type amt = sizeof (struct elf32_mn10300_link_hash_table);
03711
03712 ret = (struct elf32_mn10300_link_hash_table *) bfd_malloc (amt);
03713 if (ret == (struct elf32_mn10300_link_hash_table *) NULL)
03714 return NULL;
03715
03716 if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
03717 elf32_mn10300_link_hash_newfunc))
03718 {
03719 free (ret);
03720 return NULL;
03721 }
03722
03723 ret->flags = 0;
03724 amt = sizeof (struct elf_link_hash_table);
03725 ret->static_hash_table
03726 = (struct elf32_mn10300_link_hash_table *) bfd_malloc (amt);
03727 if (ret->static_hash_table == NULL)
03728 {
03729 free (ret);
03730 return NULL;
03731 }
03732
03733 if (! _bfd_elf_link_hash_table_init (&ret->static_hash_table->root, abfd,
03734 elf32_mn10300_link_hash_newfunc))
03735 {
03736 free (ret->static_hash_table);
03737 free (ret);
03738 return NULL;
03739 }
03740 return &ret->root.root;
03741 }
03742
03743
03744
03745 static void
03746 elf32_mn10300_link_hash_table_free (hash)
03747 struct bfd_link_hash_table *hash;
03748 {
03749 struct elf32_mn10300_link_hash_table *ret
03750 = (struct elf32_mn10300_link_hash_table *) hash;
03751
03752 _bfd_generic_link_hash_table_free
03753 ((struct bfd_link_hash_table *) ret->static_hash_table);
03754 _bfd_generic_link_hash_table_free
03755 ((struct bfd_link_hash_table *) ret);
03756 }
03757
03758 static unsigned long
03759 elf_mn10300_mach (flags)
03760 flagword flags;
03761 {
03762 switch (flags & EF_MN10300_MACH)
03763 {
03764 case E_MN10300_MACH_MN10300:
03765 default:
03766 return bfd_mach_mn10300;
03767
03768 case E_MN10300_MACH_AM33:
03769 return bfd_mach_am33;
03770
03771 case E_MN10300_MACH_AM33_2:
03772 return bfd_mach_am33_2;
03773 }
03774 }
03775
03776
03777
03778
03779
03780 void
03781 _bfd_mn10300_elf_final_write_processing (abfd, linker)
03782 bfd *abfd;
03783 bfd_boolean linker ATTRIBUTE_UNUSED;
03784 {
03785 unsigned long val;
03786
03787 switch (bfd_get_mach (abfd))
03788 {
03789 default:
03790 case bfd_mach_mn10300:
03791 val = E_MN10300_MACH_MN10300;
03792 break;
03793
03794 case bfd_mach_am33:
03795 val = E_MN10300_MACH_AM33;
03796 break;
03797
03798 case bfd_mach_am33_2:
03799 val = E_MN10300_MACH_AM33_2;
03800 break;
03801 }
03802
03803 elf_elfheader (abfd)->e_flags &= ~ (EF_MN10300_MACH);
03804 elf_elfheader (abfd)->e_flags |= val;
03805 }
03806
03807 bfd_boolean
03808 _bfd_mn10300_elf_object_p (abfd)
03809 bfd *abfd;
03810 {
03811 bfd_default_set_arch_mach (abfd, bfd_arch_mn10300,
03812 elf_mn10300_mach (elf_elfheader (abfd)->e_flags));
03813 return TRUE;
03814 }
03815
03816
03817
03818
03819 bfd_boolean
03820 _bfd_mn10300_elf_merge_private_bfd_data (ibfd, obfd)
03821 bfd *ibfd;
03822 bfd *obfd;
03823 {
03824 if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
03825 || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
03826 return TRUE;
03827
03828 if (bfd_get_arch (obfd) == bfd_get_arch (ibfd)
03829 && bfd_get_mach (obfd) < bfd_get_mach (ibfd))
03830 {
03831 if (! bfd_set_arch_mach (obfd, bfd_get_arch (ibfd),
03832 bfd_get_mach (ibfd)))
03833 return FALSE;
03834 }
03835
03836 return TRUE;
03837 }
03838
03839 #define PLT0_ENTRY_SIZE 15
03840 #define PLT_ENTRY_SIZE 20
03841 #define PIC_PLT_ENTRY_SIZE 24
03842
03843 static const bfd_byte elf_mn10300_plt0_entry[PLT0_ENTRY_SIZE] =
03844 {
03845 0xfc, 0xa0, 0, 0, 0, 0,
03846 0xfe, 0xe, 0x10, 0, 0, 0, 0,
03847 0xf0, 0xf4,
03848 };
03849
03850 static const bfd_byte elf_mn10300_plt_entry[PLT_ENTRY_SIZE] =
03851 {
03852 0xfc, 0xa0, 0, 0, 0, 0,
03853 0xf0, 0xf4,
03854 0xfe, 8, 0, 0, 0, 0, 0,
03855 0xdc, 0, 0, 0, 0,
03856 };
03857
03858 static const bfd_byte elf_mn10300_pic_plt_entry[PIC_PLT_ENTRY_SIZE] =
03859 {
03860 0xfc, 0x22, 0, 0, 0, 0,
03861 0xf0, 0xf4,
03862 0xfe, 8, 0, 0, 0, 0, 0,
03863 0xf8, 0x22, 8,
03864 0xfb, 0xa, 0x1a, 4,
03865 0xf0, 0xf4,
03866 };
03867
03868
03869 #define elf_mn10300_sizeof_plt0(info) \
03870 (info->shared ? PIC_PLT_ENTRY_SIZE : PLT0_ENTRY_SIZE)
03871
03872
03873 #define elf_mn10300_sizeof_plt(info) \
03874 (info->shared ? PIC_PLT_ENTRY_SIZE : PLT_ENTRY_SIZE)
03875
03876
03877 #define elf_mn10300_plt_plt0_offset(info) 16
03878
03879
03880 #define elf_mn10300_plt0_linker_offset(info) 2
03881
03882
03883 #define elf_mn10300_plt0_gotid_offset(info) 9
03884
03885
03886 #define elf_mn10300_plt_temp_offset(info) 8
03887
03888
03889 #define elf_mn10300_plt_symbol_offset(info) 2
03890
03891
03892 #define elf_mn10300_plt_reloc_offset(info) 11
03893
03894
03895
03896
03897 #define ELF_DYNAMIC_INTERPRETER "/lib/ld.so.1"
03898
03899
03900
03901 static bfd_boolean
03902 _bfd_mn10300_elf_create_dynamic_sections (abfd, info)
03903 bfd *abfd;
03904 struct bfd_link_info *info;
03905 {
03906 flagword flags;
03907 asection * s;
03908 const struct elf_backend_data * bed = get_elf_backend_data (abfd);
03909 int ptralign = 0;
03910
03911 switch (bed->s->arch_size)
03912 {
03913 case 32:
03914 ptralign = 2;
03915 break;
03916
03917 case 64:
03918 ptralign = 3;
03919 break;
03920
03921 default:
03922 bfd_set_error (bfd_error_bad_value);
03923 return FALSE;
03924 }
03925
03926
03927
03928
03929 flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
03930 | SEC_LINKER_CREATED);
03931
03932 s = bfd_make_section (abfd,
03933 bed->default_use_rela_p ? ".rela.plt" : ".rel.plt");
03934 if (s == NULL
03935 || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
03936 || ! bfd_set_section_alignment (abfd, s, ptralign))
03937 return FALSE;
03938
03939 if (! _bfd_mn10300_elf_create_got_section (abfd, info))
03940 return FALSE;
03941
03942 {
03943 const char * secname;
03944 char * relname;
03945 flagword secflags;
03946 asection * sec;
03947
03948 for (sec = abfd->sections; sec; sec = sec->next)
03949 {
03950 secflags = bfd_get_section_flags (abfd, sec);
03951 if ((secflags & (SEC_DATA | SEC_LINKER_CREATED))
03952 || ((secflags & SEC_HAS_CONTENTS) != SEC_HAS_CONTENTS))
03953 continue;
03954
03955 secname = bfd_get_section_name (abfd, sec);
03956 relname = (char *) bfd_malloc (strlen (secname) + 6);
03957 strcpy (relname, ".rela");
03958 strcat (relname, secname);
03959
03960 s = bfd_make_section (abfd, relname);
03961 if (s == NULL
03962 || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
03963 || ! bfd_set_section_alignment (abfd, s, ptralign))
03964 return FALSE;
03965 }
03966 }
03967
03968 if (bed->want_dynbss)
03969 {
03970
03971
03972
03973
03974
03975
03976 s = bfd_make_section (abfd, ".dynbss");
03977 if (s == NULL
03978 || ! bfd_set_section_flags (abfd, s, SEC_ALLOC))
03979 return FALSE;
03980
03981
03982
03983
03984
03985
03986
03987
03988
03989
03990
03991
03992 if (! info->shared)
03993 {
03994 s = bfd_make_section (abfd,
03995 (bed->default_use_rela_p
03996 ? ".rela.bss" : ".rel.bss"));
03997 if (s == NULL
03998 || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
03999 || ! bfd_set_section_alignment (abfd, s, ptralign))
04000 return FALSE;
04001 }
04002 }
04003
04004 return TRUE;
04005 }
04006
04007
04008
04009
04010
04011
04012
04013 static bfd_boolean
04014 _bfd_mn10300_elf_adjust_dynamic_symbol (info, h)
04015 struct bfd_link_info * info;
04016 struct elf_link_hash_entry * h;
04017 {
04018 bfd * dynobj;
04019 asection * s;
04020 unsigned int power_of_two;
04021
04022 dynobj = elf_hash_table (info)->dynobj;
04023
04024
04025 BFD_ASSERT (dynobj != NULL
04026 && (h->needs_plt
04027 || h->u.weakdef != NULL
04028 || (h->def_dynamic
04029 && h->ref_regular
04030 && !h->def_regular)));
04031
04032
04033
04034
04035 if (h->type == STT_FUNC
04036 || h->needs_plt)
04037 {
04038 if (! info->shared
04039 && !h->def_dynamic
04040 && !h->ref_dynamic)
04041 {
04042
04043
04044
04045
04046
04047 BFD_ASSERT (h->needs_plt);
04048 return TRUE;
04049 }
04050
04051
04052 if (h->dynindx == -1)
04053 {
04054 if (! bfd_elf_link_record_dynamic_symbol (info, h))
04055 return FALSE;
04056 }
04057
04058 s = bfd_get_section_by_name (dynobj, ".plt");
04059 BFD_ASSERT (s != NULL);
04060
04061
04062
04063 if (s->size == 0)
04064 s->size += elf_mn10300_sizeof_plt0 (info);
04065
04066
04067
04068
04069
04070
04071 if (! info->shared
04072 && !h->def_regular)
04073 {
04074 h->root.u.def.section = s;
04075 h->root.u.def.value = s->size;
04076 }
04077
04078 h->plt.offset = s->size;
04079
04080
04081 s->size += elf_mn10300_sizeof_plt (info);
04082
04083
04084
04085
04086 s = bfd_get_section_by_name (dynobj, ".got.plt");
04087 BFD_ASSERT (s != NULL);
04088 s->size += 4;
04089
04090
04091
04092 s = bfd_get_section_by_name (dynobj, ".rela.plt");
04093 BFD_ASSERT (s != NULL);
04094 s->size += sizeof (Elf32_External_Rela);
04095
04096 return TRUE;
04097 }
04098
04099
04100
04101
04102 if (h->u.weakdef != NULL)
04103 {
04104 BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined
04105 || h->u.weakdef->root.type == bfd_link_hash_defweak);
04106 h->root.u.def.section = h->u.weakdef->root.u.def.section;
04107 h->root.u.def.value = h->u.weakdef->root.u.def.value;
04108 return TRUE;
04109 }
04110
04111
04112
04113
04114
04115
04116
04117
04118 if (info->shared)
04119 return TRUE;
04120
04121
04122
04123 if (!h->non_got_ref)
04124 return TRUE;
04125
04126
04127
04128
04129
04130
04131
04132
04133
04134
04135
04136 s = bfd_get_section_by_name (dynobj, ".dynbss");
04137 BFD_ASSERT (s != NULL);
04138
04139
04140
04141
04142
04143 if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
04144 {
04145 asection * srel;
04146
04147 srel = bfd_get_section_by_name (dynobj, ".rela.bss");
04148 BFD_ASSERT (srel != NULL);
04149 srel->size += sizeof (Elf32_External_Rela);
04150 h->needs_copy = 1;
04151 }
04152
04153
04154
04155 power_of_two = bfd_log2 (h->size);
04156 if (power_of_two > 3)
04157 power_of_two = 3;
04158
04159
04160 s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two));
04161 if (power_of_two > bfd_get_section_alignment (dynobj, s))
04162 {
04163 if (! bfd_set_section_alignment (dynobj, s, power_of_two))
04164 return FALSE;
04165 }
04166
04167
04168 h->root.u.def.section = s;
04169 h->root.u.def.value = s->size;
04170
04171
04172 s->size += h->size;
04173
04174 return TRUE;
04175 }
04176
04177
04178
04179 static bfd_boolean
04180 _bfd_mn10300_elf_size_dynamic_sections (output_bfd, info)
04181 bfd * output_bfd;
04182 struct bfd_link_info * info;
04183 {
04184 bfd * dynobj;
04185 asection * s;
04186 bfd_boolean plt;
04187 bfd_boolean relocs;
04188 bfd_boolean reltext;
04189
04190 dynobj = elf_hash_table (info)->dynobj;
04191 BFD_ASSERT (dynobj != NULL);
04192
04193 if (elf_hash_table (info)->dynamic_sections_created)
04194 {
04195
04196 if (info->executable)
04197 {
04198 s = bfd_get_section_by_name (dynobj, ".interp");
04199 BFD_ASSERT (s != NULL);
04200 s->size = sizeof ELF_DYNAMIC_INTERPRETER;
04201 s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
04202 }
04203 }
04204 else
04205 {
04206
04207
04208
04209
04210
04211 s = bfd_get_section_by_name (dynobj, ".rela.got");
04212 if (s != NULL)
04213 s->size = 0;
04214 }
04215
04216
04217
04218
04219 plt = FALSE;
04220 relocs = FALSE;
04221 reltext = FALSE;
04222 for (s = dynobj->sections; s != NULL; s = s->next)
04223 {
04224 const char * name;
04225 bfd_boolean strip;
04226
04227 if ((s->flags & SEC_LINKER_CREATED) == 0)
04228 continue;
04229
04230
04231
04232 name = bfd_get_section_name (dynobj, s);
04233
04234 strip = FALSE;
04235
04236 if (strcmp (name, ".plt") == 0)
04237 {
04238 if (s->size == 0)
04239
04240
04241 strip = TRUE;
04242 else
04243
04244 plt = TRUE;
04245 }
04246 else if (strncmp (name, ".rela", 5) == 0)
04247 {
04248 if (s->size == 0)
04249 {
04250
04251
04252
04253
04254
04255
04256
04257
04258
04259 strip = TRUE;
04260 }
04261 else
04262 {
04263 asection * target;
04264
04265
04266
04267 if (strcmp (name, ".rela.plt") != 0)
04268 {
04269 const char * outname;
04270
04271 relocs = TRUE;
04272
04273
04274
04275
04276
04277
04278 outname = bfd_get_section_name (output_bfd,
04279 s->output_section);
04280 target = bfd_get_section_by_name (output_bfd, outname + 5);
04281 if (target != NULL
04282 && (target->flags & SEC_READONLY) != 0
04283 && (target->flags & SEC_ALLOC) != 0)
04284 reltext = TRUE;
04285 }
04286
04287
04288
04289 s->reloc_count = 0;
04290 }
04291 }
04292 else if (strncmp (name, ".got", 4) != 0)
04293
04294 continue;
04295
04296 if (strip)
04297 {
04298 _bfd_strip_section_from_output (info, s);
04299 continue;
04300 }
04301
04302
04303
04304
04305
04306
04307 s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size);
04308 if (s->contents == NULL && s->size != 0)
04309 return FALSE;
04310 }
04311
04312 if (elf_hash_table (info)->dynamic_sections_created)
04313 {
04314
04315
04316
04317
04318
04319 if (! info->shared)
04320 {
04321 if (!_bfd_elf_add_dynamic_entry (info, DT_DEBUG, 0))
04322 return FALSE;
04323 }
04324
04325 if (plt)
04326 {
04327 if (!_bfd_elf_add_dynamic_entry (info, DT_PLTGOT, 0)
04328 || !_bfd_elf_add_dynamic_entry (info, DT_PLTRELSZ, 0)
04329 || !_bfd_elf_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
04330 || !_bfd_elf_add_dynamic_entry (info, DT_JMPREL, 0))
04331 return FALSE;
04332 }
04333
04334 if (relocs)
04335 {
04336 if (!_bfd_elf_add_dynamic_entry (info, DT_RELA, 0)
04337 || !_bfd_elf_add_dynamic_entry (info, DT_RELASZ, 0)
04338 || !_bfd_elf_add_dynamic_entry (info, DT_RELAENT,
04339 sizeof (Elf32_External_Rela)))
04340 return FALSE;
04341 }
04342
04343 if (reltext)
04344 {
04345 if (!_bfd_elf_add_dynamic_entry (info, DT_TEXTREL, 0))
04346 return FALSE;
04347 }
04348 }
04349
04350 return TRUE;
04351 }
04352
04353
04354
04355
04356 static bfd_boolean
04357 _bfd_mn10300_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
04358 bfd * output_bfd;
04359 struct bfd_link_info * info;
04360 struct elf_link_hash_entry * h;
04361 Elf_Internal_Sym * sym;
04362 {
04363 bfd * dynobj;
04364
04365 dynobj = elf_hash_table (info)->dynobj;
04366
04367 if (h->plt.offset != (bfd_vma) -1)
04368 {
04369 asection * splt;
04370 asection * sgot;
04371 asection * srel;
04372 bfd_vma plt_index;
04373 bfd_vma got_offset;
04374 Elf_Internal_Rela rel;
04375
04376
04377
04378
04379 BFD_ASSERT (h->dynindx != -1);
04380
04381 splt = bfd_get_section_by_name (dynobj, ".plt");
04382 sgot = bfd_get_section_by_name (dynobj, ".got.plt");
04383 srel = bfd_get_section_by_name (dynobj, ".rela.plt");
04384 BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
04385
04386
04387
04388
04389
04390 plt_index = ((h->plt.offset - elf_mn10300_sizeof_plt0 (info))
04391 / elf_mn10300_sizeof_plt (info));
04392
04393
04394
04395
04396 got_offset = (plt_index + 3) * 4;
04397
04398
04399 if (! info->shared)
04400 {
04401 memcpy (splt->contents + h->plt.offset, elf_mn10300_plt_entry,
04402 elf_mn10300_sizeof_plt (info));
04403 bfd_put_32 (output_bfd,
04404 (sgot->output_section->vma
04405 + sgot->output_offset
04406 + got_offset),
04407 (splt->contents + h->plt.offset
04408 + elf_mn10300_plt_symbol_offset (info)));
04409
04410 bfd_put_32 (output_bfd,
04411 (1 - h->plt.offset - elf_mn10300_plt_plt0_offset (info)),
04412 (splt->contents + h->plt.offset
04413 + elf_mn10300_plt_plt0_offset (info)));
04414 }
04415 else
04416 {
04417 memcpy (splt->contents + h->plt.offset, elf_mn10300_pic_plt_entry,
04418 elf_mn10300_sizeof_plt (info));
04419
04420 bfd_put_32 (output_bfd, got_offset,
04421 (splt->contents + h->plt.offset
04422 + elf_mn10300_plt_symbol_offset (info)));
04423 }
04424
04425 bfd_put_32 (output_bfd, plt_index * sizeof (Elf32_External_Rela),
04426 (splt->contents + h->plt.offset
04427 + elf_mn10300_plt_reloc_offset (info)));
04428
04429
04430 bfd_put_32 (output_bfd,
04431 (splt->output_section->vma
04432 + splt->output_offset
04433 + h->plt.offset
04434 + elf_mn10300_plt_temp_offset (info)),
04435 sgot->contents + got_offset);
04436
04437
04438 rel.r_offset = (sgot->output_section->vma
04439 + sgot->output_offset
04440 + got_offset);
04441 rel.r_info = ELF32_R_INFO (h->dynindx, R_MN10300_JMP_SLOT);
04442 rel.r_addend = 0;
04443 bfd_elf32_swap_reloca_out (output_bfd, &rel,
04444 (bfd_byte *) ((Elf32_External_Rela *) srel->contents
04445 + plt_index));
04446
04447 if (!h->def_regular)
04448
04449
04450 sym->st_shndx = SHN_UNDEF;
04451 }
04452
04453 if (h->got.offset != (bfd_vma) -1)
04454 {
04455 asection * sgot;
04456 asection * srel;
04457 Elf_Internal_Rela rel;
04458
04459
04460
04461 sgot = bfd_get_section_by_name (dynobj, ".got");
04462 srel = bfd_get_section_by_name (dynobj, ".rela.got");
04463 BFD_ASSERT (sgot != NULL && srel != NULL);
04464
04465 rel.r_offset = (sgot->output_section->vma
04466 + sgot->output_offset
04467 + (h->got.offset &~ 1));
04468
04469
04470
04471
04472
04473
04474 if (info->shared
04475 && (info->symbolic || h->dynindx == -1)
04476 && h->def_regular)
04477 {
04478 rel.r_info = ELF32_R_INFO (0, R_MN10300_RELATIVE);
04479 rel.r_addend = (h->root.u.def.value
04480 + h->root.u.def.section->output_section->vma
04481 + h->root.u.def.section->output_offset);
04482 }
04483 else
04484 {
04485 bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset);
04486 rel.r_info = ELF32_R_INFO (h->dynindx, R_MN10300_GLOB_DAT);
04487 rel.r_addend = 0;
04488 }
04489
04490 bfd_elf32_swap_reloca_out (output_bfd, &rel,
04491 (bfd_byte *) ((Elf32_External_Rela *) srel->contents
04492 + srel->reloc_count));
04493 ++ srel->reloc_count;
04494 }
04495
04496 if (h->needs_copy)
04497 {
04498 asection * s;
04499 Elf_Internal_Rela rel;
04500
04501
04502 BFD_ASSERT (h->dynindx != -1
04503 && (h->root.type == bfd_link_hash_defined
04504 || h->root.type == bfd_link_hash_defweak));
04505
04506 s = bfd_get_section_by_name (h->root.u.def.section->owner,
04507 ".rela.bss");
04508 BFD_ASSERT (s != NULL);
04509
04510 rel.r_offset = (h->root.u.def.value
04511 + h->root.u.def.section->output_section->vma
04512 + h->root.u.def.section->output_offset);
04513 rel.r_info = ELF32_R_INFO (h->dynindx, R_MN10300_COPY);
04514 rel.r_addend = 0;
04515 bfd_elf32_swap_reloca_out (output_bfd, &rel,
04516 (bfd_byte *) ((Elf32_External_Rela *) s->contents
04517 + s->reloc_count));
04518 ++ s->reloc_count;
04519 }
04520
04521
04522 if (strcmp (h->root.root.string, "_DYNAMIC") == 0
04523 || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
04524 sym->st_shndx = SHN_ABS;
04525
04526 return TRUE;
04527 }
04528
04529
04530
04531 static bfd_boolean
04532 _bfd_mn10300_elf_finish_dynamic_sections (output_bfd, info)
04533 bfd * output_bfd;
04534 struct bfd_link_info * info;
04535 {
04536 bfd * dynobj;
04537 asection * sgot;
04538 asection * sdyn;
04539
04540 dynobj = elf_hash_table (info)->dynobj;
04541
04542 sgot = bfd_get_section_by_name (dynobj, ".got.plt");
04543 BFD_ASSERT (sgot != NULL);
04544 sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
04545
04546 if (elf_hash_table (info)->dynamic_sections_created)
04547 {
04548 asection * splt;
04549 Elf32_External_Dyn * dyncon;
04550 Elf32_External_Dyn * dynconend;
04551
04552 BFD_ASSERT (sdyn != NULL);
04553
04554 dyncon = (Elf32_External_Dyn *) sdyn->contents;
04555 dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size);
04556
04557 for (; dyncon < dynconend; dyncon++)
04558 {
04559 Elf_Internal_Dyn dyn;
04560 const char * name;
04561 asection * s;
04562
04563 bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
04564
04565 switch (dyn.d_tag)
04566 {
04567 default:
04568 break;
04569
04570 case DT_PLTGOT:
04571 name = ".got";
04572 goto get_vma;
04573
04574 case DT_JMPREL:
04575 name = ".rela.plt";
04576 get_vma:
04577 s = bfd_get_section_by_name (output_bfd, name);
04578 BFD_ASSERT (s != NULL);
04579 dyn.d_un.d_ptr = s->vma;
04580 bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
04581 break;
04582
04583 case DT_PLTRELSZ:
04584 s = bfd_get_section_by_name (output_bfd, ".rela.plt");
04585 BFD_ASSERT (s != NULL);
04586 dyn.d_un.d_val = s->size;
04587 bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
04588 break;
04589
04590 case DT_RELASZ:
04591
04592
04593
04594
04595
04596
04597
04598
04599
04600 s = bfd_get_section_by_name (output_bfd, ".rela.plt");
04601 if (s != NULL)
04602 dyn.d_un.d_val -= s->size;
04603 bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
04604 break;
04605 }
04606 }
04607
04608
04609 splt = bfd_get_section_by_name (dynobj, ".plt");
04610 if (splt && splt->size > 0)
04611 {
04612 if (info->shared)
04613 {
04614 memcpy (splt->contents, elf_mn10300_pic_plt_entry,
04615 elf_mn10300_sizeof_plt (info));
04616 }
04617 else
04618 {
04619 memcpy (splt->contents, elf_mn10300_plt0_entry, PLT0_ENTRY_SIZE);
04620 bfd_put_32 (output_bfd,
04621 sgot->output_section->vma + sgot->output_offset + 4,
04622 splt->contents + elf_mn10300_plt0_gotid_offset (info));
04623 bfd_put_32 (output_bfd,
04624 sgot->output_section->vma + sgot->output_offset + 8,
04625 splt->contents + elf_mn10300_plt0_linker_offset (info));
04626 }
04627
04628
04629
04630 elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4;
04631 }
04632 }
04633
04634
04635 if (sgot->size > 0)
04636 {
04637 if (sdyn == NULL)
04638 bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents);
04639 else
04640 bfd_put_32 (output_bfd,
04641 sdyn->output_section->vma + sdyn->output_offset,
04642 sgot->contents);
04643 bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 4);
04644 bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 8);
04645 }
04646
04647 elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
04648
04649 return TRUE;
04650 }
04651
04652
04653
04654
04655 static enum elf_reloc_type_class
04656 _bfd_mn10300_elf_reloc_type_class (const Elf_Internal_Rela *rela)
04657 {
04658 switch ((int) ELF32_R_TYPE (rela->r_info))
04659 {
04660 case R_MN10300_RELATIVE:
04661 return reloc_class_relative;
04662 case R_MN10300_JMP_SLOT:
04663 return reloc_class_plt;
04664 case R_MN10300_COPY:
04665 return reloc_class_copy;
04666 default:
04667 return reloc_class_normal;
04668 }
04669 }
04670
04671 #ifndef ELF_ARCH
04672 #define TARGET_LITTLE_SYM bfd_elf32_mn10300_vec
04673 #define TARGET_LITTLE_NAME "elf32-mn10300"
04674 #define ELF_ARCH bfd_arch_mn10300
04675 #define ELF_MACHINE_CODE EM_MN10300
04676 #define ELF_MACHINE_ALT1 EM_CYGNUS_MN10300
04677 #define ELF_MAXPAGESIZE 0x1000
04678 #endif
04679
04680 #define elf_info_to_howto mn10300_info_to_howto
04681 #define elf_info_to_howto_rel 0
04682 #define elf_backend_can_gc_sections 1
04683 #define elf_backend_rela_normal 1
04684 #define elf_backend_check_relocs mn10300_elf_check_relocs
04685 #define elf_backend_gc_mark_hook mn10300_elf_gc_mark_hook
04686 #define elf_backend_relocate_section mn10300_elf_relocate_section
04687 #define bfd_elf32_bfd_relax_section mn10300_elf_relax_section
04688 #define bfd_elf32_bfd_get_relocated_section_contents \
04689 mn10300_elf_get_relocated_section_contents
04690 #define bfd_elf32_bfd_link_hash_table_create \
04691 elf32_mn10300_link_hash_table_create
04692 #define bfd_elf32_bfd_link_hash_table_free \
04693 elf32_mn10300_link_hash_table_free
04694
04695 #ifndef elf_symbol_leading_char
04696 #define elf_symbol_leading_char '_'
04697 #endif
04698
04699
04700 #define elf_backend_final_write_processing \
04701 _bfd_mn10300_elf_final_write_processing
04702 #define elf_backend_object_p _bfd_mn10300_elf_object_p
04703
04704 #define bfd_elf32_bfd_merge_private_bfd_data \
04705 _bfd_mn10300_elf_merge_private_bfd_data
04706
04707 #define elf_backend_can_gc_sections 1
04708 #define elf_backend_create_dynamic_sections \
04709 _bfd_mn10300_elf_create_dynamic_sections
04710 #define elf_backend_adjust_dynamic_symbol \
04711 _bfd_mn10300_elf_adjust_dynamic_symbol
04712 #define elf_backend_size_dynamic_sections \
04713 _bfd_mn10300_elf_size_dynamic_sections
04714 #define elf_backend_finish_dynamic_symbol \
04715 _bfd_mn10300_elf_finish_dynamic_symbol
04716 #define elf_backend_finish_dynamic_sections \
04717 _bfd_mn10300_elf_finish_dynamic_sections
04718
04719 #define elf_backend_reloc_type_class \
04720 _bfd_mn10300_elf_reloc_type_class
04721
04722 #define elf_backend_want_got_plt 1
04723 #define elf_backend_plt_readonly 1
04724 #define elf_backend_want_plt_sym 0
04725 #define elf_backend_got_header_size 12
04726
04727 #include "elf32-target.h"