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
00026
00027
00028 #include "bfd.h"
00029 #include "sysdep.h"
00030 #include "libbfd.h"
00031 #include "elf-bfd.h"
00032 #include "elf/cris.h"
00033
00034
00035 static reloc_howto_type * cris_reloc_type_lookup
00036 PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
00037
00038 static void cris_info_to_howto_rela
00039 PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
00040
00041 static bfd_reloc_status_type cris_elf_pcrel_reloc
00042 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
00043
00044 static bfd_boolean cris_elf_grok_prstatus
00045 PARAMS ((bfd *abfd, Elf_Internal_Note *note));
00046
00047 static bfd_boolean cris_elf_grok_psinfo
00048 PARAMS ((bfd *abfd, Elf_Internal_Note *note));
00049
00050 static bfd_boolean cris_elf_relocate_section
00051 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
00052 Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
00053
00054 static bfd_reloc_status_type cris_final_link_relocate
00055 PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *,
00056 Elf_Internal_Rela *, bfd_vma));
00057
00058 static bfd_boolean cris_elf_gc_sweep_hook
00059 PARAMS ((bfd *, struct bfd_link_info *, asection *,
00060 const Elf_Internal_Rela *));
00061
00062 static asection * cris_elf_gc_mark_hook
00063 PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,
00064 struct elf_link_hash_entry *, Elf_Internal_Sym *));
00065
00066 static bfd_boolean cris_elf_object_p PARAMS ((bfd *));
00067
00068 static void cris_elf_final_write_processing PARAMS ((bfd *, bfd_boolean));
00069
00070 static bfd_boolean cris_elf_set_mach_from_flags
00071 PARAMS ((bfd *, unsigned long int));
00072
00073 static bfd_boolean cris_elf_print_private_bfd_data PARAMS ((bfd *, PTR));
00074
00075 static bfd_boolean cris_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *));
00076 static bfd_boolean cris_elf_copy_private_bfd_data PARAMS ((bfd *, bfd *));
00077
00078 struct elf_cris_link_hash_entry;
00079 static bfd_boolean elf_cris_discard_excess_dso_dynamics
00080 PARAMS ((struct elf_cris_link_hash_entry *, PTR));
00081 static bfd_boolean elf_cris_discard_excess_program_dynamics
00082 PARAMS ((struct elf_cris_link_hash_entry *, PTR));
00083 static bfd_boolean elf_cris_adjust_gotplt_to_got
00084 PARAMS ((struct elf_cris_link_hash_entry *, PTR));
00085 static bfd_boolean elf_cris_try_fold_plt_to_got
00086 PARAMS ((struct elf_cris_link_hash_entry *, PTR));
00087 static struct bfd_hash_entry *elf_cris_link_hash_newfunc
00088 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
00089 static struct bfd_link_hash_table *elf_cris_link_hash_table_create
00090 PARAMS ((bfd *));
00091 static bfd_boolean elf_cris_adjust_dynamic_symbol
00092 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
00093 static bfd_boolean cris_elf_check_relocs
00094 PARAMS ((bfd *, struct bfd_link_info *, asection *,
00095 const Elf_Internal_Rela *));
00096
00097 static bfd_boolean elf_cris_size_dynamic_sections
00098 PARAMS ((bfd *, struct bfd_link_info *));
00099 static bfd_boolean elf_cris_finish_dynamic_symbol
00100 PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
00101 Elf_Internal_Sym *));
00102 static bfd_boolean elf_cris_finish_dynamic_sections
00103 PARAMS ((bfd *, struct bfd_link_info *));
00104 static void elf_cris_hide_symbol
00105 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean));
00106 static enum elf_reloc_type_class elf_cris_reloc_type_class
00107 PARAMS ((const Elf_Internal_Rela *));
00108
00109 static reloc_howto_type cris_elf_howto_table [] =
00110 {
00111
00112 HOWTO (R_CRIS_NONE,
00113 0,
00114 2,
00115 32,
00116 FALSE,
00117 0,
00118 complain_overflow_bitfield,
00119 bfd_elf_generic_reloc,
00120 "R_CRIS_NONE",
00121 FALSE,
00122 0,
00123 0,
00124 FALSE),
00125
00126
00127 HOWTO (R_CRIS_8,
00128 0,
00129 0,
00130 8,
00131 FALSE,
00132 0,
00133 complain_overflow_bitfield,
00134 bfd_elf_generic_reloc,
00135 "R_CRIS_8",
00136 FALSE,
00137 0x0000,
00138 0x00ff,
00139 FALSE),
00140
00141
00142 HOWTO (R_CRIS_16,
00143 0,
00144 1,
00145 16,
00146 FALSE,
00147 0,
00148 complain_overflow_bitfield,
00149 bfd_elf_generic_reloc,
00150 "R_CRIS_16",
00151 FALSE,
00152 0x00000000,
00153 0x0000ffff,
00154 FALSE),
00155
00156
00157 HOWTO (R_CRIS_32,
00158 0,
00159 2,
00160 32,
00161 FALSE,
00162 0,
00163 complain_overflow_bitfield,
00164 bfd_elf_generic_reloc,
00165 "R_CRIS_32",
00166 FALSE,
00167 0x00000000,
00168 0xffffffff,
00169 FALSE),
00170
00171
00172 HOWTO (R_CRIS_8_PCREL,
00173 0,
00174 0,
00175 8,
00176 TRUE,
00177 0,
00178 complain_overflow_bitfield,
00179 cris_elf_pcrel_reloc,
00180 "R_CRIS_8_PCREL",
00181 FALSE,
00182 0x0000,
00183 0x00ff,
00184 TRUE),
00185
00186
00187 HOWTO (R_CRIS_16_PCREL,
00188 0,
00189 1,
00190 16,
00191 TRUE,
00192 0,
00193 complain_overflow_bitfield,
00194 cris_elf_pcrel_reloc,
00195 "R_CRIS_16_PCREL",
00196 FALSE,
00197 0x00000000,
00198 0x0000ffff,
00199 TRUE),
00200
00201
00202 HOWTO (R_CRIS_32_PCREL,
00203 0,
00204 2,
00205 32,
00206 TRUE,
00207 0,
00208 complain_overflow_bitfield,
00209 cris_elf_pcrel_reloc,
00210 "R_CRIS_32_PCREL",
00211 FALSE,
00212 0x00000000,
00213 0xffffffff,
00214 TRUE),
00215
00216
00217 HOWTO (R_CRIS_GNU_VTINHERIT,
00218 0,
00219 2,
00220 0,
00221 FALSE,
00222 0,
00223 complain_overflow_dont,
00224 NULL,
00225 "R_CRIS_GNU_VTINHERIT",
00226 FALSE,
00227 0,
00228 0,
00229 FALSE),
00230
00231
00232 HOWTO (R_CRIS_GNU_VTENTRY,
00233 0,
00234 2,
00235 0,
00236 FALSE,
00237 0,
00238 complain_overflow_dont,
00239 _bfd_elf_rel_vtable_reloc_fn,
00240 "R_CRIS_GNU_VTENTRY",
00241 FALSE,
00242 0,
00243 0,
00244 FALSE),
00245
00246
00247
00248
00249
00250
00251 HOWTO (R_CRIS_COPY,
00252 0,
00253 2,
00254 32,
00255 FALSE,
00256 0,
00257 complain_overflow_bitfield,
00258 bfd_elf_generic_reloc,
00259 "R_CRIS_COPY",
00260 FALSE,
00261 0,
00262 0,
00263 FALSE),
00264
00265
00266 HOWTO (R_CRIS_GLOB_DAT,
00267 0,
00268 2,
00269 32,
00270 FALSE,
00271 0,
00272 complain_overflow_bitfield,
00273 bfd_elf_generic_reloc,
00274 "R_CRIS_GLOB_DAT",
00275 FALSE,
00276 0,
00277 0xffffffff,
00278 FALSE),
00279
00280
00281 HOWTO (R_CRIS_JUMP_SLOT,
00282 0,
00283 2,
00284 32,
00285 FALSE,
00286 0,
00287 complain_overflow_bitfield,
00288 bfd_elf_generic_reloc,
00289 "R_CRIS_JUMP_SLOT",
00290 FALSE,
00291 0,
00292 0,
00293 FALSE),
00294
00295
00296
00297
00298 HOWTO (R_CRIS_RELATIVE,
00299 0,
00300 2,
00301 32,
00302 FALSE,
00303 0,
00304 complain_overflow_bitfield,
00305 bfd_elf_generic_reloc,
00306 "R_CRIS_RELATIVE",
00307 FALSE,
00308 0,
00309 0xffffffff,
00310 FALSE),
00311
00312
00313 HOWTO (R_CRIS_16_GOT,
00314 0,
00315 1,
00316 16,
00317 FALSE,
00318 0,
00319 complain_overflow_bitfield,
00320 bfd_elf_generic_reloc,
00321 "R_CRIS_16_GOT",
00322 FALSE,
00323 0,
00324 0xffff,
00325 FALSE),
00326
00327 HOWTO (R_CRIS_32_GOT,
00328 0,
00329 2,
00330 32,
00331 FALSE,
00332 0,
00333 complain_overflow_bitfield,
00334 bfd_elf_generic_reloc,
00335 "R_CRIS_32_GOT",
00336 FALSE,
00337 0,
00338 0xffffffff,
00339 FALSE),
00340
00341
00342
00343 HOWTO (R_CRIS_16_GOTPLT,
00344 0,
00345 1,
00346 16,
00347 FALSE,
00348 0,
00349 complain_overflow_bitfield,
00350 bfd_elf_generic_reloc,
00351 "R_CRIS_16_GOTPLT",
00352 FALSE,
00353 0,
00354 0xffff,
00355 FALSE),
00356
00357 HOWTO (R_CRIS_32_GOTPLT,
00358 0,
00359 2,
00360 32,
00361 FALSE,
00362 0,
00363 complain_overflow_bitfield,
00364 bfd_elf_generic_reloc,
00365 "R_CRIS_32_GOTPLT",
00366 FALSE,
00367 0,
00368 0xffffffff,
00369 FALSE),
00370
00371
00372
00373 HOWTO (R_CRIS_32_GOTREL,
00374 0,
00375 2,
00376 32,
00377 FALSE,
00378 0,
00379 complain_overflow_bitfield,
00380 bfd_elf_generic_reloc,
00381 "R_CRIS_32_GOTREL",
00382 FALSE,
00383 0,
00384 0xffffffff,
00385 FALSE),
00386
00387
00388
00389 HOWTO (R_CRIS_32_PLT_GOTREL,
00390 0,
00391 2,
00392 32,
00393 FALSE,
00394 0,
00395 complain_overflow_bitfield,
00396 bfd_elf_generic_reloc,
00397 "R_CRIS_32_PLT_GOTREL",
00398 FALSE,
00399 0,
00400 0xffffffff,
00401 FALSE),
00402
00403
00404
00405
00406 HOWTO (R_CRIS_32_PLT_PCREL,
00407 0,
00408 2,
00409 32,
00410 TRUE,
00411 0,
00412 complain_overflow_bitfield,
00413 cris_elf_pcrel_reloc,
00414 "R_CRIS_32_PLT_PCREL",
00415 FALSE,
00416 0,
00417 0xffffffff,
00418 TRUE)
00419 };
00420
00421
00422
00423 struct cris_reloc_map
00424 {
00425 bfd_reloc_code_real_type bfd_reloc_val;
00426 unsigned int cris_reloc_val;
00427 };
00428
00429 static const struct cris_reloc_map cris_reloc_map [] =
00430 {
00431 { BFD_RELOC_NONE, R_CRIS_NONE },
00432 { BFD_RELOC_8, R_CRIS_8 },
00433 { BFD_RELOC_16, R_CRIS_16 },
00434 { BFD_RELOC_32, R_CRIS_32 },
00435 { BFD_RELOC_8_PCREL, R_CRIS_8_PCREL },
00436 { BFD_RELOC_16_PCREL, R_CRIS_16_PCREL },
00437 { BFD_RELOC_32_PCREL, R_CRIS_32_PCREL },
00438 { BFD_RELOC_VTABLE_INHERIT, R_CRIS_GNU_VTINHERIT },
00439 { BFD_RELOC_VTABLE_ENTRY, R_CRIS_GNU_VTENTRY },
00440 { BFD_RELOC_CRIS_COPY, R_CRIS_COPY },
00441 { BFD_RELOC_CRIS_GLOB_DAT, R_CRIS_GLOB_DAT },
00442 { BFD_RELOC_CRIS_JUMP_SLOT, R_CRIS_JUMP_SLOT },
00443 { BFD_RELOC_CRIS_RELATIVE, R_CRIS_RELATIVE },
00444 { BFD_RELOC_CRIS_16_GOT, R_CRIS_16_GOT },
00445 { BFD_RELOC_CRIS_32_GOT, R_CRIS_32_GOT },
00446 { BFD_RELOC_CRIS_16_GOTPLT, R_CRIS_16_GOTPLT },
00447 { BFD_RELOC_CRIS_32_GOTPLT, R_CRIS_32_GOTPLT },
00448 { BFD_RELOC_CRIS_32_GOTREL, R_CRIS_32_GOTREL },
00449 { BFD_RELOC_CRIS_32_PLT_GOTREL, R_CRIS_32_PLT_GOTREL },
00450 { BFD_RELOC_CRIS_32_PLT_PCREL, R_CRIS_32_PLT_PCREL }
00451 };
00452
00453 static reloc_howto_type *
00454 cris_reloc_type_lookup (abfd, code)
00455 bfd * abfd ATTRIBUTE_UNUSED;
00456 bfd_reloc_code_real_type code;
00457 {
00458 unsigned int i;
00459
00460 for (i = 0; i < sizeof (cris_reloc_map) / sizeof (cris_reloc_map[0]); i++)
00461 if (cris_reloc_map [i].bfd_reloc_val == code)
00462 return & cris_elf_howto_table [cris_reloc_map[i].cris_reloc_val];
00463
00464 return NULL;
00465 }
00466
00467
00468
00469 static void
00470 cris_info_to_howto_rela (abfd, cache_ptr, dst)
00471 bfd * abfd ATTRIBUTE_UNUSED;
00472 arelent * cache_ptr;
00473 Elf_Internal_Rela * dst;
00474 {
00475 unsigned int r_type;
00476
00477 r_type = ELF32_R_TYPE (dst->r_info);
00478 BFD_ASSERT (r_type < (unsigned int) R_CRIS_max);
00479 cache_ptr->howto = & cris_elf_howto_table [r_type];
00480 }
00481
00482 bfd_reloc_status_type
00483 cris_elf_pcrel_reloc (abfd, reloc_entry, symbol, data, input_section,
00484 output_bfd, error_message)
00485 bfd *abfd ATTRIBUTE_UNUSED;
00486 arelent *reloc_entry;
00487 asymbol *symbol;
00488 PTR data ATTRIBUTE_UNUSED;
00489 asection *input_section;
00490 bfd *output_bfd;
00491 char **error_message ATTRIBUTE_UNUSED;
00492 {
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502 if (output_bfd == (bfd *) NULL)
00503 reloc_entry->addend -= 1 << reloc_entry->howto->size;
00504
00505 return
00506 bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
00507 input_section, output_bfd, error_message);
00508 }
00509
00510
00511
00512
00513
00514
00515 static bfd_boolean
00516 cris_elf_grok_prstatus (abfd, note)
00517 bfd *abfd;
00518 Elf_Internal_Note *note;
00519 {
00520 int offset;
00521 size_t size;
00522
00523 if (bfd_get_mach (abfd) == bfd_mach_cris_v32)
00524 switch (note->descsz)
00525 {
00526 default:
00527 return FALSE;
00528
00529 case 202:
00530
00531 elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
00532
00533
00534 elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 22);
00535
00536
00537 offset = 70;
00538 size = 128;
00539
00540 break;
00541 }
00542 else
00543 switch (note->descsz)
00544 {
00545 default:
00546 return FALSE;
00547
00548 case 214:
00549
00550 elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
00551
00552
00553 elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 22);
00554
00555
00556 offset = 70;
00557 size = 140;
00558
00559 break;
00560 }
00561
00562
00563 return _bfd_elfcore_make_pseudosection (abfd, ".reg",
00564 size, note->descpos + offset);
00565 }
00566
00567 static bfd_boolean
00568 cris_elf_grok_psinfo (abfd, note)
00569 bfd *abfd;
00570 Elf_Internal_Note *note;
00571 {
00572 if (bfd_get_mach (abfd) == bfd_mach_cris_v32)
00573 switch (note->descsz)
00574 {
00575 default:
00576 return FALSE;
00577
00578 case 124:
00579 elf_tdata (abfd)->core_program
00580 = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
00581 elf_tdata (abfd)->core_command
00582 = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
00583 }
00584 else
00585 switch (note->descsz)
00586 {
00587 default:
00588 return FALSE;
00589
00590 case 124:
00591 elf_tdata (abfd)->core_program
00592 = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
00593 elf_tdata (abfd)->core_command
00594 = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
00595 }
00596
00597
00598
00599
00600
00601 {
00602 char *command = elf_tdata (abfd)->core_command;
00603 int n = strlen (command);
00604
00605 if (0 < n && command[n - 1] == ' ')
00606 command[n - 1] = '\0';
00607 }
00608
00609 return TRUE;
00610 }
00611
00612
00613
00614
00615 #define ELF_DYNAMIC_INTERPRETER "/lib/ld.so.1"
00616
00617
00618
00619 #define PLT_ENTRY_SIZE 20
00620 #define PLT_ENTRY_SIZE_V32 26
00621
00622
00623
00624 static const bfd_byte elf_cris_plt0_entry[PLT_ENTRY_SIZE] =
00625 {
00626 0xfc, 0xe1,
00627 0x7e, 0x7e,
00628 0x7f, 0x0d,
00629 0, 0, 0, 0,
00630 0x30, 0x7a,
00631 0x7f, 0x0d,
00632 0, 0, 0, 0,
00633 0x30, 0x09
00634 };
00635
00636 static const bfd_byte elf_cris_plt0_entry_v32[PLT_ENTRY_SIZE_V32] =
00637 {
00638 0x84, 0xe2,
00639 0x6f, 0xfe,
00640 0, 0, 0, 0,
00641 0x7e, 0x7a,
00642 0x3f, 0x7a,
00643 0x04, 0xf2,
00644 0x6f, 0xfa,
00645 0xbf, 0x09,
00646 0xb0, 0x05,
00647 0, 0
00648 };
00649
00650
00651
00652
00653 static const bfd_byte elf_cris_plt_entry[PLT_ENTRY_SIZE] =
00654 {
00655 0x7f, 0x0d,
00656 0, 0, 0, 0,
00657 0x30, 0x09,
00658 0x3f, 0x7e,
00659 0, 0, 0, 0,
00660 0x2f, 0xfe,
00661 0xec, 0xff,
00662 0xff, 0xff
00663 };
00664
00665 static const bfd_byte elf_cris_plt_entry_v32[PLT_ENTRY_SIZE_V32] =
00666 {
00667 0x6f, 0xfe,
00668 0, 0, 0, 0,
00669 0x6f, 0xfa,
00670 0xbf, 0x09,
00671 0xb0, 0x05,
00672 0x3f, 0x7e,
00673 0, 0, 0, 0,
00674 0xbf, 0x0e,
00675 0, 0, 0, 0,
00676 0xb0, 0x05
00677 };
00678
00679
00680
00681 static const bfd_byte elf_cris_pic_plt0_entry[PLT_ENTRY_SIZE] =
00682 {
00683 0xfc, 0xe1, 0x7e, 0x7e,
00684 0x04, 0x01, 0x30, 0x7a,
00685 0x08, 0x01, 0x30, 0x09,
00686 0, 0, 0, 0, 0, 0, 0, 0,
00687 };
00688
00689 static const bfd_byte elf_cris_pic_plt0_entry_v32[PLT_ENTRY_SIZE_V32] =
00690 {
00691 0x84, 0xe2,
00692 0x04, 0x01,
00693 0x7e, 0x7a,
00694 0x3f, 0x7a,
00695 0x04, 0xf2,
00696 0x6f, 0xfa,
00697 0xbf, 0x09,
00698 0xb0, 0x05,
00699 0, 0,
00700 0, 0, 0, 0,
00701 0, 0, 0, 0
00702 };
00703
00704
00705
00706 static const bfd_byte elf_cris_pic_plt_entry[PLT_ENTRY_SIZE] =
00707 {
00708 0x6f, 0x0d,
00709 0, 0, 0, 0,
00710 0x30, 0x09,
00711 0x3f, 0x7e,
00712 0, 0, 0, 0,
00713 0x2f, 0xfe,
00714 0xec, 0xff,
00715 0xff, 0xff
00716 };
00717
00718 static const bfd_byte elf_cris_pic_plt_entry_v32[PLT_ENTRY_SIZE_V32] =
00719 {
00720 0x6f, 0x0d,
00721 0, 0, 0, 0,
00722 0x6f, 0xfa,
00723 0xbf, 0x09,
00724 0xb0, 0x05,
00725 0x3f, 0x7e,
00726 0, 0, 0, 0,
00727 0xbf, 0x0e,
00728 0, 0, 0, 0,
00729 0xb0, 0x05
00730 };
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746 struct elf_cris_pcrel_relocs_copied
00747 {
00748
00749 struct elf_cris_pcrel_relocs_copied *next;
00750
00751 asection *section;
00752
00753 bfd_size_type count;
00754 };
00755
00756
00757
00758 struct elf_cris_link_hash_entry
00759 {
00760 struct elf_link_hash_entry root;
00761
00762
00763 struct elf_cris_pcrel_relocs_copied *pcrel_relocs_copied;
00764
00765
00766
00767
00768
00769
00770 bfd_signed_vma gotplt_refcount;
00771
00772
00773
00774
00775
00776 bfd_size_type gotplt_offset;
00777 };
00778
00779
00780
00781 struct elf_cris_link_hash_table
00782 {
00783 struct elf_link_hash_table root;
00784
00785
00786
00787
00788 bfd_size_type next_gotplt_entry;
00789 };
00790
00791
00792
00793 #define elf_cris_link_hash_traverse(table, func, info) \
00794 (elf_link_hash_traverse \
00795 (&(table)->root, \
00796 (bfd_boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \
00797 (info)))
00798
00799
00800
00801 #define elf_cris_hash_table(p) \
00802 ((struct elf_cris_link_hash_table *) (p)->hash)
00803
00804
00805
00806 static struct bfd_hash_entry *
00807 elf_cris_link_hash_newfunc (entry, table, string)
00808 struct bfd_hash_entry *entry;
00809 struct bfd_hash_table *table;
00810 const char *string;
00811 {
00812 struct elf_cris_link_hash_entry *ret =
00813 (struct elf_cris_link_hash_entry *) entry;
00814
00815
00816
00817 if (ret == (struct elf_cris_link_hash_entry *) NULL)
00818 ret = ((struct elf_cris_link_hash_entry *)
00819 bfd_hash_allocate (table,
00820 sizeof (struct elf_cris_link_hash_entry)));
00821 if (ret == (struct elf_cris_link_hash_entry *) NULL)
00822 return (struct bfd_hash_entry *) ret;
00823
00824
00825 ret = ((struct elf_cris_link_hash_entry *)
00826 _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,
00827 table, string));
00828 if (ret != (struct elf_cris_link_hash_entry *) NULL)
00829 {
00830 ret->pcrel_relocs_copied = NULL;
00831 ret->gotplt_refcount = 0;
00832 ret->gotplt_offset = 0;
00833 }
00834
00835 return (struct bfd_hash_entry *) ret;
00836 }
00837
00838
00839
00840 static struct bfd_link_hash_table *
00841 elf_cris_link_hash_table_create (abfd)
00842 bfd *abfd;
00843 {
00844 struct elf_cris_link_hash_table *ret;
00845 bfd_size_type amt = sizeof (struct elf_cris_link_hash_table);
00846
00847 ret = ((struct elf_cris_link_hash_table *) bfd_malloc (amt));
00848 if (ret == (struct elf_cris_link_hash_table *) NULL)
00849 return NULL;
00850
00851 if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
00852 elf_cris_link_hash_newfunc))
00853 {
00854 free (ret);
00855 return NULL;
00856 }
00857
00858
00859
00860 ret->next_gotplt_entry = 12;
00861
00862 return &ret->root.root;
00863 }
00864
00865
00866
00867
00868 static bfd_reloc_status_type
00869 cris_final_link_relocate (howto, input_bfd, input_section, contents, rel,
00870 relocation)
00871 reloc_howto_type * howto;
00872 bfd * input_bfd;
00873 asection * input_section;
00874 bfd_byte * contents;
00875 Elf_Internal_Rela * rel;
00876 bfd_vma relocation;
00877 {
00878 bfd_reloc_status_type r;
00879
00880
00881
00882
00883 switch (ELF32_R_TYPE (rel->r_info))
00884 {
00885
00886 case R_CRIS_16_GOTPLT:
00887 case R_CRIS_16_GOT:
00888 if ((bfd_signed_vma) relocation < 0)
00889 return bfd_reloc_overflow;
00890 break;
00891
00892 case R_CRIS_32_PLT_PCREL:
00893 case R_CRIS_32_PCREL:
00894 relocation -= 2;
00895
00896 case R_CRIS_8_PCREL:
00897 case R_CRIS_16_PCREL:
00898 relocation -= 2;
00899 break;
00900
00901 default:
00902 break;
00903 }
00904
00905 r = _bfd_final_link_relocate (howto, input_bfd, input_section,
00906 contents, rel->r_offset,
00907 relocation, rel->r_addend);
00908 return r;
00909 }
00910
00911
00912
00913
00914 static bfd_boolean
00915 cris_elf_relocate_section (output_bfd, info, input_bfd, input_section,
00916 contents, relocs, local_syms, local_sections)
00917 bfd *output_bfd ATTRIBUTE_UNUSED;
00918 struct bfd_link_info *info;
00919 bfd *input_bfd;
00920 asection *input_section;
00921 bfd_byte *contents;
00922 Elf_Internal_Rela *relocs;
00923 Elf_Internal_Sym *local_syms;
00924 asection **local_sections;
00925 {
00926 bfd *dynobj;
00927 Elf_Internal_Shdr *symtab_hdr;
00928 struct elf_link_hash_entry **sym_hashes;
00929 bfd_vma *local_got_offsets;
00930 asection *sgot;
00931 asection *splt;
00932 asection *sreloc;
00933 Elf_Internal_Rela *rel;
00934 Elf_Internal_Rela *relend;
00935
00936 if (info->relocatable)
00937 return TRUE;
00938
00939 dynobj = elf_hash_table (info)->dynobj;
00940 local_got_offsets = elf_local_got_offsets (input_bfd);
00941 symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
00942 sym_hashes = elf_sym_hashes (input_bfd);
00943 relend = relocs + input_section->reloc_count;
00944
00945 sgot = NULL;
00946 splt = NULL;
00947 sreloc = NULL;
00948
00949 if (dynobj != NULL)
00950 {
00951 splt = bfd_get_section_by_name (dynobj, ".plt");
00952 sgot = bfd_get_section_by_name (dynobj, ".got");
00953 }
00954
00955 for (rel = relocs; rel < relend; rel ++)
00956 {
00957 reloc_howto_type *howto;
00958 unsigned long r_symndx;
00959 Elf_Internal_Sym *sym;
00960 asection *sec;
00961 struct elf_link_hash_entry *h;
00962 bfd_vma relocation;
00963 bfd_reloc_status_type r;
00964 const char *symname = NULL;
00965 int r_type;
00966
00967 r_type = ELF32_R_TYPE (rel->r_info);
00968
00969 if ( r_type == R_CRIS_GNU_VTINHERIT
00970 || r_type == R_CRIS_GNU_VTENTRY)
00971 continue;
00972
00973
00974 r_symndx = ELF32_R_SYM (rel->r_info);
00975 howto = cris_elf_howto_table + r_type;
00976 h = NULL;
00977 sym = NULL;
00978 sec = NULL;
00979
00980 if (r_symndx < symtab_hdr->sh_info)
00981 {
00982 sym = local_syms + r_symndx;
00983 sec = local_sections [r_symndx];
00984 relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
00985
00986 symname = (bfd_elf_string_from_elf_section
00987 (input_bfd, symtab_hdr->sh_link, sym->st_name));
00988 if (symname == NULL)
00989 symname = bfd_section_name (input_bfd, sec);
00990 }
00991 else
00992 {
00993 bfd_boolean warned;
00994 bfd_boolean unresolved_reloc;
00995
00996 RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
00997 r_symndx, symtab_hdr, sym_hashes,
00998 h, sec, relocation,
00999 unresolved_reloc, warned);
01000
01001 if (unresolved_reloc
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016 && (sec->owner->flags & DYNAMIC) != 0)
01017 relocation = 0;
01018
01019 else if (h->root.type == bfd_link_hash_defined
01020 || h->root.type == bfd_link_hash_defweak)
01021 {
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040 if (info->shared
01041 && ((! info->symbolic && h->dynindx != -1)
01042 || !h->def_regular)
01043 && (input_section->flags & SEC_ALLOC) != 0
01044 && (r_type == R_CRIS_8
01045 || r_type == R_CRIS_16
01046 || r_type == R_CRIS_32
01047 || r_type == R_CRIS_8_PCREL
01048 || r_type == R_CRIS_16_PCREL
01049 || r_type == R_CRIS_32_PCREL))
01050 relocation = 0;
01051 else if (unresolved_reloc)
01052 {
01053 _bfd_error_handler
01054 (_("%B, section %A: unresolvable relocation %s against symbol `%s'"),
01055 input_bfd,
01056 input_section,
01057 cris_elf_howto_table[r_type].name,
01058 symname);
01059 bfd_set_error (bfd_error_bad_value);
01060 return FALSE;
01061 }
01062 }
01063 }
01064
01065 switch (r_type)
01066 {
01067 case R_CRIS_16_GOTPLT:
01068 case R_CRIS_32_GOTPLT:
01069
01070
01071
01072
01073
01074 if (h != NULL
01075 && ((struct elf_cris_link_hash_entry *) h)->gotplt_offset != 0)
01076 {
01077 asection *sgotplt
01078 = bfd_get_section_by_name (dynobj, ".got.plt");
01079 bfd_vma got_offset;
01080
01081 BFD_ASSERT (h->dynindx != -1);
01082 BFD_ASSERT (sgotplt != NULL);
01083
01084 got_offset
01085 = ((struct elf_cris_link_hash_entry *) h)->gotplt_offset;
01086
01087 relocation = got_offset;
01088 break;
01089 }
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100 if (h != NULL
01101 && (h->got.offset == (bfd_vma) -1
01102 || (!info->shared
01103 && !(h->def_regular
01104 || (!h->def_dynamic
01105 && h->root.type == bfd_link_hash_undefweak)))))
01106 {
01107 (*_bfd_error_handler)
01108 ((h->got.offset == (bfd_vma) -1)
01109 ? _("%B, section %A: No PLT nor GOT for relocation %s"
01110 " against symbol `%s'")
01111 : _("%B, section %A: No PLT for relocation %s"
01112 " against symbol `%s'"),
01113 input_bfd,
01114 input_section,
01115 cris_elf_howto_table[r_type].name,
01116 (symname != NULL && symname[0] != '\0'
01117 ? symname : _("[whose name is lost]")));
01118
01119
01120
01121
01122 bfd_set_error (bfd_error_bad_value);
01123 return FALSE;
01124 }
01125
01126
01127
01128
01129 case R_CRIS_16_GOT:
01130 case R_CRIS_32_GOT:
01131 {
01132 bfd_vma off;
01133
01134
01135
01136
01137
01138 if (h != NULL)
01139 {
01140 off = h->got.offset;
01141 BFD_ASSERT (off != (bfd_vma) -1);
01142
01143 if (!elf_hash_table (info)->dynamic_sections_created
01144 || (! info->shared
01145 && (h->def_regular
01146 || h->type == STT_FUNC
01147 || h->needs_plt))
01148 || (info->shared
01149 && (info->symbolic || h->dynindx == -1)
01150 && h->def_regular))
01151 {
01152
01153
01154
01155
01156 BFD_ASSERT (!elf_hash_table (info)->dynamic_sections_created
01157 || info->shared
01158 || h->def_regular
01159 || h->type == STT_FUNC
01160 || h->needs_plt
01161 || h->root.type == bfd_link_hash_undefweak);
01162
01163
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173
01174
01175
01176
01177 if ((off & 1) != 0)
01178 off &= ~1;
01179 else
01180 {
01181 bfd_put_32 (output_bfd, relocation,
01182 sgot->contents + off);
01183 h->got.offset |= 1;
01184 }
01185 }
01186 }
01187 else
01188 {
01189 BFD_ASSERT (local_got_offsets != NULL
01190 && local_got_offsets[r_symndx] != (bfd_vma) -1);
01191
01192 off = local_got_offsets[r_symndx];
01193
01194
01195
01196
01197 if ((off & 1) != 0)
01198 off &= ~1;
01199 else
01200 {
01201 bfd_put_32 (output_bfd, relocation, sgot->contents + off);
01202
01203 if (info->shared)
01204 {
01205 asection *s;
01206 Elf_Internal_Rela outrel;
01207 bfd_byte *loc;
01208
01209 s = bfd_get_section_by_name (dynobj, ".rela.got");
01210 BFD_ASSERT (s != NULL);
01211
01212 outrel.r_offset = (sgot->output_section->vma
01213 + sgot->output_offset
01214 + off);
01215 outrel.r_info = ELF32_R_INFO (0, R_CRIS_RELATIVE);
01216 outrel.r_addend = relocation;
01217 loc = s->contents;
01218 loc += s->reloc_count++ * sizeof (Elf32_External_Rela);
01219 bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
01220 }
01221
01222 local_got_offsets[r_symndx] |= 1;
01223 }
01224 }
01225
01226 relocation = sgot->output_offset + off;
01227 if (rel->r_addend != 0)
01228 {
01229
01230
01231
01232
01233 if (h == NULL)
01234 (*_bfd_error_handler)
01235 (_("%B, section %A: relocation %s with non-zero addend %d"
01236 " against local symbol"),
01237 input_bfd,
01238 input_section,
01239 cris_elf_howto_table[r_type].name,
01240 rel->r_addend);
01241 else
01242 (*_bfd_error_handler)
01243 (_("%B, section %A: relocation %s with non-zero addend %d"
01244 " against symbol `%s'"),
01245 input_bfd,
01246 input_section,
01247 cris_elf_howto_table[r_type].name,
01248 rel->r_addend,
01249 symname[0] != '\0' ? symname : _("[whose name is lost]"));
01250
01251 bfd_set_error (bfd_error_bad_value);
01252 return FALSE;
01253 }
01254 }
01255 break;
01256
01257 case R_CRIS_32_GOTREL:
01258
01259
01260
01261 if (h != NULL
01262 && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
01263 && !(!info->shared
01264 && (h->def_regular
01265 || (!h->def_dynamic
01266 && h->root.type == bfd_link_hash_undefweak))))
01267 {
01268 (*_bfd_error_handler)
01269 (_("%B, section %A: relocation %s is"
01270 " not allowed for global symbol: `%s'"),
01271 input_bfd,
01272 input_section,
01273 cris_elf_howto_table[r_type].name,
01274 symname);
01275 bfd_set_error (bfd_error_bad_value);
01276 return FALSE;
01277 }
01278
01279
01280
01281
01282 if (sgot == NULL)
01283 {
01284 (*_bfd_error_handler)
01285 (_("%B, section %A: relocation %s with no GOT created"),
01286 input_bfd,
01287 input_section,
01288 cris_elf_howto_table[r_type].name);
01289 bfd_set_error (bfd_error_bad_value);
01290 return FALSE;
01291 }
01292
01293
01294
01295
01296
01297
01298 relocation -= sgot->output_section->vma;
01299 break;
01300
01301 case R_CRIS_32_PLT_PCREL:
01302
01303
01304
01305
01306
01307 if (h == NULL || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
01308 break;
01309
01310 if (h->plt.offset == (bfd_vma) -1
01311 || splt == NULL)
01312 {
01313
01314
01315
01316 break;
01317 }
01318
01319 relocation = (splt->output_section->vma
01320 + splt->output_offset
01321 + h->plt.offset);
01322 break;
01323
01324 case R_CRIS_32_PLT_GOTREL:
01325
01326
01327
01328 relocation -= sgot->output_section->vma;
01329
01330
01331
01332 if (h == NULL || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
01333 break;
01334
01335 if (h->plt.offset == (bfd_vma) -1
01336 || splt == NULL)
01337 {
01338
01339
01340
01341 break;
01342 }
01343
01344 relocation = (splt->output_section->vma
01345 + splt->output_offset
01346 + h->plt.offset
01347 - sgot->output_section->vma);
01348 break;
01349
01350 case R_CRIS_8_PCREL:
01351 case R_CRIS_16_PCREL:
01352 case R_CRIS_32_PCREL:
01353
01354 if (h == NULL || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
01355 break;
01356
01357
01358 case R_CRIS_8:
01359 case R_CRIS_16:
01360 case R_CRIS_32:
01361 if (info->shared
01362 && r_symndx != 0
01363 && (input_section->flags & SEC_ALLOC) != 0
01364 && ((r_type != R_CRIS_8_PCREL
01365 && r_type != R_CRIS_16_PCREL
01366 && r_type != R_CRIS_32_PCREL)
01367 || (!info->symbolic
01368 || !h->def_regular)))
01369 {
01370 Elf_Internal_Rela outrel;
01371 bfd_byte *loc;
01372 bfd_boolean skip, relocate;
01373
01374
01375
01376
01377
01378 if (sreloc == NULL)
01379 {
01380 const char *name;
01381
01382 name = (bfd_elf_string_from_elf_section
01383 (input_bfd,
01384 elf_elfheader (input_bfd)->e_shstrndx,
01385 elf_section_data (input_section)->rel_hdr.sh_name));
01386 if (name == NULL)
01387 return FALSE;
01388
01389 BFD_ASSERT (strncmp (name, ".rela", 5) == 0
01390 && strcmp (bfd_get_section_name (input_bfd,
01391 input_section),
01392 name + 5) == 0);
01393
01394 sreloc = bfd_get_section_by_name (dynobj, name);
01395
01396
01397
01398
01399
01400 if (sreloc == NULL)
01401 {
01402 (*_bfd_error_handler)
01403 (_("%B: Internal inconsistency; no relocation section %s"),
01404 input_bfd,
01405 name);
01406
01407 bfd_set_error (bfd_error_bad_value);
01408 return FALSE;
01409 }
01410 }
01411
01412 skip = FALSE;
01413 relocate = FALSE;
01414
01415 outrel.r_offset =
01416 _bfd_elf_section_offset (output_bfd, info, input_section,
01417 rel->r_offset);
01418 if (outrel.r_offset == (bfd_vma) -1)
01419 skip = TRUE;
01420 else if (outrel.r_offset == (bfd_vma) -2)
01421 skip = TRUE, relocate = TRUE;
01422 outrel.r_offset += (input_section->output_section->vma
01423 + input_section->output_offset);
01424
01425 if (skip)
01426 memset (&outrel, 0, sizeof outrel);
01427
01428
01429 else if (h != NULL
01430 && ((! info->symbolic && h->dynindx != -1)
01431 || !h->def_regular))
01432 {
01433 BFD_ASSERT (h->dynindx != -1);
01434 outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
01435 outrel.r_addend = relocation + rel->r_addend;
01436 }
01437 else
01438 {
01439 if (r_type == R_CRIS_32)
01440 {
01441 relocate = TRUE;
01442 outrel.r_info = ELF32_R_INFO (0, R_CRIS_RELATIVE);
01443 outrel.r_addend = relocation + rel->r_addend;
01444 }
01445 else
01446 {
01447 long indx;
01448
01449 if (bfd_is_abs_section (sec))
01450 indx = 0;
01451 else if (sec == NULL || sec->owner == NULL)
01452 {
01453 bfd_set_error (bfd_error_bad_value);
01454 return FALSE;
01455 }
01456 else
01457 {
01458 asection *osec;
01459
01460 osec = sec->output_section;
01461 indx = elf_section_data (osec)->dynindx;
01462 BFD_ASSERT (indx > 0);
01463 }
01464
01465 outrel.r_info = ELF32_R_INFO (indx, r_type);
01466 outrel.r_addend = relocation + rel->r_addend;
01467 }
01468 }
01469
01470 loc = sreloc->contents;
01471 loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela);
01472 bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
01473
01474
01475
01476
01477 if (!relocate)
01478 continue;
01479 }
01480
01481 break;
01482 }
01483
01484 r = cris_final_link_relocate (howto, input_bfd, input_section,
01485 contents, rel, relocation);
01486
01487 if (r != bfd_reloc_ok)
01488 {
01489 const char * msg = (const char *) NULL;
01490
01491 switch (r)
01492 {
01493 case bfd_reloc_overflow:
01494 r = info->callbacks->reloc_overflow
01495 (info, (h ? &h->root : NULL), symname, howto->name,
01496 (bfd_vma) 0, input_bfd, input_section, rel->r_offset);
01497 break;
01498
01499 case bfd_reloc_undefined:
01500 r = info->callbacks->undefined_symbol
01501 (info, symname, input_bfd, input_section, rel->r_offset,
01502 TRUE);
01503 break;
01504
01505 case bfd_reloc_outofrange:
01506 msg = _("internal error: out of range error");
01507 break;
01508
01509 case bfd_reloc_notsupported:
01510 msg = _("internal error: unsupported relocation error");
01511 break;
01512
01513 case bfd_reloc_dangerous:
01514 msg = _("internal error: dangerous relocation");
01515 break;
01516
01517 default:
01518 msg = _("internal error: unknown error");
01519 break;
01520 }
01521
01522 if (msg)
01523 r = info->callbacks->warning
01524 (info, msg, symname, input_bfd, input_section, rel->r_offset);
01525
01526 if (! r)
01527 return FALSE;
01528 }
01529 }
01530
01531 return TRUE;
01532 }
01533
01534
01535
01536
01537 static bfd_boolean
01538 elf_cris_finish_dynamic_symbol (output_bfd, info, h, sym)
01539 bfd *output_bfd;
01540 struct bfd_link_info *info;
01541 struct elf_link_hash_entry *h;
01542 Elf_Internal_Sym *sym;
01543 {
01544 bfd *dynobj;
01545
01546
01547 int plt_off1 = 2, plt_off2 = 10, plt_off3 = 16;
01548
01549
01550
01551 int plt_off3_value_bias = 4;
01552
01553
01554
01555 int plt_stub_offset = 8;
01556 int plt_entry_size = PLT_ENTRY_SIZE;
01557 const bfd_byte *plt_entry = elf_cris_plt_entry;
01558 const bfd_byte *plt_pic_entry = elf_cris_pic_plt_entry;
01559
01560
01561 if (bfd_get_mach (output_bfd) == bfd_mach_cris_v32)
01562 {
01563 plt_off2 = 14;
01564 plt_off3 = 20;
01565 plt_off3_value_bias = -2;
01566 plt_stub_offset = 12;
01567 plt_entry_size = PLT_ENTRY_SIZE_V32;
01568 plt_entry = elf_cris_plt_entry_v32;
01569 plt_pic_entry = elf_cris_pic_plt_entry_v32;
01570 }
01571
01572 dynobj = elf_hash_table (info)->dynobj;
01573
01574 if (h->plt.offset != (bfd_vma) -1)
01575 {
01576 asection *splt;
01577 asection *sgotplt;
01578 asection *sgot;
01579 asection *srela;
01580 bfd_vma got_base;
01581
01582 bfd_vma gotplt_offset
01583 = ((struct elf_cris_link_hash_entry *) h)->gotplt_offset;
01584 Elf_Internal_Rela rela;
01585 bfd_byte *loc;
01586 bfd_boolean has_gotplt = gotplt_offset != 0;
01587
01588
01589
01590
01591
01592
01593
01594 bfd_vma gotplt_index = gotplt_offset/4 - 3;
01595
01596
01597
01598
01599
01600
01601 bfd_vma got_offset
01602 = (has_gotplt
01603 ? gotplt_offset
01604 : h->got.offset + elf_cris_hash_table(info)->next_gotplt_entry);
01605
01606
01607
01608
01609 BFD_ASSERT (h->dynindx != -1);
01610
01611 splt = bfd_get_section_by_name (dynobj, ".plt");
01612 sgot = bfd_get_section_by_name (dynobj, ".got");
01613 sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
01614 srela = bfd_get_section_by_name (dynobj, ".rela.plt");
01615 BFD_ASSERT (splt != NULL && sgotplt != NULL
01616 && (! has_gotplt || srela != NULL));
01617
01618 got_base = sgotplt->output_section->vma + sgotplt->output_offset;
01619
01620
01621 if (! info->shared)
01622 {
01623 memcpy (splt->contents + h->plt.offset, plt_entry,
01624 plt_entry_size);
01625
01626
01627 bfd_put_32 (output_bfd, got_base + got_offset,
01628 splt->contents + h->plt.offset + plt_off1);
01629 }
01630 else
01631 {
01632 memcpy (splt->contents + h->plt.offset, plt_pic_entry,
01633 plt_entry_size);
01634 bfd_put_32 (output_bfd, got_offset,
01635 splt->contents + h->plt.offset + plt_off1);
01636 }
01637
01638
01639
01640 if (has_gotplt)
01641 {
01642
01643 bfd_put_32 (output_bfd,
01644 gotplt_index * sizeof (Elf32_External_Rela),
01645 splt->contents + h->plt.offset + plt_off2);
01646
01647
01648 bfd_put_32 (output_bfd,
01649 - (h->plt.offset + plt_off3 + plt_off3_value_bias),
01650 splt->contents + h->plt.offset + plt_off3);
01651
01652
01653
01654 bfd_put_32 (output_bfd,
01655 (splt->output_section->vma
01656 + splt->output_offset
01657 + h->plt.offset
01658 + plt_stub_offset),
01659 sgotplt->contents + got_offset);
01660
01661
01662 rela.r_offset = (sgotplt->output_section->vma
01663 + sgotplt->output_offset
01664 + got_offset);
01665 rela.r_info = ELF32_R_INFO (h->dynindx, R_CRIS_JUMP_SLOT);
01666 rela.r_addend = 0;
01667 loc = srela->contents + gotplt_index * sizeof (Elf32_External_Rela);
01668 bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
01669 }
01670
01671 if (!h->def_regular)
01672 {
01673
01674
01675 sym->st_shndx = SHN_UNDEF;
01676
01677
01678
01679
01680
01681
01682
01683
01684
01685 if (!h->ref_regular_nonweak)
01686 sym->st_value = 0;
01687 }
01688 }
01689
01690
01691
01692
01693
01694
01695 if (h->got.offset != (bfd_vma) -1
01696 && (info->shared
01697 || (h->dynindx != -1
01698 && h->plt.offset == (bfd_vma) -1
01699 && !h->def_regular
01700 && h->root.type != bfd_link_hash_undefweak)))
01701 {
01702 asection *sgot;
01703 asection *srela;
01704 Elf_Internal_Rela rela;
01705 bfd_byte *loc;
01706 bfd_byte *where;
01707
01708
01709
01710 sgot = bfd_get_section_by_name (dynobj, ".got");
01711 srela = bfd_get_section_by_name (dynobj, ".rela.got");
01712 BFD_ASSERT (sgot != NULL && srela != NULL);
01713
01714 rela.r_offset = (sgot->output_section->vma
01715 + sgot->output_offset
01716 + (h->got.offset &~ (bfd_vma) 1));
01717
01718
01719
01720
01721
01722
01723 where = sgot->contents + (h->got.offset &~ (bfd_vma) 1);
01724 if (! elf_hash_table (info)->dynamic_sections_created
01725 || (info->shared
01726 && (info->symbolic || h->dynindx == -1)
01727 && h->def_regular))
01728 {
01729 rela.r_info = ELF32_R_INFO (0, R_CRIS_RELATIVE);
01730 rela.r_addend = bfd_get_signed_32 (output_bfd, where);
01731 }
01732 else
01733 {
01734 bfd_put_32 (output_bfd, (bfd_vma) 0, where);
01735 rela.r_info = ELF32_R_INFO (h->dynindx, R_CRIS_GLOB_DAT);
01736 rela.r_addend = 0;
01737 }
01738
01739 loc = srela->contents;
01740 loc += srela->reloc_count++ * sizeof (Elf32_External_Rela);
01741 bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
01742 }
01743
01744 if (h->needs_copy)
01745 {
01746 asection *s;
01747 Elf_Internal_Rela rela;
01748 bfd_byte *loc;
01749
01750
01751
01752 BFD_ASSERT (h->dynindx != -1
01753 && (h->root.type == bfd_link_hash_defined
01754 || h->root.type == bfd_link_hash_defweak));
01755
01756 s = bfd_get_section_by_name (h->root.u.def.section->owner,
01757 ".rela.bss");
01758 BFD_ASSERT (s != NULL);
01759
01760 rela.r_offset = (h->root.u.def.value
01761 + h->root.u.def.section->output_section->vma
01762 + h->root.u.def.section->output_offset);
01763 rela.r_info = ELF32_R_INFO (h->dynindx, R_CRIS_COPY);
01764 rela.r_addend = 0;
01765 loc = s->contents + s->reloc_count++ * sizeof (Elf32_External_Rela);
01766 bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
01767 }
01768
01769
01770 if (strcmp (h->root.root.string, "_DYNAMIC") == 0
01771 || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
01772 sym->st_shndx = SHN_ABS;
01773
01774 return TRUE;
01775 }
01776
01777
01778
01779 static bfd_boolean
01780 elf_cris_finish_dynamic_sections (output_bfd, info)
01781 bfd *output_bfd;
01782 struct bfd_link_info *info;
01783 {
01784 bfd *dynobj;
01785 asection *sgot;
01786 asection *sdyn;
01787
01788 dynobj = elf_hash_table (info)->dynobj;
01789
01790 sgot = bfd_get_section_by_name (dynobj, ".got.plt");
01791 BFD_ASSERT (sgot != NULL);
01792 sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
01793
01794 if (elf_hash_table (info)->dynamic_sections_created)
01795 {
01796 asection *splt;
01797 Elf32_External_Dyn *dyncon, *dynconend;
01798
01799 splt = bfd_get_section_by_name (dynobj, ".plt");
01800 BFD_ASSERT (splt != NULL && sdyn != NULL);
01801
01802 dyncon = (Elf32_External_Dyn *) sdyn->contents;
01803 dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size);
01804 for (; dyncon < dynconend; dyncon++)
01805 {
01806 Elf_Internal_Dyn dyn;
01807 asection *s;
01808
01809 bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
01810
01811 switch (dyn.d_tag)
01812 {
01813 default:
01814 break;
01815
01816 case DT_PLTGOT:
01817 s = bfd_get_section_by_name (output_bfd, ".got");
01818 BFD_ASSERT (s != NULL);
01819 dyn.d_un.d_ptr = s->vma;
01820 bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
01821 break;
01822
01823 case DT_JMPREL:
01824
01825
01826 s = bfd_get_section_by_name (output_bfd, ".rela.plt");
01827 dyn.d_un.d_ptr = s != NULL ? s->vma : 0;
01828 bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
01829 break;
01830
01831 case DT_PLTRELSZ:
01832 s = bfd_get_section_by_name (output_bfd, ".rela.plt");
01833 if (s == NULL)
01834 dyn.d_un.d_val = 0;
01835 else
01836 dyn.d_un.d_val = s->size;
01837 bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
01838 break;
01839
01840 case DT_RELASZ:
01841
01842
01843
01844
01845
01846
01847
01848 s = bfd_get_section_by_name (output_bfd, ".rela.plt");
01849 if (s != NULL)
01850 dyn.d_un.d_val -= s->size;
01851 bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
01852 break;
01853 }
01854 }
01855
01856
01857 if (splt->size > 0)
01858 {
01859 if (bfd_get_mach (output_bfd) == bfd_mach_cris_v32)
01860 {
01861 if (info->shared)
01862 memcpy (splt->contents, elf_cris_pic_plt0_entry_v32,
01863 PLT_ENTRY_SIZE_V32);
01864 else
01865 {
01866 memcpy (splt->contents, elf_cris_plt0_entry_v32,
01867 PLT_ENTRY_SIZE_V32);
01868 bfd_put_32 (output_bfd,
01869 sgot->output_section->vma
01870 + sgot->output_offset + 4,
01871 splt->contents + 4);
01872
01873 elf_section_data (splt->output_section)->this_hdr.sh_entsize
01874 = PLT_ENTRY_SIZE_V32;
01875 }
01876 }
01877 else
01878 {
01879 if (info->shared)
01880 memcpy (splt->contents, elf_cris_pic_plt0_entry,
01881 PLT_ENTRY_SIZE);
01882 else
01883 {
01884 memcpy (splt->contents, elf_cris_plt0_entry,
01885 PLT_ENTRY_SIZE);
01886 bfd_put_32 (output_bfd,
01887 sgot->output_section->vma
01888 + sgot->output_offset + 4,
01889 splt->contents + 6);
01890 bfd_put_32 (output_bfd,
01891 sgot->output_section->vma
01892 + sgot->output_offset + 8,
01893 splt->contents + 14);
01894
01895 elf_section_data (splt->output_section)->this_hdr.sh_entsize
01896 = PLT_ENTRY_SIZE;
01897 }
01898 }
01899 }
01900 }
01901
01902
01903 if (sgot->size > 0)
01904 {
01905 if (sdyn == NULL)
01906 bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents);
01907 else
01908 bfd_put_32 (output_bfd,
01909 sdyn->output_section->vma + sdyn->output_offset,
01910 sgot->contents);
01911 bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 4);
01912 bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 8);
01913 }
01914
01915 elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
01916
01917 return TRUE;
01918 }
01919
01920
01921
01922
01923 static asection *
01924 cris_elf_gc_mark_hook (sec, info, rel, h, sym)
01925 asection *sec;
01926 struct bfd_link_info *info ATTRIBUTE_UNUSED;
01927 Elf_Internal_Rela *rel;
01928 struct elf_link_hash_entry *h;
01929 Elf_Internal_Sym *sym;
01930 {
01931 if (h != NULL)
01932 {
01933 switch (ELF32_R_TYPE (rel->r_info))
01934 {
01935 case R_CRIS_GNU_VTINHERIT:
01936 case R_CRIS_GNU_VTENTRY:
01937 break;
01938
01939 default:
01940 switch (h->root.type)
01941 {
01942 case bfd_link_hash_defined:
01943 case bfd_link_hash_defweak:
01944 return h->root.u.def.section;
01945
01946 case bfd_link_hash_common:
01947 return h->root.u.c.p->section;
01948
01949 default:
01950 break;
01951 }
01952 }
01953 }
01954 else
01955 return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
01956
01957 return NULL;
01958 }
01959
01960
01961
01962 static bfd_boolean
01963 cris_elf_gc_sweep_hook (abfd, info, sec, relocs)
01964 bfd *abfd ATTRIBUTE_UNUSED;
01965 struct bfd_link_info *info ATTRIBUTE_UNUSED;
01966 asection *sec ATTRIBUTE_UNUSED;
01967 const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED;
01968 {
01969 Elf_Internal_Shdr *symtab_hdr;
01970 struct elf_link_hash_entry **sym_hashes;
01971 bfd_signed_vma *local_got_refcounts;
01972 const Elf_Internal_Rela *rel, *relend;
01973 bfd *dynobj;
01974 asection *sgot;
01975 asection *srelgot;
01976
01977 dynobj = elf_hash_table (info)->dynobj;
01978 if (dynobj == NULL)
01979 return TRUE;
01980
01981 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
01982 sym_hashes = elf_sym_hashes (abfd);
01983 local_got_refcounts = elf_local_got_refcounts (abfd);
01984
01985 sgot = bfd_get_section_by_name (dynobj, ".got");
01986 srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
01987
01988 relend = relocs + sec->reloc_count;
01989 for (rel = relocs; rel < relend; rel++)
01990 {
01991 unsigned long r_symndx;
01992 struct elf_link_hash_entry *h = NULL;
01993
01994 r_symndx = ELF32_R_SYM (rel->r_info);
01995 if (r_symndx >= symtab_hdr->sh_info)
01996 {
01997 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
01998 while (h->root.type == bfd_link_hash_indirect
01999 || h->root.type == bfd_link_hash_warning)
02000 h = (struct elf_link_hash_entry *) h->root.u.i.link;
02001 }
02002
02003 switch (ELF32_R_TYPE (rel->r_info))
02004 {
02005 case R_CRIS_16_GOT:
02006 case R_CRIS_32_GOT:
02007 if (h != NULL)
02008 {
02009 if (h->got.refcount > 0)
02010 {
02011 --h->got.refcount;
02012 if (h->got.refcount == 0)
02013 {
02014
02015 sgot->size -= 4;
02016 srelgot->size -= sizeof (Elf32_External_Rela);
02017 }
02018 }
02019 break;
02020 }
02021
02022 local_got_reloc:
02023 if (local_got_refcounts != NULL)
02024 {
02025 if (local_got_refcounts[r_symndx] > 0)
02026 {
02027 --local_got_refcounts[r_symndx];
02028 if (local_got_refcounts[r_symndx] == 0)
02029 {
02030
02031 sgot->size -= 4;
02032 if (info->shared)
02033 srelgot->size -= sizeof (Elf32_External_Rela);
02034 }
02035 }
02036 }
02037 break;
02038
02039 case R_CRIS_16_GOTPLT:
02040 case R_CRIS_32_GOTPLT:
02041
02042 if (h == NULL)
02043 goto local_got_reloc;
02044
02045
02046 case R_CRIS_32_PLT_GOTREL:
02047
02048 if (local_got_refcounts != NULL)
02049 local_got_refcounts[-1]--;
02050
02051
02052 case R_CRIS_8_PCREL:
02053 case R_CRIS_16_PCREL:
02054 case R_CRIS_32_PCREL:
02055 case R_CRIS_32_PLT_PCREL:
02056 if (h != NULL)
02057 {
02058 if (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
02059 && h->plt.refcount > 0)
02060 --h->plt.refcount;
02061 }
02062 break;
02063
02064 default:
02065 break;
02066 }
02067 }
02068
02069 return TRUE;
02070 }
02071
02072
02073
02074
02075
02076
02077
02078
02079 static bfd_boolean
02080 elf_cris_adjust_gotplt_to_got (h, p)
02081 struct elf_cris_link_hash_entry *h;
02082 PTR p;
02083 {
02084 struct bfd_link_info *info = (struct bfd_link_info *) p;
02085 bfd *dynobj = elf_hash_table (info)->dynobj;
02086
02087 BFD_ASSERT (dynobj != NULL);
02088
02089 if (h->root.root.type == bfd_link_hash_warning)
02090 h = (struct elf_cris_link_hash_entry *) h->root.root.u.i.link;
02091
02092
02093 if (h->gotplt_refcount <= 0)
02094 return TRUE;
02095
02096 if (h->root.got.refcount > 0)
02097 {
02098
02099
02100
02101 h->root.got.refcount += h->gotplt_refcount;
02102 h->gotplt_refcount = 0;
02103 }
02104 else
02105 {
02106
02107 asection *sgot = bfd_get_section_by_name (dynobj, ".got");
02108 asection *srelgot
02109 = bfd_get_section_by_name (dynobj, ".rela.got");
02110
02111
02112 h->root.got.refcount = h->gotplt_refcount;
02113
02114 h->gotplt_refcount = 0;
02115
02116
02117
02118 BFD_ASSERT (sgot != NULL && srelgot != NULL);
02119
02120
02121 sgot->size += 4;
02122
02123
02124 srelgot->size += sizeof (Elf32_External_Rela);
02125 }
02126
02127 return TRUE;
02128 }
02129
02130
02131
02132
02133
02134
02135
02136
02137
02138
02139
02140
02141
02142
02143
02144
02145
02146
02147
02148
02149
02150
02151
02152
02153
02154 static bfd_boolean
02155 elf_cris_try_fold_plt_to_got (h, p)
02156 struct elf_cris_link_hash_entry *h;
02157 PTR p;
02158 {
02159 struct bfd_link_info *info = (struct bfd_link_info *) p;
02160
02161
02162
02163
02164 if (h->root.got.refcount <= 0 || h->root.plt.refcount <= 0)
02165 return TRUE;
02166
02167
02168 BFD_ASSERT (h->gotplt_refcount <= h->root.plt.refcount);
02169
02170 if (h->gotplt_refcount == h->root.plt.refcount)
02171 {
02172
02173
02174 if (! elf_cris_adjust_gotplt_to_got (h, info))
02175 return FALSE;
02176
02177
02178 h->root.plt.offset = (bfd_vma) -1;
02179 }
02180
02181 return TRUE;
02182 }
02183
02184
02185
02186
02187
02188 static void
02189 elf_cris_hide_symbol (info, h, force_local)
02190 struct bfd_link_info *info;
02191 struct elf_link_hash_entry *h;
02192 bfd_boolean force_local;
02193 {
02194 elf_cris_adjust_gotplt_to_got ((struct elf_cris_link_hash_entry *) h, info);
02195
02196 _bfd_elf_link_hash_hide_symbol (info, h, force_local);
02197 }
02198
02199
02200
02201
02202
02203
02204
02205 static bfd_boolean
02206 elf_cris_adjust_dynamic_symbol (info, h)
02207 struct bfd_link_info *info;
02208 struct elf_link_hash_entry *h;
02209 {
02210 bfd *dynobj;
02211 asection *s;
02212 unsigned int power_of_two;
02213 bfd_size_type plt_entry_size;
02214
02215 dynobj = elf_hash_table (info)->dynobj;
02216
02217
02218 BFD_ASSERT (dynobj != NULL
02219 && (h->needs_plt
02220 || h->u.weakdef != NULL
02221 || (h->def_dynamic
02222 && h->ref_regular
02223 && !h->def_regular)));
02224
02225 plt_entry_size
02226 = (bfd_get_mach (dynobj) == bfd_mach_cris_v32
02227 ? PLT_ENTRY_SIZE_V32 : PLT_ENTRY_SIZE);
02228
02229
02230
02231
02232 if (h->type == STT_FUNC
02233 || h->needs_plt)
02234 {
02235
02236
02237
02238
02239
02240
02241 if (! info->shared
02242 && !h->def_dynamic)
02243 {
02244
02245
02246
02247
02248
02249 BFD_ASSERT (h->needs_plt);
02250 h->needs_plt = 0;
02251 h->plt.offset = (bfd_vma) -1;
02252 return
02253 elf_cris_adjust_gotplt_to_got ((struct
02254 elf_cris_link_hash_entry *) h,
02255 info);
02256 }
02257
02258
02259
02260
02261
02262
02263 if (info->shared
02264 && !elf_cris_try_fold_plt_to_got ((struct elf_cris_link_hash_entry*)
02265 h, info))
02266 return FALSE;
02267
02268
02269 if (h->plt.refcount <= 0)
02270 {
02271 h->needs_plt = 0;
02272 h->plt.offset = (bfd_vma) -1;
02273 return TRUE;
02274 }
02275
02276
02277 if (h->dynindx == -1)
02278 {
02279 if (! bfd_elf_link_record_dynamic_symbol (info, h))
02280 return FALSE;
02281 }
02282
02283 s = bfd_get_section_by_name (dynobj, ".plt");
02284 BFD_ASSERT (s != NULL);
02285
02286
02287
02288 if (s->size == 0)
02289 s->size += plt_entry_size;
02290
02291
02292
02293
02294 if (!info->shared
02295 && !h->def_regular)
02296 {
02297 h->root.u.def.section = s;
02298 h->root.u.def.value = s->size;
02299 }
02300
02301
02302
02303
02304
02305
02306
02307 if (info->shared && h->got.refcount > 0)
02308 {
02309 h->got.refcount += h->plt.refcount;
02310
02311
02312
02313
02314 BFD_ASSERT ((s->size % plt_entry_size) == 0);
02315
02316
02317 h->plt.offset = s->size;
02318
02319
02320
02321 BFD_ASSERT (((struct elf_cris_link_hash_entry *)
02322 h)->gotplt_offset == 0);
02323
02324
02325 s->size += plt_entry_size;
02326
02327 return TRUE;
02328 }
02329
02330
02331 h->plt.offset = s->size;
02332
02333
02334 s->size += plt_entry_size;
02335
02336
02337
02338 ((struct elf_cris_link_hash_entry *) h)->gotplt_offset
02339 = elf_cris_hash_table (info)->next_gotplt_entry;
02340 elf_cris_hash_table (info)->next_gotplt_entry += 4;
02341
02342 s = bfd_get_section_by_name (dynobj, ".got.plt");
02343 BFD_ASSERT (s != NULL);
02344 s->size += 4;
02345
02346
02347
02348 s = bfd_get_section_by_name (dynobj, ".rela.plt");
02349 BFD_ASSERT (s != NULL);
02350 s->size += sizeof (Elf32_External_Rela);
02351
02352 return TRUE;
02353 }
02354
02355
02356
02357 h->plt.offset = (bfd_vma) -1;
02358
02359
02360
02361
02362 if (h->u.weakdef != NULL)
02363 {
02364 BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined
02365 || h->u.weakdef->root.type == bfd_link_hash_defweak);
02366 h->root.u.def.section = h->u.weakdef->root.u.def.section;
02367 h->root.u.def.value = h->u.weakdef->root.u.def.value;
02368 return TRUE;
02369 }
02370
02371
02372
02373
02374
02375
02376
02377
02378 if (info->shared)
02379 return TRUE;
02380
02381
02382
02383 if (!h->non_got_ref)
02384 return TRUE;
02385
02386
02387
02388
02389
02390
02391
02392
02393
02394
02395
02396 s = bfd_get_section_by_name (dynobj, ".dynbss");
02397 BFD_ASSERT (s != NULL);
02398
02399
02400
02401
02402
02403 if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
02404 {
02405 asection *srel;
02406
02407 srel = bfd_get_section_by_name (dynobj, ".rela.bss");
02408 BFD_ASSERT (srel != NULL);
02409 srel->size += sizeof (Elf32_External_Rela);
02410 h->needs_copy = 1;
02411 }
02412
02413
02414
02415
02416
02417
02418 power_of_two = bfd_log2 (h->size);
02419 if (power_of_two > 3)
02420 power_of_two = 3;
02421
02422
02423 s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two));
02424 if (power_of_two > bfd_get_section_alignment (dynobj, s))
02425 {
02426 if (!bfd_set_section_alignment (dynobj, s, power_of_two))
02427 return FALSE;
02428 }
02429
02430
02431 h->root.u.def.section = s;
02432 h->root.u.def.value = s->size;
02433
02434
02435 s->size += h->size;
02436
02437 return TRUE;
02438 }
02439
02440
02441
02442 static bfd_boolean
02443 cris_elf_check_relocs (abfd, info, sec, relocs)
02444 bfd *abfd;
02445 struct bfd_link_info *info;
02446 asection *sec;
02447 const Elf_Internal_Rela *relocs;
02448 {
02449 bfd *dynobj;
02450 Elf_Internal_Shdr *symtab_hdr;
02451 struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
02452 bfd_signed_vma *local_got_refcounts;
02453 const Elf_Internal_Rela *rel;
02454 const Elf_Internal_Rela *rel_end;
02455 asection *sgot;
02456 asection *srelgot;
02457 asection *sreloc;
02458
02459 if (info->relocatable)
02460 return TRUE;
02461
02462 dynobj = elf_hash_table (info)->dynobj;
02463 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
02464 sym_hashes = elf_sym_hashes (abfd);
02465 sym_hashes_end = sym_hashes + symtab_hdr->sh_size/sizeof (Elf32_External_Sym);
02466 local_got_refcounts = elf_local_got_refcounts (abfd);
02467
02468 sgot = NULL;
02469 srelgot = NULL;
02470 sreloc = NULL;
02471
02472 if (!elf_bad_symtab (abfd))
02473 sym_hashes_end -= symtab_hdr->sh_info;
02474
02475 rel_end = relocs + sec->reloc_count;
02476 for (rel = relocs; rel < rel_end; rel++)
02477 {
02478 struct elf_link_hash_entry *h;
02479 unsigned long r_symndx;
02480 enum elf_cris_reloc_type r_type;
02481
02482 r_symndx = ELF32_R_SYM (rel->r_info);
02483 if (r_symndx < symtab_hdr->sh_info)
02484 h = NULL;
02485 else
02486 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
02487
02488 r_type = ELF32_R_TYPE (rel->r_info);
02489
02490
02491
02492 switch (r_type)
02493 {
02494 case R_CRIS_16_GOT:
02495 case R_CRIS_32_GOT:
02496 case R_CRIS_32_GOTREL:
02497 case R_CRIS_32_PLT_GOTREL:
02498 case R_CRIS_32_PLT_PCREL:
02499 case R_CRIS_16_GOTPLT:
02500 case R_CRIS_32_GOTPLT:
02501 if (dynobj == NULL)
02502 {
02503 elf_hash_table (info)->dynobj = dynobj = abfd;
02504
02505
02506
02507
02508 if (bfd_get_mach (dynobj) == bfd_mach_cris_v10_v32)
02509 {
02510 (*_bfd_error_handler)
02511 (_("%B, section %A:\n v10/v32 compatible object %s"
02512 " must not contain a PIC relocation"),
02513 abfd, sec);
02514 return FALSE;
02515 }
02516
02517
02518
02519 if (!_bfd_elf_create_got_section (dynobj, info))
02520 return FALSE;
02521 }
02522 break;
02523
02524 default:
02525 break;
02526 }
02527
02528
02529
02530 switch (r_type)
02531 {
02532
02533
02534
02535
02536
02537
02538
02539 case R_CRIS_16_GOTPLT:
02540 case R_CRIS_32_GOTPLT:
02541 case R_CRIS_16_GOT:
02542 case R_CRIS_32_GOT:
02543 if (srelgot == NULL
02544 && (h != NULL || info->shared))
02545 {
02546 srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
02547 if (srelgot == NULL)
02548 {
02549 srelgot = bfd_make_section (dynobj, ".rela.got");
02550 if (srelgot == NULL
02551 || !bfd_set_section_flags (dynobj, srelgot,
02552 (SEC_ALLOC
02553 | SEC_LOAD
02554 | SEC_HAS_CONTENTS
02555 | SEC_IN_MEMORY
02556 | SEC_LINKER_CREATED
02557 | SEC_READONLY))
02558 || !bfd_set_section_alignment (dynobj, srelgot, 2))
02559 return FALSE;
02560 }
02561 }
02562
02563
02564 case R_CRIS_32_GOTREL:
02565 case R_CRIS_32_PLT_GOTREL:
02566 if (sgot == NULL)
02567 sgot = bfd_get_section_by_name (dynobj, ".got");
02568
02569 if (local_got_refcounts == NULL)
02570 {
02571 bfd_size_type amt;
02572
02573
02574
02575
02576 amt = symtab_hdr->sh_info + 1;
02577 amt *= sizeof (bfd_signed_vma);
02578 local_got_refcounts = ((bfd_signed_vma *) bfd_zalloc (abfd, amt));
02579 if (local_got_refcounts == NULL)
02580 return FALSE;
02581
02582 local_got_refcounts++;
02583 elf_local_got_refcounts (abfd) = local_got_refcounts;
02584 }
02585 break;
02586
02587 default:
02588 break;
02589 }
02590
02591 switch (r_type)
02592 {
02593 case R_CRIS_16_GOTPLT:
02594 case R_CRIS_32_GOTPLT:
02595
02596
02597
02598 if (h != NULL)
02599 {
02600 ((struct elf_cris_link_hash_entry *) h)->gotplt_refcount++;
02601 goto handle_gotplt_reloc;
02602 }
02603
02604
02605
02606
02607 case R_CRIS_16_GOT:
02608 case R_CRIS_32_GOT:
02609
02610 if (h != NULL)
02611 {
02612 if (h->got.refcount == 0)
02613 {
02614
02615 if (h->dynindx == -1)
02616 {
02617 if (!bfd_elf_link_record_dynamic_symbol (info, h))
02618 return FALSE;
02619 }
02620
02621
02622 sgot->size += 4;
02623
02624 srelgot->size += sizeof (Elf32_External_Rela);
02625 }
02626 h->got.refcount++;
02627 }
02628 else
02629 {
02630
02631 if (local_got_refcounts[r_symndx] == 0)
02632 {
02633 sgot->size += 4;
02634 if (info->shared)
02635 {
02636
02637
02638
02639 srelgot->size += sizeof (Elf32_External_Rela);
02640 }
02641 }
02642 local_got_refcounts[r_symndx]++;
02643 }
02644 break;
02645
02646 case R_CRIS_32_GOTREL:
02647
02648
02649
02650
02651 local_got_refcounts[-1]++;
02652 break;
02653
02654 handle_gotplt_reloc:
02655
02656 case R_CRIS_32_PLT_GOTREL:
02657
02658 local_got_refcounts[-1]++;
02659
02660
02661 case R_CRIS_32_PLT_PCREL:
02662
02663
02664
02665
02666
02667
02668
02669
02670
02671
02672
02673
02674
02675 if (h == NULL)
02676 continue;
02677
02678 h->needs_plt = 1;
02679 h->plt.refcount++;
02680 break;
02681
02682 case R_CRIS_8:
02683 case R_CRIS_16:
02684 case R_CRIS_32:
02685
02686
02687
02688
02689
02690
02691
02692 if (info->shared
02693 && (sec->flags & SEC_ALLOC) != 0
02694 && (sec->flags & SEC_READONLY) != 0)
02695 {
02696
02697 (*_bfd_error_handler)
02698 (_("%B, section %A:\n relocation %s should not"
02699 " be used in a shared object; recompile with -fPIC"),
02700 abfd,
02701 sec,
02702 cris_elf_howto_table[r_type].name);
02703 }
02704
02705
02706 case R_CRIS_8_PCREL:
02707 case R_CRIS_16_PCREL:
02708 case R_CRIS_32_PCREL:
02709 if (h != NULL)
02710 {
02711 h->non_got_ref = 1;
02712
02713
02714
02715 if (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
02716 h->plt.refcount++;
02717 }
02718
02719
02720
02721
02722
02723
02724
02725
02726
02727
02728
02729
02730
02731
02732
02733
02734
02735 if (! info->shared)
02736 break;
02737
02738
02739
02740 if ((sec->flags & SEC_ALLOC) == 0)
02741 break;
02742
02743
02744 if (r_type == R_CRIS_8_PCREL
02745 || r_type == R_CRIS_16_PCREL
02746 || r_type == R_CRIS_32_PCREL)
02747 {
02748
02749 if (h == NULL || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
02750 break;
02751
02752
02753
02754
02755
02756
02757 if (info->symbolic
02758 && h->root.type != bfd_link_hash_defweak
02759 && h->def_regular)
02760 break;
02761
02762 if ((sec->flags & SEC_READONLY) != 0)
02763 {
02764
02765 (*_bfd_error_handler)
02766 (_("%B, section %A:\n relocation %s should not be used"
02767 " in a shared object; recompile with -fPIC"),
02768 abfd,
02769 sec,
02770 cris_elf_howto_table[r_type].name);
02771 }
02772 }
02773
02774
02775
02776 if (sreloc == NULL)
02777 {
02778 const char *name;
02779
02780 name = (bfd_elf_string_from_elf_section
02781 (abfd,
02782 elf_elfheader (abfd)->e_shstrndx,
02783 elf_section_data (sec)->rel_hdr.sh_name));
02784 if (name == NULL)
02785 return FALSE;
02786
02787 BFD_ASSERT (strncmp (name, ".rela", 5) == 0
02788 && strcmp (bfd_get_section_name (abfd, sec),
02789 name + 5) == 0);
02790
02791 sreloc = bfd_get_section_by_name (dynobj, name);
02792 if (sreloc == NULL)
02793 {
02794 sreloc = bfd_make_section (dynobj, name);
02795 if (sreloc == NULL
02796 || !bfd_set_section_flags (dynobj, sreloc,
02797 (SEC_ALLOC
02798 | SEC_LOAD
02799 | SEC_HAS_CONTENTS
02800 | SEC_IN_MEMORY
02801 | SEC_LINKER_CREATED
02802 | SEC_READONLY))
02803 || !bfd_set_section_alignment (dynobj, sreloc, 2))
02804 return FALSE;
02805 }
02806 if (sec->flags & SEC_READONLY)
02807 info->flags |= DF_TEXTREL;
02808 }
02809
02810 sreloc->size += sizeof (Elf32_External_Rela);
02811
02812
02813
02814
02815
02816
02817 if ((r_type == R_CRIS_8_PCREL
02818 || r_type == R_CRIS_16_PCREL
02819 || r_type == R_CRIS_32_PCREL)
02820 && info->symbolic)
02821 {
02822 struct elf_cris_link_hash_entry *eh;
02823 struct elf_cris_pcrel_relocs_copied *p;
02824
02825 eh = (struct elf_cris_link_hash_entry *) h;
02826
02827 for (p = eh->pcrel_relocs_copied; p != NULL; p = p->next)
02828 if (p->section == sreloc)
02829 break;
02830
02831 if (p == NULL)
02832 {
02833 p = ((struct elf_cris_pcrel_relocs_copied *)
02834 bfd_alloc (dynobj, (bfd_size_type) sizeof *p));
02835 if (p == NULL)
02836 return FALSE;
02837 p->next = eh->pcrel_relocs_copied;
02838 eh->pcrel_relocs_copied = p;
02839 p->section = sreloc;
02840 p->count = 0;
02841 }
02842
02843 ++p->count;
02844 }
02845 break;
02846
02847
02848
02849 case R_CRIS_GNU_VTINHERIT:
02850 if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
02851 return FALSE;
02852 break;
02853
02854
02855
02856 case R_CRIS_GNU_VTENTRY:
02857 if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
02858 return FALSE;
02859 break;
02860
02861 default:
02862
02863 bfd_set_error (bfd_error_bad_value);
02864 return FALSE;
02865 }
02866 }
02867
02868 return TRUE;
02869 }
02870
02871
02872
02873 static bfd_boolean
02874 elf_cris_size_dynamic_sections (output_bfd, info)
02875 bfd *output_bfd ATTRIBUTE_UNUSED;
02876 struct bfd_link_info *info;
02877 {
02878 bfd *dynobj;
02879 asection *s;
02880 bfd_boolean plt;
02881 bfd_boolean relocs;
02882
02883 dynobj = elf_hash_table (info)->dynobj;
02884 BFD_ASSERT (dynobj != NULL);
02885
02886 if (elf_hash_table (info)->dynamic_sections_created)
02887 {
02888
02889 if (info->executable)
02890 {
02891 s = bfd_get_section_by_name (dynobj, ".interp");
02892 BFD_ASSERT (s != NULL);
02893 s->size = sizeof ELF_DYNAMIC_INTERPRETER;
02894 s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
02895 }
02896 }
02897 else
02898 {
02899
02900 elf_cris_link_hash_traverse (elf_cris_hash_table (info),
02901 elf_cris_adjust_gotplt_to_got,
02902 (PTR) info);
02903
02904
02905
02906
02907
02908
02909 s = bfd_get_section_by_name (dynobj, ".rela.got");
02910 if (s != NULL)
02911 s->size = 0;
02912 }
02913
02914
02915
02916
02917
02918
02919
02920
02921 if (info->shared)
02922 elf_cris_link_hash_traverse (elf_cris_hash_table (info),
02923 elf_cris_discard_excess_dso_dynamics,
02924 (PTR) info);
02925 else
02926 elf_cris_link_hash_traverse (elf_cris_hash_table (info),
02927 elf_cris_discard_excess_program_dynamics,
02928 (PTR) info);
02929
02930
02931
02932
02933 plt = FALSE;
02934 relocs = FALSE;
02935 for (s = dynobj->sections; s != NULL; s = s->next)
02936 {
02937 const char *name;
02938 bfd_boolean strip;
02939
02940 if ((s->flags & SEC_LINKER_CREATED) == 0)
02941 continue;
02942
02943
02944
02945 name = bfd_get_section_name (dynobj, s);
02946
02947 strip = FALSE;
02948
02949 if (strcmp (name, ".plt") == 0)
02950 {
02951 if (s->size == 0)
02952 {
02953
02954
02955 strip = TRUE;
02956 }
02957 else
02958 {
02959
02960 plt = TRUE;
02961 }
02962 }
02963 else if (strncmp (name, ".rela", 5) == 0)
02964 {
02965 if (s->size == 0)
02966 {
02967
02968
02969
02970
02971
02972
02973
02974
02975
02976 strip = TRUE;
02977 }
02978 else
02979 {
02980
02981
02982 if (strcmp (name, ".rela.plt") != 0)
02983 relocs = TRUE;
02984
02985
02986
02987 s->reloc_count = 0;
02988 }
02989 }
02990 else if (strncmp (name, ".got", 4) != 0)
02991 {
02992
02993 continue;
02994 }
02995
02996 if (strip)
02997 {
02998 _bfd_strip_section_from_output (info, s);
02999 continue;
03000 }
03001
03002
03003
03004
03005
03006
03007 s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size);
03008 if (s->contents == NULL && s->size != 0)
03009 return FALSE;
03010 }
03011
03012 if (elf_hash_table (info)->dynamic_sections_created)
03013 {
03014
03015
03016
03017
03018
03019 #define add_dynamic_entry(TAG, VAL) \
03020 _bfd_elf_add_dynamic_entry (info, TAG, VAL)
03021
03022 if (!info->shared)
03023 {
03024 if (!add_dynamic_entry (DT_DEBUG, 0))
03025 return FALSE;
03026 }
03027
03028 if (plt)
03029 {
03030 if (!add_dynamic_entry (DT_PLTGOT, 0)
03031 || !add_dynamic_entry (DT_PLTRELSZ, 0)
03032 || !add_dynamic_entry (DT_PLTREL, DT_RELA)
03033 || !add_dynamic_entry (DT_JMPREL, 0))
03034 return FALSE;
03035 }
03036
03037 if (relocs)
03038 {
03039 if (!add_dynamic_entry (DT_RELA, 0)
03040 || !add_dynamic_entry (DT_RELASZ, 0)
03041 || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela)))
03042 return FALSE;
03043 }
03044
03045 if ((info->flags & DF_TEXTREL) != 0)
03046 {
03047 if (!add_dynamic_entry (DT_TEXTREL, 0))
03048 return FALSE;
03049 info->flags |= DF_TEXTREL;
03050 }
03051 }
03052 #undef add_dynamic_entry
03053
03054 return TRUE;
03055 }
03056
03057
03058
03059
03060
03061
03062
03063
03064
03065
03066 static bfd_boolean
03067 elf_cris_discard_excess_dso_dynamics (h, inf)
03068 struct elf_cris_link_hash_entry *h;
03069 PTR inf;
03070 {
03071 struct elf_cris_pcrel_relocs_copied *s;
03072 struct bfd_link_info *info = (struct bfd_link_info *) inf;
03073
03074 if (h->root.root.type == bfd_link_hash_warning)
03075 h = (struct elf_cris_link_hash_entry *) h->root.root.u.i.link;
03076
03077
03078
03079
03080 if (h->root.def_regular
03081 && (h->root.forced_local
03082 || info->symbolic))
03083 {
03084 for (s = h->pcrel_relocs_copied; s != NULL; s = s->next)
03085 s->section->size -= s->count * sizeof (Elf32_External_Rela);
03086 }
03087
03088 return TRUE;
03089 }
03090
03091
03092
03093
03094
03095 static bfd_boolean
03096 elf_cris_discard_excess_program_dynamics (h, inf)
03097 struct elf_cris_link_hash_entry *h;
03098 PTR inf;
03099 {
03100 struct bfd_link_info *info = (struct bfd_link_info *) inf;
03101
03102 if (h->root.root.type == bfd_link_hash_warning)
03103 h = (struct elf_cris_link_hash_entry *) h->root.root.u.i.link;
03104
03105
03106
03107
03108
03109
03110 if (!h->root.def_dynamic
03111 || h->root.plt.refcount > 0)
03112 {
03113 if (h->root.got.refcount > 0
03114
03115
03116
03117 && elf_hash_table (info)->dynamic_sections_created)
03118 {
03119 bfd *dynobj = elf_hash_table (info)->dynobj;
03120 asection *srelgot;
03121
03122 BFD_ASSERT (dynobj != NULL);
03123
03124 srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
03125
03126 BFD_ASSERT (srelgot != NULL);
03127
03128 srelgot->size -= sizeof (Elf32_External_Rela);
03129 }
03130
03131
03132
03133
03134
03135
03136 if (! info->export_dynamic
03137 && h->root.dynindx != -1
03138 && !h->root.def_dynamic
03139 && !h->root.ref_dynamic)
03140 {
03141 h->root.dynindx = -1;
03142 _bfd_elf_strtab_delref (elf_hash_table (info)->dynstr,
03143 h->root.dynstr_index);
03144 }
03145 }
03146
03147 return TRUE;
03148 }
03149
03150
03151
03152
03153 static bfd_boolean
03154 cris_elf_object_p (abfd)
03155 bfd *abfd;
03156 {
03157 if (! cris_elf_set_mach_from_flags (abfd, elf_elfheader (abfd)->e_flags))
03158 return FALSE;
03159
03160 if ((elf_elfheader (abfd)->e_flags & EF_CRIS_UNDERSCORE))
03161 return (bfd_get_symbol_leading_char (abfd) == '_');
03162 else
03163 return (bfd_get_symbol_leading_char (abfd) == 0);
03164 }
03165
03166
03167
03168
03169 static void
03170 cris_elf_final_write_processing (abfd, linker)
03171 bfd *abfd;
03172 bfd_boolean linker ATTRIBUTE_UNUSED;
03173 {
03174 unsigned long e_flags = elf_elfheader (abfd)->e_flags;
03175
03176 e_flags &= ~EF_CRIS_UNDERSCORE;
03177 if (bfd_get_symbol_leading_char (abfd) == '_')
03178 e_flags |= EF_CRIS_UNDERSCORE;
03179
03180 switch (bfd_get_mach (abfd))
03181 {
03182 case bfd_mach_cris_v0_v10:
03183 e_flags |= EF_CRIS_VARIANT_ANY_V0_V10;
03184 break;
03185
03186 case bfd_mach_cris_v10_v32:
03187 e_flags |= EF_CRIS_VARIANT_COMMON_V10_V32;
03188 break;
03189
03190 case bfd_mach_cris_v32:
03191 e_flags |= EF_CRIS_VARIANT_V32;
03192 break;
03193
03194 default:
03195 _bfd_abort (__FILE__, __LINE__,
03196 _("Unexpected machine number"));
03197 }
03198
03199 elf_elfheader (abfd)->e_flags = e_flags;
03200 }
03201
03202
03203
03204 static bfd_boolean
03205 cris_elf_set_mach_from_flags (abfd, flags)
03206 bfd *abfd;
03207 unsigned long flags;
03208 {
03209 switch (flags & EF_CRIS_VARIANT_MASK)
03210 {
03211 case EF_CRIS_VARIANT_ANY_V0_V10:
03212 bfd_default_set_arch_mach (abfd, bfd_arch_cris, bfd_mach_cris_v0_v10);
03213 break;
03214
03215 case EF_CRIS_VARIANT_V32:
03216 bfd_default_set_arch_mach (abfd, bfd_arch_cris, bfd_mach_cris_v32);
03217 break;
03218
03219 case EF_CRIS_VARIANT_COMMON_V10_V32:
03220 bfd_default_set_arch_mach (abfd, bfd_arch_cris, bfd_mach_cris_v10_v32);
03221 break;
03222
03223 default:
03224
03225
03226
03227 bfd_set_error (bfd_error_wrong_format);
03228 return FALSE;
03229 }
03230
03231 return TRUE;
03232 }
03233
03234
03235
03236 static bfd_boolean
03237 cris_elf_print_private_bfd_data (abfd, ptr)
03238 bfd *abfd;
03239 PTR ptr;
03240 {
03241 FILE *file = (FILE *) ptr;
03242
03243 BFD_ASSERT (abfd != NULL && ptr != NULL);
03244
03245 _bfd_elf_print_private_bfd_data (abfd, ptr);
03246
03247 fprintf (file, _("private flags = %lx:"), elf_elfheader (abfd)->e_flags);
03248
03249 if (elf_elfheader (abfd)->e_flags & EF_CRIS_UNDERSCORE)
03250 fprintf (file, _(" [symbols have a _ prefix]"));
03251 if ((elf_elfheader (abfd)->e_flags & EF_CRIS_VARIANT_MASK)
03252 == EF_CRIS_VARIANT_COMMON_V10_V32)
03253 fprintf (file, _(" [v10 and v32]"));
03254 if ((elf_elfheader (abfd)->e_flags & EF_CRIS_VARIANT_MASK)
03255 == EF_CRIS_VARIANT_V32)
03256 fprintf (file, _(" [v32]"));
03257
03258 fputc ('\n', file);
03259 return TRUE;
03260 }
03261
03262
03263
03264 static bfd_boolean
03265 cris_elf_merge_private_bfd_data (ibfd, obfd)
03266 bfd *ibfd;
03267 bfd *obfd;
03268 {
03269 int imach, omach;
03270
03271 if (! _bfd_generic_verify_endian_match (ibfd, obfd))
03272 return FALSE;
03273
03274 if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
03275 || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
03276 return TRUE;
03277
03278 imach = bfd_get_mach (ibfd);
03279
03280 if (! elf_flags_init (obfd))
03281 {
03282
03283 elf_flags_init (obfd) = TRUE;
03284
03285
03286
03287
03288
03289
03290
03291
03292 if (! bfd_set_arch_mach (obfd, bfd_arch_cris, imach))
03293 return FALSE;
03294 }
03295
03296 if (bfd_get_symbol_leading_char (ibfd)
03297 != bfd_get_symbol_leading_char (obfd))
03298 {
03299 (*_bfd_error_handler)
03300 (bfd_get_symbol_leading_char (ibfd) == '_'
03301 ? _("%B: uses _-prefixed symbols, but writing file with non-prefixed symbols")
03302 : _("%B: uses non-prefixed symbols, but writing file with _-prefixed symbols"),
03303 ibfd);
03304 bfd_set_error (bfd_error_bad_value);
03305 return FALSE;
03306 }
03307
03308 omach = bfd_get_mach (obfd);
03309
03310 if (imach != omach)
03311 {
03312
03313
03314 if ((imach == bfd_mach_cris_v32
03315 && omach != bfd_mach_cris_v10_v32)
03316 || (omach == bfd_mach_cris_v32
03317 && imach != bfd_mach_cris_v10_v32))
03318 {
03319 (*_bfd_error_handler)
03320 ((imach == bfd_mach_cris_v32)
03321 ? _("%B contains CRIS v32 code, incompatible"
03322 " with previous objects")
03323 : _("%B contains non-CRIS-v32 code, incompatible"
03324 " with previous objects"),
03325 ibfd);
03326 bfd_set_error (bfd_error_bad_value);
03327 return FALSE;
03328 }
03329
03330
03331
03332
03333 if (omach == bfd_mach_cris_v10_v32
03334 && ! bfd_set_arch_mach (obfd, bfd_arch_cris, imach))
03335 return FALSE;
03336 }
03337
03338 return TRUE;
03339 }
03340
03341
03342
03343 static bfd_boolean
03344 cris_elf_copy_private_bfd_data (ibfd, obfd)
03345 bfd *ibfd;
03346 bfd *obfd;
03347 {
03348
03349 if (!_bfd_elf_copy_private_bfd_data (ibfd, obfd))
03350 return FALSE;
03351
03352
03353 if (_bfd_generic_verify_endian_match (ibfd, obfd) == FALSE)
03354 return FALSE;
03355
03356 if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
03357 || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
03358 return TRUE;
03359
03360
03361 return bfd_set_arch_mach (obfd, bfd_arch_cris, bfd_get_mach (ibfd));
03362 }
03363
03364 static enum elf_reloc_type_class
03365 elf_cris_reloc_type_class (rela)
03366 const Elf_Internal_Rela *rela;
03367 {
03368 switch ((int) ELF32_R_TYPE (rela->r_info))
03369 {
03370 case R_CRIS_RELATIVE:
03371 return reloc_class_relative;
03372 case R_CRIS_JUMP_SLOT:
03373 return reloc_class_plt;
03374 case R_CRIS_COPY:
03375 return reloc_class_copy;
03376 default:
03377 return reloc_class_normal;
03378 }
03379 }
03380
03381 #define ELF_ARCH bfd_arch_cris
03382 #define ELF_MACHINE_CODE EM_CRIS
03383 #define ELF_MAXPAGESIZE 0x2000
03384
03385 #define TARGET_LITTLE_SYM bfd_elf32_cris_vec
03386 #define TARGET_LITTLE_NAME "elf32-cris"
03387 #define elf_symbol_leading_char 0
03388
03389 #define elf_info_to_howto_rel NULL
03390 #define elf_info_to_howto cris_info_to_howto_rela
03391 #define elf_backend_relocate_section cris_elf_relocate_section
03392 #define elf_backend_gc_mark_hook cris_elf_gc_mark_hook
03393 #define elf_backend_gc_sweep_hook cris_elf_gc_sweep_hook
03394 #define elf_backend_check_relocs cris_elf_check_relocs
03395 #define elf_backend_grok_prstatus cris_elf_grok_prstatus
03396 #define elf_backend_grok_psinfo cris_elf_grok_psinfo
03397
03398 #define elf_backend_can_gc_sections 1
03399 #define elf_backend_can_refcount 1
03400
03401 #define elf_backend_object_p cris_elf_object_p
03402 #define elf_backend_final_write_processing \
03403 cris_elf_final_write_processing
03404 #define bfd_elf32_bfd_print_private_bfd_data \
03405 cris_elf_print_private_bfd_data
03406 #define bfd_elf32_bfd_merge_private_bfd_data \
03407 cris_elf_merge_private_bfd_data
03408 #define bfd_elf32_bfd_copy_private_bfd_data \
03409 cris_elf_copy_private_bfd_data
03410
03411 #define bfd_elf32_bfd_reloc_type_lookup cris_reloc_type_lookup
03412
03413 #define bfd_elf32_bfd_link_hash_table_create \
03414 elf_cris_link_hash_table_create
03415 #define elf_backend_adjust_dynamic_symbol \
03416 elf_cris_adjust_dynamic_symbol
03417 #define elf_backend_size_dynamic_sections \
03418 elf_cris_size_dynamic_sections
03419 #define elf_backend_finish_dynamic_symbol \
03420 elf_cris_finish_dynamic_symbol
03421 #define elf_backend_finish_dynamic_sections \
03422 elf_cris_finish_dynamic_sections
03423 #define elf_backend_create_dynamic_sections \
03424 _bfd_elf_create_dynamic_sections
03425 #define bfd_elf32_bfd_final_link \
03426 bfd_elf_gc_common_final_link
03427 #define elf_backend_hide_symbol elf_cris_hide_symbol
03428 #define elf_backend_reloc_type_class elf_cris_reloc_type_class
03429
03430 #define elf_backend_want_got_plt 1
03431 #define elf_backend_plt_readonly 1
03432 #define elf_backend_want_plt_sym 0
03433 #define elf_backend_got_header_size 12
03434
03435
03436
03437
03438 #define elf_backend_may_use_rel_p 0
03439 #define elf_backend_may_use_rela_p 1
03440 #define elf_backend_rela_normal 1
03441
03442 #include "elf32-target.h"
03443
03444 #define INCLUDED_TARGET_FILE
03445
03446 #undef TARGET_LITTLE_SYM
03447 #undef TARGET_LITTLE_NAME
03448 #undef elf_symbol_leading_char
03449
03450 #define TARGET_LITTLE_SYM bfd_elf32_us_cris_vec
03451 #define TARGET_LITTLE_NAME "elf32-us-cris"
03452 #define elf_symbol_leading_char '_'
03453
03454 #include "elf32-target.h"