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
00029
00030
00031
00032
00033
00034
00035
00036 #include "bfd.h"
00037 #include "sysdep.h"
00038 #include "libbfd.h"
00039 #include "bfdlink.h"
00040 #include "genlink.h"
00041 #include "elf-bfd.h"
00042 #include "elfxx-mips.h"
00043 #include "elf/mips.h"
00044
00045
00046 #include "coff/sym.h"
00047 #include "coff/symconst.h"
00048 #include "coff/internal.h"
00049 #include "coff/ecoff.h"
00050 #include "coff/mips.h"
00051 #define ECOFF_SIGNED_32
00052 #include "ecoffswap.h"
00053
00054 static bfd_boolean mips_elf_assign_gp
00055 (bfd *, bfd_vma *);
00056 static bfd_reloc_status_type mips_elf_final_gp
00057 (bfd *, asymbol *, bfd_boolean, char **, bfd_vma *);
00058 static bfd_reloc_status_type mips_elf_gprel16_reloc
00059 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
00060 static bfd_reloc_status_type mips_elf_literal_reloc
00061 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
00062 static bfd_reloc_status_type mips_elf_gprel32_reloc
00063 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
00064 static bfd_reloc_status_type gprel32_with_gp
00065 (bfd *, asymbol *, arelent *, asection *, bfd_boolean, void *, bfd_vma);
00066 static bfd_reloc_status_type mips_elf_shift6_reloc
00067 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
00068 static bfd_reloc_status_type mips16_jump_reloc
00069 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
00070 static bfd_reloc_status_type mips16_gprel_reloc
00071 (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
00072 static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
00073 (bfd *, bfd_reloc_code_real_type);
00074 static reloc_howto_type *mips_elf_n32_rtype_to_howto
00075 (unsigned int, bfd_boolean);
00076 static void mips_info_to_howto_rel
00077 (bfd *, arelent *, Elf_Internal_Rela *);
00078 static void mips_info_to_howto_rela
00079 (bfd *, arelent *, Elf_Internal_Rela *);
00080 static bfd_boolean mips_elf_sym_is_global
00081 (bfd *, asymbol *);
00082 static bfd_boolean mips_elf_n32_object_p
00083 (bfd *);
00084 static bfd_boolean elf32_mips_grok_prstatus
00085 (bfd *, Elf_Internal_Note *);
00086 static bfd_boolean elf32_mips_grok_psinfo
00087 (bfd *, Elf_Internal_Note *);
00088 static irix_compat_t elf_n32_mips_irix_compat
00089 (bfd *);
00090
00091 extern const bfd_target bfd_elf32_nbigmips_vec;
00092 extern const bfd_target bfd_elf32_nlittlemips_vec;
00093
00094
00095 #define ABI_N32_P(abfd) \
00096 ((elf_elfheader (abfd)->e_flags & EF_MIPS_ABI2) != 0)
00097
00098
00099 #define SGI_COMPAT(abfd) \
00100 (elf_n32_mips_irix_compat (abfd) != ict_none)
00101
00102
00103 #define MIPS_RESERVED_GOTNO (2)
00104
00105
00106
00107 #define MINUS_ONE (((bfd_vma)0) - 1)
00108
00109
00110
00111 static reloc_howto_type elf_mips_howto_table_rel[] =
00112 {
00113
00114 HOWTO (R_MIPS_NONE,
00115 0,
00116 0,
00117 0,
00118 FALSE,
00119 0,
00120 complain_overflow_dont,
00121 _bfd_mips_elf_generic_reloc,
00122 "R_MIPS_NONE",
00123 FALSE,
00124 0,
00125 0,
00126 FALSE),
00127
00128
00129 HOWTO (R_MIPS_16,
00130 0,
00131 2,
00132 16,
00133 FALSE,
00134 0,
00135 complain_overflow_signed,
00136 _bfd_mips_elf_generic_reloc,
00137 "R_MIPS_16",
00138 TRUE,
00139 0x0000ffff,
00140 0x0000ffff,
00141 FALSE),
00142
00143
00144 HOWTO (R_MIPS_32,
00145 0,
00146 2,
00147 32,
00148 FALSE,
00149 0,
00150 complain_overflow_dont,
00151 _bfd_mips_elf_generic_reloc,
00152 "R_MIPS_32",
00153 TRUE,
00154 0xffffffff,
00155 0xffffffff,
00156 FALSE),
00157
00158
00159 HOWTO (R_MIPS_REL32,
00160 0,
00161 2,
00162 32,
00163 FALSE,
00164 0,
00165 complain_overflow_dont,
00166 _bfd_mips_elf_generic_reloc,
00167 "R_MIPS_REL32",
00168 TRUE,
00169 0xffffffff,
00170 0xffffffff,
00171 FALSE),
00172
00173
00174 HOWTO (R_MIPS_26,
00175 2,
00176 2,
00177 26,
00178 FALSE,
00179 0,
00180 complain_overflow_dont,
00181
00182
00183
00184 _bfd_mips_elf_generic_reloc,
00185 "R_MIPS_26",
00186 TRUE,
00187 0x03ffffff,
00188 0x03ffffff,
00189 FALSE),
00190
00191
00192
00193
00194
00195 HOWTO (R_MIPS_HI16,
00196 16,
00197 2,
00198 16,
00199 FALSE,
00200 0,
00201 complain_overflow_dont,
00202 _bfd_mips_elf_hi16_reloc,
00203 "R_MIPS_HI16",
00204 TRUE,
00205 0x0000ffff,
00206 0x0000ffff,
00207 FALSE),
00208
00209
00210 HOWTO (R_MIPS_LO16,
00211 0,
00212 2,
00213 16,
00214 FALSE,
00215 0,
00216 complain_overflow_dont,
00217 _bfd_mips_elf_lo16_reloc,
00218 "R_MIPS_LO16",
00219 TRUE,
00220 0x0000ffff,
00221 0x0000ffff,
00222 FALSE),
00223
00224
00225 HOWTO (R_MIPS_GPREL16,
00226 0,
00227 2,
00228 16,
00229 FALSE,
00230 0,
00231 complain_overflow_signed,
00232 mips_elf_gprel16_reloc,
00233 "R_MIPS_GPREL16",
00234 TRUE,
00235 0x0000ffff,
00236 0x0000ffff,
00237 FALSE),
00238
00239
00240 HOWTO (R_MIPS_LITERAL,
00241 0,
00242 2,
00243 16,
00244 FALSE,
00245 0,
00246 complain_overflow_signed,
00247 mips_elf_literal_reloc,
00248 "R_MIPS_LITERAL",
00249 TRUE,
00250 0x0000ffff,
00251 0x0000ffff,
00252 FALSE),
00253
00254
00255 HOWTO (R_MIPS_GOT16,
00256 0,
00257 2,
00258 16,
00259 FALSE,
00260 0,
00261 complain_overflow_signed,
00262 _bfd_mips_elf_got16_reloc,
00263 "R_MIPS_GOT16",
00264 TRUE,
00265 0x0000ffff,
00266 0x0000ffff,
00267 FALSE),
00268
00269
00270 HOWTO (R_MIPS_PC16,
00271 0,
00272 2,
00273 16,
00274 TRUE,
00275 0,
00276 complain_overflow_signed,
00277 _bfd_mips_elf_generic_reloc,
00278 "R_MIPS_PC16",
00279 TRUE,
00280 0x0000ffff,
00281 0x0000ffff,
00282 TRUE),
00283
00284
00285 HOWTO (R_MIPS_CALL16,
00286 0,
00287 2,
00288 16,
00289 FALSE,
00290 0,
00291 complain_overflow_signed,
00292 _bfd_mips_elf_generic_reloc,
00293 "R_MIPS_CALL16",
00294 TRUE,
00295 0x0000ffff,
00296 0x0000ffff,
00297 FALSE),
00298
00299
00300 HOWTO (R_MIPS_GPREL32,
00301 0,
00302 2,
00303 32,
00304 FALSE,
00305 0,
00306 complain_overflow_dont,
00307 mips_elf_gprel32_reloc,
00308 "R_MIPS_GPREL32",
00309 TRUE,
00310 0xffffffff,
00311 0xffffffff,
00312 FALSE),
00313
00314
00315
00316 EMPTY_HOWTO (13),
00317 EMPTY_HOWTO (14),
00318 EMPTY_HOWTO (15),
00319
00320
00321 HOWTO (R_MIPS_SHIFT5,
00322 0,
00323 2,
00324 5,
00325 FALSE,
00326 6,
00327 complain_overflow_bitfield,
00328 _bfd_mips_elf_generic_reloc,
00329 "R_MIPS_SHIFT5",
00330 TRUE,
00331 0x000007c0,
00332 0x000007c0,
00333 FALSE),
00334
00335
00336 HOWTO (R_MIPS_SHIFT6,
00337 0,
00338 2,
00339 6,
00340 FALSE,
00341 6,
00342 complain_overflow_bitfield,
00343 mips_elf_shift6_reloc,
00344 "R_MIPS_SHIFT6",
00345 TRUE,
00346 0x000007c4,
00347 0x000007c4,
00348 FALSE),
00349
00350
00351 HOWTO (R_MIPS_64,
00352 0,
00353 4,
00354 64,
00355 FALSE,
00356 0,
00357 complain_overflow_dont,
00358 _bfd_mips_elf_generic_reloc,
00359 "R_MIPS_64",
00360 TRUE,
00361 MINUS_ONE,
00362 MINUS_ONE,
00363 FALSE),
00364
00365
00366 HOWTO (R_MIPS_GOT_DISP,
00367 0,
00368 2,
00369 16,
00370 FALSE,
00371 0,
00372 complain_overflow_signed,
00373 _bfd_mips_elf_generic_reloc,
00374 "R_MIPS_GOT_DISP",
00375 TRUE,
00376 0x0000ffff,
00377 0x0000ffff,
00378 FALSE),
00379
00380
00381 HOWTO (R_MIPS_GOT_PAGE,
00382 0,
00383 2,
00384 16,
00385 FALSE,
00386 0,
00387 complain_overflow_signed,
00388 _bfd_mips_elf_generic_reloc,
00389 "R_MIPS_GOT_PAGE",
00390 TRUE,
00391 0x0000ffff,
00392 0x0000ffff,
00393 FALSE),
00394
00395
00396 HOWTO (R_MIPS_GOT_OFST,
00397 0,
00398 2,
00399 16,
00400 FALSE,
00401 0,
00402 complain_overflow_signed,
00403 _bfd_mips_elf_generic_reloc,
00404 "R_MIPS_GOT_OFST",
00405 TRUE,
00406 0x0000ffff,
00407 0x0000ffff,
00408 FALSE),
00409
00410
00411 HOWTO (R_MIPS_GOT_HI16,
00412 0,
00413 2,
00414 16,
00415 FALSE,
00416 0,
00417 complain_overflow_dont,
00418 _bfd_mips_elf_generic_reloc,
00419 "R_MIPS_GOT_HI16",
00420 TRUE,
00421 0x0000ffff,
00422 0x0000ffff,
00423 FALSE),
00424
00425
00426 HOWTO (R_MIPS_GOT_LO16,
00427 0,
00428 2,
00429 16,
00430 FALSE,
00431 0,
00432 complain_overflow_dont,
00433 _bfd_mips_elf_generic_reloc,
00434 "R_MIPS_GOT_LO16",
00435 TRUE,
00436 0x0000ffff,
00437 0x0000ffff,
00438 FALSE),
00439
00440
00441 HOWTO (R_MIPS_SUB,
00442 0,
00443 4,
00444 64,
00445 FALSE,
00446 0,
00447 complain_overflow_dont,
00448 _bfd_mips_elf_generic_reloc,
00449 "R_MIPS_SUB",
00450 TRUE,
00451 MINUS_ONE,
00452 MINUS_ONE,
00453 FALSE),
00454
00455
00456
00457 HOWTO (R_MIPS_INSERT_A,
00458 0,
00459 2,
00460 32,
00461 FALSE,
00462 0,
00463 complain_overflow_dont,
00464 _bfd_mips_elf_generic_reloc,
00465 "R_MIPS_INSERT_A",
00466 TRUE,
00467 0xffffffff,
00468 0xffffffff,
00469 FALSE),
00470
00471
00472
00473
00474 HOWTO (R_MIPS_INSERT_B,
00475 0,
00476 2,
00477 32,
00478 FALSE,
00479 0,
00480 complain_overflow_dont,
00481 _bfd_mips_elf_generic_reloc,
00482 "R_MIPS_INSERT_B",
00483 TRUE,
00484 0xffffffff,
00485 0xffffffff,
00486 FALSE),
00487
00488
00489
00490 HOWTO (R_MIPS_DELETE,
00491 0,
00492 2,
00493 32,
00494 FALSE,
00495 0,
00496 complain_overflow_dont,
00497 _bfd_mips_elf_generic_reloc,
00498 "R_MIPS_DELETE",
00499 TRUE,
00500 0xffffffff,
00501 0xffffffff,
00502 FALSE),
00503
00504
00505
00506
00507
00508
00509
00510 EMPTY_HOWTO (R_MIPS_HIGHER),
00511 EMPTY_HOWTO (R_MIPS_HIGHEST),
00512
00513
00514 HOWTO (R_MIPS_CALL_HI16,
00515 0,
00516 2,
00517 16,
00518 FALSE,
00519 0,
00520 complain_overflow_dont,
00521 _bfd_mips_elf_generic_reloc,
00522 "R_MIPS_CALL_HI16",
00523 TRUE,
00524 0x0000ffff,
00525 0x0000ffff,
00526 FALSE),
00527
00528
00529 HOWTO (R_MIPS_CALL_LO16,
00530 0,
00531 2,
00532 16,
00533 FALSE,
00534 0,
00535 complain_overflow_dont,
00536 _bfd_mips_elf_generic_reloc,
00537 "R_MIPS_CALL_LO16",
00538 TRUE,
00539 0x0000ffff,
00540 0x0000ffff,
00541 FALSE),
00542
00543
00544 HOWTO (R_MIPS_SCN_DISP,
00545 0,
00546 2,
00547 32,
00548 FALSE,
00549 0,
00550 complain_overflow_dont,
00551 _bfd_mips_elf_generic_reloc,
00552 "R_MIPS_SCN_DISP",
00553 TRUE,
00554 0xffffffff,
00555 0xffffffff,
00556 FALSE),
00557
00558 HOWTO (R_MIPS_REL16,
00559 0,
00560 1,
00561 16,
00562 FALSE,
00563 0,
00564 complain_overflow_signed,
00565 _bfd_mips_elf_generic_reloc,
00566 "R_MIPS_REL16",
00567 TRUE,
00568 0xffff,
00569 0xffff,
00570 FALSE),
00571
00572
00573 EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE),
00574 EMPTY_HOWTO (R_MIPS_PJUMP),
00575
00576
00577
00578 HOWTO (R_MIPS_RELGOT,
00579 0,
00580 2,
00581 32,
00582 FALSE,
00583 0,
00584 complain_overflow_dont,
00585 _bfd_mips_elf_generic_reloc,
00586 "R_MIPS_RELGOT",
00587 TRUE,
00588 0xffffffff,
00589 0xffffffff,
00590 FALSE),
00591
00592
00593
00594 HOWTO (R_MIPS_JALR,
00595 0,
00596 2,
00597 32,
00598 FALSE,
00599 0,
00600 complain_overflow_dont,
00601 _bfd_mips_elf_generic_reloc,
00602 "R_MIPS_JALR",
00603 FALSE,
00604 0x00000000,
00605 0x00000000,
00606 FALSE),
00607
00608
00609 HOWTO (R_MIPS_TLS_DTPMOD32,
00610 0,
00611 2,
00612 32,
00613 FALSE,
00614 0,
00615 complain_overflow_dont,
00616 _bfd_mips_elf_generic_reloc,
00617 "R_MIPS_TLS_DTPMOD32",
00618 TRUE,
00619 0xffffffff,
00620 0xffffffff,
00621 FALSE),
00622
00623 HOWTO (R_MIPS_TLS_DTPREL32,
00624 0,
00625 2,
00626 32,
00627 FALSE,
00628 0,
00629 complain_overflow_dont,
00630 _bfd_mips_elf_generic_reloc,
00631 "R_MIPS_TLS_DTPREL32",
00632 TRUE,
00633 0xffffffff,
00634 0xffffffff,
00635 FALSE),
00636
00637 EMPTY_HOWTO (R_MIPS_TLS_DTPMOD64),
00638 EMPTY_HOWTO (R_MIPS_TLS_DTPREL64),
00639
00640
00641 HOWTO (R_MIPS_TLS_GD,
00642 0,
00643 2,
00644 16,
00645 FALSE,
00646 0,
00647 complain_overflow_signed,
00648 _bfd_mips_elf_generic_reloc,
00649 "R_MIPS_TLS_GD",
00650 TRUE,
00651 0x0000ffff,
00652 0x0000ffff,
00653 FALSE),
00654
00655
00656 HOWTO (R_MIPS_TLS_LDM,
00657 0,
00658 2,
00659 16,
00660 FALSE,
00661 0,
00662 complain_overflow_signed,
00663 _bfd_mips_elf_generic_reloc,
00664 "R_MIPS_TLS_LDM",
00665 TRUE,
00666 0x0000ffff,
00667 0x0000ffff,
00668 FALSE),
00669
00670
00671 HOWTO (R_MIPS_TLS_DTPREL_HI16,
00672 0,
00673 2,
00674 16,
00675 FALSE,
00676 0,
00677 complain_overflow_signed,
00678 _bfd_mips_elf_generic_reloc,
00679 "R_MIPS_TLS_DTPREL_HI16",
00680 TRUE,
00681 0x0000ffff,
00682 0x0000ffff,
00683 FALSE),
00684
00685
00686 HOWTO (R_MIPS_TLS_DTPREL_LO16,
00687 0,
00688 2,
00689 16,
00690 FALSE,
00691 0,
00692 complain_overflow_signed,
00693 _bfd_mips_elf_generic_reloc,
00694 "R_MIPS_TLS_DTPREL_LO16",
00695 TRUE,
00696 0x0000ffff,
00697 0x0000ffff,
00698 FALSE),
00699
00700
00701 HOWTO (R_MIPS_TLS_GOTTPREL,
00702 0,
00703 2,
00704 16,
00705 FALSE,
00706 0,
00707 complain_overflow_signed,
00708 _bfd_mips_elf_generic_reloc,
00709 "R_MIPS_TLS_GOTTPREL",
00710 TRUE,
00711 0x0000ffff,
00712 0x0000ffff,
00713 FALSE),
00714
00715
00716 HOWTO (R_MIPS_TLS_TPREL32,
00717 0,
00718 2,
00719 32,
00720 FALSE,
00721 0,
00722 complain_overflow_dont,
00723 _bfd_mips_elf_generic_reloc,
00724 "R_MIPS_TLS_TPREL32",
00725 TRUE,
00726 0xffffffff,
00727 0xffffffff,
00728 FALSE),
00729
00730 EMPTY_HOWTO (R_MIPS_TLS_TPREL64),
00731
00732
00733 HOWTO (R_MIPS_TLS_TPREL_HI16,
00734 0,
00735 2,
00736 16,
00737 FALSE,
00738 0,
00739 complain_overflow_signed,
00740 _bfd_mips_elf_generic_reloc,
00741 "R_MIPS_TLS_TPREL_HI16",
00742 TRUE,
00743 0x0000ffff,
00744 0x0000ffff,
00745 FALSE),
00746
00747
00748 HOWTO (R_MIPS_TLS_TPREL_LO16,
00749 0,
00750 2,
00751 16,
00752 FALSE,
00753 0,
00754 complain_overflow_signed,
00755 _bfd_mips_elf_generic_reloc,
00756 "R_MIPS_TLS_TPREL_LO16",
00757 TRUE,
00758 0x0000ffff,
00759 0x0000ffff,
00760 FALSE),
00761 };
00762
00763
00764
00765 static reloc_howto_type elf_mips_howto_table_rela[] =
00766 {
00767
00768 HOWTO (R_MIPS_NONE,
00769 0,
00770 0,
00771 0,
00772 FALSE,
00773 0,
00774 complain_overflow_dont,
00775 _bfd_mips_elf_generic_reloc,
00776 "R_MIPS_NONE",
00777 FALSE,
00778 0,
00779 0,
00780 FALSE),
00781
00782
00783 HOWTO (R_MIPS_16,
00784 0,
00785 2,
00786 16,
00787 FALSE,
00788 0,
00789 complain_overflow_signed,
00790 _bfd_mips_elf_generic_reloc,
00791 "R_MIPS_16",
00792 FALSE,
00793 0,
00794 0x0000,
00795 FALSE),
00796
00797
00798 HOWTO (R_MIPS_32,
00799 0,
00800 2,
00801 32,
00802 FALSE,
00803 0,
00804 complain_overflow_dont,
00805 _bfd_mips_elf_generic_reloc,
00806 "R_MIPS_32",
00807 FALSE,
00808 0,
00809 0xffffffff,
00810 FALSE),
00811
00812
00813 HOWTO (R_MIPS_REL32,
00814 0,
00815 2,
00816 32,
00817 FALSE,
00818 0,
00819 complain_overflow_dont,
00820 _bfd_mips_elf_generic_reloc,
00821 "R_MIPS_REL32",
00822 FALSE,
00823 0,
00824 0xffffffff,
00825 FALSE),
00826
00827
00828 HOWTO (R_MIPS_26,
00829 2,
00830 2,
00831 26,
00832 FALSE,
00833 0,
00834 complain_overflow_dont,
00835
00836
00837
00838 _bfd_mips_elf_generic_reloc,
00839 "R_MIPS_26",
00840 FALSE,
00841 0,
00842 0x03ffffff,
00843 FALSE),
00844
00845
00846 HOWTO (R_MIPS_HI16,
00847 0,
00848 2,
00849 16,
00850 FALSE,
00851 0,
00852 complain_overflow_dont,
00853 _bfd_mips_elf_generic_reloc,
00854 "R_MIPS_HI16",
00855 FALSE,
00856 0,
00857 0x0000ffff,
00858 FALSE),
00859
00860
00861 HOWTO (R_MIPS_LO16,
00862 0,
00863 2,
00864 16,
00865 FALSE,
00866 0,
00867 complain_overflow_dont,
00868 _bfd_mips_elf_generic_reloc,
00869 "R_MIPS_LO16",
00870 FALSE,
00871 0,
00872 0x0000ffff,
00873 FALSE),
00874
00875
00876 HOWTO (R_MIPS_GPREL16,
00877 0,
00878 2,
00879 16,
00880 FALSE,
00881 0,
00882 complain_overflow_signed,
00883 mips_elf_gprel16_reloc,
00884 "R_MIPS_GPREL16",
00885 FALSE,
00886 0,
00887 0x0000ffff,
00888 FALSE),
00889
00890
00891 HOWTO (R_MIPS_LITERAL,
00892 0,
00893 2,
00894 16,
00895 FALSE,
00896 0,
00897 complain_overflow_signed,
00898 mips_elf_literal_reloc,
00899 "R_MIPS_LITERAL",
00900 FALSE,
00901 0,
00902 0x0000ffff,
00903 FALSE),
00904
00905
00906 HOWTO (R_MIPS_GOT16,
00907 0,
00908 2,
00909 16,
00910 FALSE,
00911 0,
00912 complain_overflow_signed,
00913 _bfd_mips_elf_generic_reloc,
00914 "R_MIPS_GOT16",
00915 FALSE,
00916 0,
00917 0x0000ffff,
00918 FALSE),
00919
00920
00921 HOWTO (R_MIPS_PC16,
00922 0,
00923 2,
00924 16,
00925 TRUE,
00926 0,
00927 complain_overflow_signed,
00928 _bfd_mips_elf_generic_reloc,
00929 "R_MIPS_PC16",
00930 FALSE,
00931 0,
00932 0x0000ffff,
00933 TRUE),
00934
00935
00936 HOWTO (R_MIPS_CALL16,
00937 0,
00938 2,
00939 16,
00940 FALSE,
00941 0,
00942 complain_overflow_signed,
00943 _bfd_mips_elf_generic_reloc,
00944 "R_MIPS_CALL16",
00945 FALSE,
00946 0,
00947 0x0000ffff,
00948 FALSE),
00949
00950
00951 HOWTO (R_MIPS_GPREL32,
00952 0,
00953 2,
00954 32,
00955 FALSE,
00956 0,
00957 complain_overflow_dont,
00958 mips_elf_gprel32_reloc,
00959 "R_MIPS_GPREL32",
00960 FALSE,
00961 0,
00962 0xffffffff,
00963 FALSE),
00964
00965 EMPTY_HOWTO (13),
00966 EMPTY_HOWTO (14),
00967 EMPTY_HOWTO (15),
00968
00969
00970 HOWTO (R_MIPS_SHIFT5,
00971 0,
00972 2,
00973 5,
00974 FALSE,
00975 6,
00976 complain_overflow_bitfield,
00977 _bfd_mips_elf_generic_reloc,
00978 "R_MIPS_SHIFT5",
00979 FALSE,
00980 0,
00981 0x000007c0,
00982 FALSE),
00983
00984
00985 HOWTO (R_MIPS_SHIFT6,
00986 0,
00987 2,
00988 6,
00989 FALSE,
00990 6,
00991 complain_overflow_bitfield,
00992 mips_elf_shift6_reloc,
00993 "R_MIPS_SHIFT6",
00994 FALSE,
00995 0,
00996 0x000007c4,
00997 FALSE),
00998
00999
01000 HOWTO (R_MIPS_64,
01001 0,
01002 4,
01003 64,
01004 FALSE,
01005 0,
01006 complain_overflow_dont,
01007 _bfd_mips_elf_generic_reloc,
01008 "R_MIPS_64",
01009 FALSE,
01010 0,
01011 MINUS_ONE,
01012 FALSE),
01013
01014
01015 HOWTO (R_MIPS_GOT_DISP,
01016 0,
01017 2,
01018 16,
01019 FALSE,
01020 0,
01021 complain_overflow_signed,
01022 _bfd_mips_elf_generic_reloc,
01023 "R_MIPS_GOT_DISP",
01024 FALSE,
01025 0,
01026 0x0000ffff,
01027 FALSE),
01028
01029
01030 HOWTO (R_MIPS_GOT_PAGE,
01031 0,
01032 2,
01033 16,
01034 FALSE,
01035 0,
01036 complain_overflow_signed,
01037 _bfd_mips_elf_generic_reloc,
01038 "R_MIPS_GOT_PAGE",
01039 FALSE,
01040 0,
01041 0x0000ffff,
01042 FALSE),
01043
01044
01045 HOWTO (R_MIPS_GOT_OFST,
01046 0,
01047 2,
01048 16,
01049 FALSE,
01050 0,
01051 complain_overflow_signed,
01052 _bfd_mips_elf_generic_reloc,
01053 "R_MIPS_GOT_OFST",
01054 FALSE,
01055 0,
01056 0x0000ffff,
01057 FALSE),
01058
01059
01060 HOWTO (R_MIPS_GOT_HI16,
01061 0,
01062 2,
01063 16,
01064 FALSE,
01065 0,
01066 complain_overflow_dont,
01067 _bfd_mips_elf_generic_reloc,
01068 "R_MIPS_GOT_HI16",
01069 FALSE,
01070 0,
01071 0x0000ffff,
01072 FALSE),
01073
01074
01075 HOWTO (R_MIPS_GOT_LO16,
01076 0,
01077 2,
01078 16,
01079 FALSE,
01080 0,
01081 complain_overflow_dont,
01082 _bfd_mips_elf_generic_reloc,
01083 "R_MIPS_GOT_LO16",
01084 FALSE,
01085 0,
01086 0x0000ffff,
01087 FALSE),
01088
01089
01090 HOWTO (R_MIPS_SUB,
01091 0,
01092 4,
01093 64,
01094 FALSE,
01095 0,
01096 complain_overflow_dont,
01097 _bfd_mips_elf_generic_reloc,
01098 "R_MIPS_SUB",
01099 FALSE,
01100 0,
01101 MINUS_ONE,
01102 FALSE),
01103
01104
01105
01106 HOWTO (R_MIPS_INSERT_A,
01107 0,
01108 2,
01109 32,
01110 FALSE,
01111 0,
01112 complain_overflow_dont,
01113 _bfd_mips_elf_generic_reloc,
01114 "R_MIPS_INSERT_A",
01115 FALSE,
01116 0,
01117 0xffffffff,
01118 FALSE),
01119
01120
01121
01122
01123 HOWTO (R_MIPS_INSERT_B,
01124 0,
01125 2,
01126 32,
01127 FALSE,
01128 0,
01129 complain_overflow_dont,
01130 _bfd_mips_elf_generic_reloc,
01131 "R_MIPS_INSERT_B",
01132 FALSE,
01133 0,
01134 0xffffffff,
01135 FALSE),
01136
01137
01138
01139 HOWTO (R_MIPS_DELETE,
01140 0,
01141 2,
01142 32,
01143 FALSE,
01144 0,
01145 complain_overflow_dont,
01146 _bfd_mips_elf_generic_reloc,
01147 "R_MIPS_DELETE",
01148 FALSE,
01149 0,
01150 0xffffffff,
01151 FALSE),
01152
01153
01154 HOWTO (R_MIPS_HIGHER,
01155 0,
01156 2,
01157 16,
01158 FALSE,
01159 0,
01160 complain_overflow_dont,
01161 _bfd_mips_elf_generic_reloc,
01162 "R_MIPS_HIGHER",
01163 FALSE,
01164 0,
01165 0x0000ffff,
01166 FALSE),
01167
01168
01169 HOWTO (R_MIPS_HIGHEST,
01170 0,
01171 2,
01172 16,
01173 FALSE,
01174 0,
01175 complain_overflow_dont,
01176 _bfd_mips_elf_generic_reloc,
01177 "R_MIPS_HIGHEST",
01178 FALSE,
01179 0,
01180 0x0000ffff,
01181 FALSE),
01182
01183
01184 HOWTO (R_MIPS_CALL_HI16,
01185 0,
01186 2,
01187 16,
01188 FALSE,
01189 0,
01190 complain_overflow_dont,
01191 _bfd_mips_elf_generic_reloc,
01192 "R_MIPS_CALL_HI16",
01193 FALSE,
01194 0,
01195 0x0000ffff,
01196 FALSE),
01197
01198
01199 HOWTO (R_MIPS_CALL_LO16,
01200 0,
01201 2,
01202 16,
01203 FALSE,
01204 0,
01205 complain_overflow_dont,
01206 _bfd_mips_elf_generic_reloc,
01207 "R_MIPS_CALL_LO16",
01208 FALSE,
01209 0,
01210 0x0000ffff,
01211 FALSE),
01212
01213
01214 HOWTO (R_MIPS_SCN_DISP,
01215 0,
01216 2,
01217 32,
01218 FALSE,
01219 0,
01220 complain_overflow_dont,
01221 _bfd_mips_elf_generic_reloc,
01222 "R_MIPS_SCN_DISP",
01223 FALSE,
01224 0,
01225 0xffffffff,
01226 FALSE),
01227
01228
01229 HOWTO (R_MIPS_REL16,
01230 0,
01231 1,
01232 16,
01233 FALSE,
01234 0,
01235 complain_overflow_signed,
01236 _bfd_mips_elf_generic_reloc,
01237 "R_MIPS_REL16",
01238 FALSE,
01239 0,
01240 0xffff,
01241 FALSE),
01242
01243
01244 EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE),
01245 EMPTY_HOWTO (R_MIPS_PJUMP),
01246
01247
01248
01249 HOWTO (R_MIPS_RELGOT,
01250 0,
01251 2,
01252 32,
01253 FALSE,
01254 0,
01255 complain_overflow_dont,
01256 _bfd_mips_elf_generic_reloc,
01257 "R_MIPS_RELGOT",
01258 FALSE,
01259 0,
01260 0xffffffff,
01261 FALSE),
01262
01263
01264
01265 HOWTO (R_MIPS_JALR,
01266 0,
01267 2,
01268 32,
01269 FALSE,
01270 0,
01271 complain_overflow_dont,
01272 _bfd_mips_elf_generic_reloc,
01273 "R_MIPS_JALR",
01274 FALSE,
01275 0,
01276 0,
01277 FALSE),
01278
01279
01280 HOWTO (R_MIPS_TLS_DTPMOD32,
01281 0,
01282 2,
01283 32,
01284 FALSE,
01285 0,
01286 complain_overflow_dont,
01287 _bfd_mips_elf_generic_reloc,
01288 "R_MIPS_TLS_DTPMOD32",
01289 TRUE,
01290 0xffffffff,
01291 0xffffffff,
01292 FALSE),
01293
01294 HOWTO (R_MIPS_TLS_DTPREL32,
01295 0,
01296 2,
01297 32,
01298 FALSE,
01299 0,
01300 complain_overflow_dont,
01301 _bfd_mips_elf_generic_reloc,
01302 "R_MIPS_TLS_DTPREL32",
01303 TRUE,
01304 0xffffffff,
01305 0xffffffff,
01306 FALSE),
01307
01308 EMPTY_HOWTO (R_MIPS_TLS_DTPMOD64),
01309 EMPTY_HOWTO (R_MIPS_TLS_DTPREL64),
01310
01311
01312 HOWTO (R_MIPS_TLS_GD,
01313 0,
01314 2,
01315 16,
01316 FALSE,
01317 0,
01318 complain_overflow_signed,
01319 _bfd_mips_elf_generic_reloc,
01320 "R_MIPS_TLS_GD",
01321 TRUE,
01322 0x0000ffff,
01323 0x0000ffff,
01324 FALSE),
01325
01326
01327 HOWTO (R_MIPS_TLS_LDM,
01328 0,
01329 2,
01330 16,
01331 FALSE,
01332 0,
01333 complain_overflow_signed,
01334 _bfd_mips_elf_generic_reloc,
01335 "R_MIPS_TLS_LDM",
01336 TRUE,
01337 0x0000ffff,
01338 0x0000ffff,
01339 FALSE),
01340
01341
01342 HOWTO (R_MIPS_TLS_DTPREL_HI16,
01343 0,
01344 2,
01345 16,
01346 FALSE,
01347 0,
01348 complain_overflow_signed,
01349 _bfd_mips_elf_generic_reloc,
01350 "R_MIPS_TLS_DTPREL_HI16",
01351 TRUE,
01352 0x0000ffff,
01353 0x0000ffff,
01354 FALSE),
01355
01356
01357 HOWTO (R_MIPS_TLS_DTPREL_LO16,
01358 0,
01359 2,
01360 16,
01361 FALSE,
01362 0,
01363 complain_overflow_signed,
01364 _bfd_mips_elf_generic_reloc,
01365 "R_MIPS_TLS_DTPREL_LO16",
01366 TRUE,
01367 0x0000ffff,
01368 0x0000ffff,
01369 FALSE),
01370
01371
01372 HOWTO (R_MIPS_TLS_GOTTPREL,
01373 0,
01374 2,
01375 16,
01376 FALSE,
01377 0,
01378 complain_overflow_signed,
01379 _bfd_mips_elf_generic_reloc,
01380 "R_MIPS_TLS_GOTTPREL",
01381 TRUE,
01382 0x0000ffff,
01383 0x0000ffff,
01384 FALSE),
01385
01386
01387 HOWTO (R_MIPS_TLS_TPREL32,
01388 0,
01389 2,
01390 32,
01391 FALSE,
01392 0,
01393 complain_overflow_dont,
01394 _bfd_mips_elf_generic_reloc,
01395 "R_MIPS_TLS_TPREL32",
01396 TRUE,
01397 0xffffffff,
01398 0xffffffff,
01399 FALSE),
01400
01401 EMPTY_HOWTO (R_MIPS_TLS_TPREL64),
01402
01403
01404 HOWTO (R_MIPS_TLS_TPREL_HI16,
01405 0,
01406 2,
01407 16,
01408 FALSE,
01409 0,
01410 complain_overflow_signed,
01411 _bfd_mips_elf_generic_reloc,
01412 "R_MIPS_TLS_TPREL_HI16",
01413 TRUE,
01414 0x0000ffff,
01415 0x0000ffff,
01416 FALSE),
01417
01418
01419 HOWTO (R_MIPS_TLS_TPREL_LO16,
01420 0,
01421 2,
01422 16,
01423 FALSE,
01424 0,
01425 complain_overflow_signed,
01426 _bfd_mips_elf_generic_reloc,
01427 "R_MIPS_TLS_TPREL_LO16",
01428 TRUE,
01429 0x0000ffff,
01430 0x0000ffff,
01431 FALSE),
01432 };
01433
01434 static reloc_howto_type elf_mips16_howto_table_rel[] =
01435 {
01436
01437 HOWTO (R_MIPS16_26,
01438 2,
01439 2,
01440 26,
01441 FALSE,
01442 0,
01443 complain_overflow_dont,
01444
01445
01446
01447 mips16_jump_reloc,
01448 "R_MIPS16_26",
01449 TRUE,
01450 0x3ffffff,
01451 0x3ffffff,
01452 FALSE),
01453
01454
01455 HOWTO (R_MIPS16_GPREL,
01456 0,
01457 2,
01458 16,
01459 FALSE,
01460 0,
01461 complain_overflow_signed,
01462 mips16_gprel_reloc,
01463 "R_MIPS16_GPREL",
01464 TRUE,
01465 0x0000ffff,
01466 0x0000ffff,
01467 FALSE),
01468
01469
01470 EMPTY_HOWTO (R_MIPS16_GOT16),
01471
01472
01473 EMPTY_HOWTO (R_MIPS16_CALL16),
01474
01475
01476 HOWTO (R_MIPS16_HI16,
01477 16,
01478 2,
01479 16,
01480 FALSE,
01481 0,
01482 complain_overflow_dont,
01483 _bfd_mips_elf_hi16_reloc,
01484 "R_MIPS16_HI16",
01485 TRUE,
01486 0x0000ffff,
01487 0x0000ffff,
01488 FALSE),
01489
01490
01491 HOWTO (R_MIPS16_LO16,
01492 0,
01493 2,
01494 16,
01495 FALSE,
01496 0,
01497 complain_overflow_dont,
01498 _bfd_mips_elf_lo16_reloc,
01499 "R_MIPS16_LO16",
01500 TRUE,
01501 0x0000ffff,
01502 0x0000ffff,
01503 FALSE),
01504 };
01505
01506 static reloc_howto_type elf_mips16_howto_table_rela[] =
01507 {
01508
01509 HOWTO (R_MIPS16_26,
01510 2,
01511 2,
01512 26,
01513 FALSE,
01514 0,
01515 complain_overflow_dont,
01516
01517
01518
01519 mips16_jump_reloc,
01520 "R_MIPS16_26",
01521 FALSE,
01522 0x3ffffff,
01523 0x3ffffff,
01524 FALSE),
01525
01526
01527 HOWTO (R_MIPS16_GPREL,
01528 0,
01529 2,
01530 16,
01531 FALSE,
01532 0,
01533 complain_overflow_signed,
01534 mips16_gprel_reloc,
01535 "R_MIPS16_GPREL",
01536 FALSE,
01537 0x0000ffff,
01538 0x0000ffff,
01539 FALSE),
01540
01541
01542 EMPTY_HOWTO (R_MIPS16_GOT16),
01543
01544
01545 EMPTY_HOWTO (R_MIPS16_CALL16),
01546
01547
01548 HOWTO (R_MIPS16_HI16,
01549 16,
01550 2,
01551 16,
01552 FALSE,
01553 0,
01554 complain_overflow_dont,
01555 _bfd_mips_elf_hi16_reloc,
01556 "R_MIPS16_HI16",
01557 FALSE,
01558 0x0000ffff,
01559 0x0000ffff,
01560 FALSE),
01561
01562
01563 HOWTO (R_MIPS16_LO16,
01564 0,
01565 2,
01566 16,
01567 FALSE,
01568 0,
01569 complain_overflow_dont,
01570 _bfd_mips_elf_lo16_reloc,
01571 "R_MIPS16_LO16",
01572 FALSE,
01573 0x0000ffff,
01574 0x0000ffff,
01575 FALSE),
01576 };
01577
01578
01579 static reloc_howto_type elf_mips_gnu_vtinherit_howto =
01580 HOWTO (R_MIPS_GNU_VTINHERIT,
01581 0,
01582 2,
01583 0,
01584 FALSE,
01585 0,
01586 complain_overflow_dont,
01587 NULL,
01588 "R_MIPS_GNU_VTINHERIT",
01589 FALSE,
01590 0,
01591 0,
01592 FALSE);
01593
01594
01595 static reloc_howto_type elf_mips_gnu_vtentry_howto =
01596 HOWTO (R_MIPS_GNU_VTENTRY,
01597 0,
01598 2,
01599 0,
01600 FALSE,
01601 0,
01602 complain_overflow_dont,
01603 _bfd_elf_rel_vtable_reloc_fn,
01604 "R_MIPS_GNU_VTENTRY",
01605 FALSE,
01606 0,
01607 0,
01608 FALSE);
01609
01610
01611 static reloc_howto_type elf_mips_gnu_rel16_s2 =
01612 HOWTO (R_MIPS_GNU_REL16_S2,
01613 2,
01614 2,
01615 16,
01616 TRUE,
01617 0,
01618 complain_overflow_signed,
01619 _bfd_mips_elf_generic_reloc,
01620 "R_MIPS_GNU_REL16_S2",
01621 TRUE,
01622 0x0000ffff,
01623 0x0000ffff,
01624 TRUE);
01625
01626
01627 static reloc_howto_type elf_mips_gnu_rela16_s2 =
01628 HOWTO (R_MIPS_GNU_REL16_S2,
01629 2,
01630 2,
01631 16,
01632 TRUE,
01633 0,
01634 complain_overflow_signed,
01635 _bfd_mips_elf_generic_reloc,
01636 "R_MIPS_GNU_REL16_S2",
01637 FALSE,
01638 0,
01639 0x0000ffff,
01640 TRUE);
01641
01642
01643
01644
01645 static bfd_boolean
01646 mips_elf_assign_gp (bfd *output_bfd, bfd_vma *pgp)
01647 {
01648 unsigned int count;
01649 asymbol **sym;
01650 unsigned int i;
01651
01652
01653 *pgp = _bfd_get_gp_value (output_bfd);
01654 if (*pgp)
01655 return TRUE;
01656
01657 count = bfd_get_symcount (output_bfd);
01658 sym = bfd_get_outsymbols (output_bfd);
01659
01660
01661
01662 if (sym == NULL)
01663 i = count;
01664 else
01665 {
01666 for (i = 0; i < count; i++, sym++)
01667 {
01668 register const char *name;
01669
01670 name = bfd_asymbol_name (*sym);
01671 if (*name == '_' && strcmp (name, "_gp") == 0)
01672 {
01673 *pgp = bfd_asymbol_value (*sym);
01674 _bfd_set_gp_value (output_bfd, *pgp);
01675 break;
01676 }
01677 }
01678 }
01679
01680 if (i >= count)
01681 {
01682
01683 *pgp = 4;
01684 _bfd_set_gp_value (output_bfd, *pgp);
01685 return FALSE;
01686 }
01687
01688 return TRUE;
01689 }
01690
01691
01692
01693
01694
01695
01696
01697 static bfd_reloc_status_type
01698 mips_elf_final_gp (bfd *output_bfd, asymbol *symbol, bfd_boolean relocatable,
01699 char **error_message, bfd_vma *pgp)
01700 {
01701 if (bfd_is_und_section (symbol->section)
01702 && ! relocatable)
01703 {
01704 *pgp = 0;
01705 return bfd_reloc_undefined;
01706 }
01707
01708 *pgp = _bfd_get_gp_value (output_bfd);
01709 if (*pgp == 0
01710 && (! relocatable
01711 || (symbol->flags & BSF_SECTION_SYM) != 0))
01712 {
01713 if (relocatable)
01714 {
01715
01716 *pgp = symbol->section->output_section->vma ;
01717 _bfd_set_gp_value (output_bfd, *pgp);
01718 }
01719 else if (!mips_elf_assign_gp (output_bfd, pgp))
01720 {
01721 *error_message =
01722 (char *) _("GP relative relocation when _gp not defined");
01723 return bfd_reloc_dangerous;
01724 }
01725 }
01726
01727 return bfd_reloc_ok;
01728 }
01729
01730
01731
01732
01733 static bfd_reloc_status_type
01734 mips_elf_gprel16_reloc (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc_entry,
01735 asymbol *symbol, void *data ATTRIBUTE_UNUSED,
01736 asection *input_section, bfd *output_bfd,
01737 char **error_message ATTRIBUTE_UNUSED)
01738 {
01739 bfd_boolean relocatable;
01740 bfd_reloc_status_type ret;
01741 bfd_vma gp;
01742
01743 if (output_bfd != NULL)
01744 relocatable = TRUE;
01745 else
01746 {
01747 relocatable = FALSE;
01748 output_bfd = symbol->section->output_section->owner;
01749 }
01750
01751 ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
01752 &gp);
01753 if (ret != bfd_reloc_ok)
01754 return ret;
01755
01756 return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
01757 input_section, relocatable,
01758 data, gp);
01759 }
01760
01761
01762
01763 static bfd_reloc_status_type
01764 mips_elf_literal_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
01765 void *data, asection *input_section, bfd *output_bfd,
01766 char **error_message)
01767 {
01768 bfd_boolean relocatable;
01769 bfd_reloc_status_type ret;
01770 bfd_vma gp;
01771
01772
01773 if (output_bfd != NULL
01774 && (symbol->flags & BSF_SECTION_SYM) == 0
01775 && (symbol->flags & BSF_LOCAL) != 0)
01776 {
01777 *error_message = (char *)
01778 _("literal relocation occurs for an external symbol");
01779 return bfd_reloc_outofrange;
01780 }
01781
01782
01783 if (output_bfd != NULL)
01784 relocatable = TRUE;
01785 else
01786 {
01787 relocatable = FALSE;
01788 output_bfd = symbol->section->output_section->owner;
01789 }
01790
01791 ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
01792 &gp);
01793 if (ret != bfd_reloc_ok)
01794 return ret;
01795
01796 return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
01797 input_section, relocatable,
01798 data, gp);
01799 }
01800
01801
01802
01803
01804 static bfd_reloc_status_type
01805 mips_elf_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
01806 void *data, asection *input_section, bfd *output_bfd,
01807 char **error_message)
01808 {
01809 bfd_boolean relocatable;
01810 bfd_reloc_status_type ret;
01811 bfd_vma gp;
01812
01813
01814 if (output_bfd != NULL
01815 && (symbol->flags & BSF_SECTION_SYM) == 0
01816 && (symbol->flags & BSF_LOCAL) != 0)
01817 {
01818 *error_message = (char *)
01819 _("32bits gp relative relocation occurs for an external symbol");
01820 return bfd_reloc_outofrange;
01821 }
01822
01823 if (output_bfd != NULL)
01824 {
01825 relocatable = TRUE;
01826 gp = _bfd_get_gp_value (output_bfd);
01827 }
01828 else
01829 {
01830 relocatable = FALSE;
01831 output_bfd = symbol->section->output_section->owner;
01832
01833 ret = mips_elf_final_gp (output_bfd, symbol, relocatable,
01834 error_message, &gp);
01835 if (ret != bfd_reloc_ok)
01836 return ret;
01837 }
01838
01839 return gprel32_with_gp (abfd, symbol, reloc_entry, input_section,
01840 relocatable, data, gp);
01841 }
01842
01843 static bfd_reloc_status_type
01844 gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry,
01845 asection *input_section, bfd_boolean relocatable,
01846 void *data, bfd_vma gp)
01847 {
01848 bfd_vma relocation;
01849 unsigned long val;
01850
01851 if (bfd_is_com_section (symbol->section))
01852 relocation = 0;
01853 else
01854 relocation = symbol->value;
01855
01856 relocation += symbol->section->output_section->vma;
01857 relocation += symbol->section->output_offset;
01858
01859 if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
01860 return bfd_reloc_outofrange;
01861
01862 if (reloc_entry->howto->src_mask == 0)
01863 val = 0;
01864 else
01865 val = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
01866
01867
01868 val += reloc_entry->addend;
01869
01870
01871
01872
01873 if (! relocatable
01874 || (symbol->flags & BSF_SECTION_SYM) != 0)
01875 val += relocation - gp;
01876
01877 bfd_put_32 (abfd, val, (bfd_byte *) data + reloc_entry->address);
01878
01879 if (relocatable)
01880 reloc_entry->address += input_section->output_offset;
01881
01882 return bfd_reloc_ok;
01883 }
01884
01885
01886
01887
01888 static bfd_reloc_status_type
01889 mips_elf_shift6_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
01890 void *data, asection *input_section, bfd *output_bfd,
01891 char **error_message)
01892 {
01893 if (reloc_entry->howto->partial_inplace)
01894 {
01895 reloc_entry->addend = ((reloc_entry->addend & 0x00007c0)
01896 | (reloc_entry->addend & 0x00000800) >> 9);
01897 }
01898
01899 return _bfd_mips_elf_generic_reloc (abfd, reloc_entry, symbol, data,
01900 input_section, output_bfd,
01901 error_message);
01902 }
01903
01904
01905
01906 static bfd_reloc_status_type
01907 mips16_jump_reloc (bfd *abfd ATTRIBUTE_UNUSED,
01908 arelent *reloc_entry ATTRIBUTE_UNUSED,
01909 asymbol *symbol ATTRIBUTE_UNUSED,
01910 void *data ATTRIBUTE_UNUSED,
01911 asection *input_section, bfd *output_bfd ATTRIBUTE_UNUSED,
01912 char **error_message ATTRIBUTE_UNUSED)
01913 {
01914 static bfd_boolean warned = FALSE;
01915
01916
01917 if (! warned)
01918 (*_bfd_error_handler)
01919 (_("Linking mips16 objects into %s format is not supported"),
01920 bfd_get_target (input_section->output_section->owner));
01921 warned = TRUE;
01922
01923 return bfd_reloc_undefined;
01924 }
01925
01926
01927
01928 static bfd_reloc_status_type
01929 mips16_gprel_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
01930 void *data, asection *input_section, bfd *output_bfd,
01931 char **error_message)
01932 {
01933 bfd_boolean relocatable;
01934 bfd_reloc_status_type ret;
01935 bfd_byte *location;
01936 bfd_vma gp;
01937
01938
01939
01940 if (output_bfd != NULL
01941 && (symbol->flags & BSF_SECTION_SYM) == 0
01942 && (symbol->flags & BSF_LOCAL) != 0)
01943 {
01944 reloc_entry->address += input_section->output_offset;
01945 return bfd_reloc_ok;
01946 }
01947
01948 if (output_bfd != NULL)
01949 relocatable = TRUE;
01950 else
01951 {
01952 relocatable = FALSE;
01953 output_bfd = symbol->section->output_section->owner;
01954 }
01955
01956 ret = mips_elf_final_gp (output_bfd, symbol, relocatable, error_message,
01957 &gp);
01958 if (ret != bfd_reloc_ok)
01959 return ret;
01960
01961 location = (bfd_byte *) data + reloc_entry->address;
01962 _bfd_mips16_elf_reloc_unshuffle (abfd, reloc_entry->howto->type, FALSE,
01963 location);
01964 ret = _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry,
01965 input_section, relocatable,
01966 data, gp);
01967 _bfd_mips16_elf_reloc_shuffle (abfd, reloc_entry->howto->type, !relocatable,
01968 location);
01969
01970 return ret;
01971 }
01972
01973
01974
01975 struct elf_reloc_map {
01976 bfd_reloc_code_real_type bfd_val;
01977 enum elf_mips_reloc_type elf_val;
01978 };
01979
01980 static const struct elf_reloc_map mips_reloc_map[] =
01981 {
01982 { BFD_RELOC_NONE, R_MIPS_NONE },
01983 { BFD_RELOC_16, R_MIPS_16 },
01984 { BFD_RELOC_32, R_MIPS_32 },
01985
01986 { BFD_RELOC_CTOR, R_MIPS_32 },
01987 { BFD_RELOC_64, R_MIPS_64 },
01988 { BFD_RELOC_16_PCREL, R_MIPS_PC16 },
01989 { BFD_RELOC_HI16_S, R_MIPS_HI16 },
01990 { BFD_RELOC_LO16, R_MIPS_LO16 },
01991 { BFD_RELOC_GPREL16, R_MIPS_GPREL16 },
01992 { BFD_RELOC_GPREL32, R_MIPS_GPREL32 },
01993 { BFD_RELOC_MIPS_JMP, R_MIPS_26 },
01994 { BFD_RELOC_MIPS_LITERAL, R_MIPS_LITERAL },
01995 { BFD_RELOC_MIPS_GOT16, R_MIPS_GOT16 },
01996 { BFD_RELOC_MIPS_CALL16, R_MIPS_CALL16 },
01997 { BFD_RELOC_MIPS_SHIFT5, R_MIPS_SHIFT5 },
01998 { BFD_RELOC_MIPS_SHIFT6, R_MIPS_SHIFT6 },
01999 { BFD_RELOC_MIPS_GOT_DISP, R_MIPS_GOT_DISP },
02000 { BFD_RELOC_MIPS_GOT_PAGE, R_MIPS_GOT_PAGE },
02001 { BFD_RELOC_MIPS_GOT_OFST, R_MIPS_GOT_OFST },
02002 { BFD_RELOC_MIPS_GOT_HI16, R_MIPS_GOT_HI16 },
02003 { BFD_RELOC_MIPS_GOT_LO16, R_MIPS_GOT_LO16 },
02004 { BFD_RELOC_MIPS_SUB, R_MIPS_SUB },
02005 { BFD_RELOC_MIPS_INSERT_A, R_MIPS_INSERT_A },
02006 { BFD_RELOC_MIPS_INSERT_B, R_MIPS_INSERT_B },
02007 { BFD_RELOC_MIPS_DELETE, R_MIPS_DELETE },
02008 { BFD_RELOC_MIPS_HIGHEST, R_MIPS_HIGHEST },
02009 { BFD_RELOC_MIPS_HIGHER, R_MIPS_HIGHER },
02010 { BFD_RELOC_MIPS_CALL_HI16, R_MIPS_CALL_HI16 },
02011 { BFD_RELOC_MIPS_CALL_LO16, R_MIPS_CALL_LO16 },
02012 { BFD_RELOC_MIPS_SCN_DISP, R_MIPS_SCN_DISP },
02013 { BFD_RELOC_MIPS_REL16, R_MIPS_REL16 },
02014
02015 { BFD_RELOC_MIPS_RELGOT, R_MIPS_RELGOT },
02016 { BFD_RELOC_MIPS_JALR, R_MIPS_JALR },
02017 { BFD_RELOC_MIPS_TLS_DTPMOD32, R_MIPS_TLS_DTPMOD32 },
02018 { BFD_RELOC_MIPS_TLS_DTPREL32, R_MIPS_TLS_DTPREL32 },
02019 { BFD_RELOC_MIPS_TLS_DTPMOD64, R_MIPS_TLS_DTPMOD64 },
02020 { BFD_RELOC_MIPS_TLS_DTPREL64, R_MIPS_TLS_DTPREL64 },
02021 { BFD_RELOC_MIPS_TLS_GD, R_MIPS_TLS_GD },
02022 { BFD_RELOC_MIPS_TLS_LDM, R_MIPS_TLS_LDM },
02023 { BFD_RELOC_MIPS_TLS_DTPREL_HI16, R_MIPS_TLS_DTPREL_HI16 },
02024 { BFD_RELOC_MIPS_TLS_DTPREL_LO16, R_MIPS_TLS_DTPREL_LO16 },
02025 { BFD_RELOC_MIPS_TLS_GOTTPREL, R_MIPS_TLS_GOTTPREL },
02026 { BFD_RELOC_MIPS_TLS_TPREL32, R_MIPS_TLS_TPREL32 },
02027 { BFD_RELOC_MIPS_TLS_TPREL64, R_MIPS_TLS_TPREL64 },
02028 { BFD_RELOC_MIPS_TLS_TPREL_HI16, R_MIPS_TLS_TPREL_HI16 },
02029 { BFD_RELOC_MIPS_TLS_TPREL_LO16, R_MIPS_TLS_TPREL_LO16 }
02030 };
02031
02032 static const struct elf_reloc_map mips16_reloc_map[] =
02033 {
02034 { BFD_RELOC_MIPS16_JMP, R_MIPS16_26 - R_MIPS16_min },
02035 { BFD_RELOC_MIPS16_GPREL, R_MIPS16_GPREL - R_MIPS16_min },
02036 { BFD_RELOC_MIPS16_HI16_S, R_MIPS16_HI16 - R_MIPS16_min },
02037 { BFD_RELOC_MIPS16_LO16, R_MIPS16_LO16 - R_MIPS16_min },
02038 };
02039
02040
02041
02042 static reloc_howto_type *
02043 bfd_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
02044 bfd_reloc_code_real_type code)
02045 {
02046 unsigned int i;
02047
02048
02049 reloc_howto_type *howto_table = elf_mips_howto_table_rela;
02050 reloc_howto_type *howto16_table = elf_mips16_howto_table_rela;
02051
02052 for (i = 0; i < sizeof (mips_reloc_map) / sizeof (struct elf_reloc_map);
02053 i++)
02054 {
02055 if (mips_reloc_map[i].bfd_val == code)
02056 return &howto_table[(int) mips_reloc_map[i].elf_val];
02057 }
02058
02059 for (i = 0; i < sizeof (mips16_reloc_map) / sizeof (struct elf_reloc_map);
02060 i++)
02061 {
02062 if (mips16_reloc_map[i].bfd_val == code)
02063 return &howto16_table[(int) mips16_reloc_map[i].elf_val];
02064 }
02065
02066 switch (code)
02067 {
02068 case BFD_RELOC_VTABLE_INHERIT:
02069 return &elf_mips_gnu_vtinherit_howto;
02070 case BFD_RELOC_VTABLE_ENTRY:
02071 return &elf_mips_gnu_vtentry_howto;
02072 case BFD_RELOC_16_PCREL_S2:
02073 return &elf_mips_gnu_rela16_s2;
02074 default:
02075 bfd_set_error (bfd_error_bad_value);
02076 return NULL;
02077 }
02078 }
02079
02080
02081
02082 static reloc_howto_type *
02083 mips_elf_n32_rtype_to_howto (unsigned int r_type, bfd_boolean rela_p)
02084 {
02085 switch (r_type)
02086 {
02087 case R_MIPS_GNU_VTINHERIT:
02088 return &elf_mips_gnu_vtinherit_howto;
02089 case R_MIPS_GNU_VTENTRY:
02090 return &elf_mips_gnu_vtentry_howto;
02091 case R_MIPS_GNU_REL16_S2:
02092 if (rela_p)
02093 return &elf_mips_gnu_rela16_s2;
02094 else
02095 return &elf_mips_gnu_rel16_s2;
02096 default:
02097 if (r_type >= R_MIPS16_min && r_type < R_MIPS16_max)
02098 {
02099 if (rela_p)
02100 return &elf_mips16_howto_table_rela[r_type - R_MIPS16_min];
02101 else
02102 return &elf_mips16_howto_table_rel[r_type - R_MIPS16_min];
02103 }
02104 BFD_ASSERT (r_type < (unsigned int) R_MIPS_max);
02105 if (rela_p)
02106 return &elf_mips_howto_table_rela[r_type];
02107 else
02108 return &elf_mips_howto_table_rel[r_type];
02109 break;
02110 }
02111 }
02112
02113
02114
02115 static void
02116 mips_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
02117 {
02118 unsigned int r_type;
02119
02120 r_type = ELF32_R_TYPE (dst->r_info);
02121 cache_ptr->howto = mips_elf_n32_rtype_to_howto (r_type, FALSE);
02122
02123
02124
02125
02126
02127 if (((*cache_ptr->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0
02128 && (r_type == (unsigned int) R_MIPS_GPREL16
02129 || r_type == (unsigned int) R_MIPS_LITERAL))
02130 cache_ptr->addend = elf_gp (abfd);
02131 }
02132
02133
02134
02135 static void
02136 mips_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
02137 arelent *cache_ptr, Elf_Internal_Rela *dst)
02138 {
02139 unsigned int r_type;
02140
02141 r_type = ELF32_R_TYPE (dst->r_info);
02142 cache_ptr->howto = mips_elf_n32_rtype_to_howto (r_type, TRUE);
02143 cache_ptr->addend = dst->r_addend;
02144 }
02145
02146
02147
02148
02149
02150
02151
02152 static bfd_boolean
02153 mips_elf_sym_is_global (bfd *abfd ATTRIBUTE_UNUSED, asymbol *sym)
02154 {
02155 if (SGI_COMPAT (abfd))
02156 return (sym->flags & BSF_SECTION_SYM) == 0;
02157 else
02158 return ((sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0
02159 || bfd_is_und_section (bfd_get_section (sym))
02160 || bfd_is_com_section (bfd_get_section (sym)));
02161 }
02162
02163
02164
02165 static bfd_boolean
02166 mips_elf_n32_object_p (bfd *abfd)
02167 {
02168 unsigned long mach;
02169
02170
02171
02172
02173 if (SGI_COMPAT (abfd))
02174 elf_bad_symtab (abfd) = TRUE;
02175
02176 mach = _bfd_elf_mips_mach (elf_elfheader (abfd)->e_flags);
02177 bfd_default_set_arch_mach (abfd, bfd_arch_mips, mach);
02178
02179 if (! ABI_N32_P(abfd))
02180 return FALSE;
02181
02182 return TRUE;
02183 }
02184
02185
02186 static bfd_boolean
02187 elf32_mips_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
02188 {
02189 int offset;
02190 unsigned int size;
02191
02192 switch (note->descsz)
02193 {
02194 default:
02195 return FALSE;
02196
02197 case 440:
02198
02199 elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
02200
02201
02202 elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
02203
02204
02205 offset = 72;
02206 size = 360;
02207
02208 break;
02209 }
02210
02211
02212 return _bfd_elfcore_make_pseudosection (abfd, ".reg", size,
02213 note->descpos + offset);
02214 }
02215
02216 static bfd_boolean
02217 elf32_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
02218 {
02219 switch (note->descsz)
02220 {
02221 default:
02222 return FALSE;
02223
02224 case 128:
02225 elf_tdata (abfd)->core_program
02226 = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
02227 elf_tdata (abfd)->core_command
02228 = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
02229 }
02230
02231
02232
02233
02234
02235 {
02236 char *command = elf_tdata (abfd)->core_command;
02237 int n = strlen (command);
02238
02239 if (0 < n && command[n - 1] == ' ')
02240 command[n - 1] = '\0';
02241 }
02242
02243 return TRUE;
02244 }
02245
02246
02247
02248 static irix_compat_t
02249 elf_n32_mips_irix_compat (bfd *abfd)
02250 {
02251 if ((abfd->xvec == &bfd_elf32_nbigmips_vec)
02252 || (abfd->xvec == &bfd_elf32_nlittlemips_vec))
02253 return ict_irix6;
02254 else
02255 return ict_none;
02256 }
02257
02258
02259
02260 static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
02261
02262 magicSym,
02263
02264 4,
02265
02266 sizeof (struct hdr_ext),
02267 sizeof (struct dnr_ext),
02268 sizeof (struct pdr_ext),
02269 sizeof (struct sym_ext),
02270 sizeof (struct opt_ext),
02271 sizeof (struct fdr_ext),
02272 sizeof (struct rfd_ext),
02273 sizeof (struct ext_ext),
02274
02275 ecoff_swap_hdr_in,
02276 ecoff_swap_dnr_in,
02277 ecoff_swap_pdr_in,
02278 ecoff_swap_sym_in,
02279 ecoff_swap_opt_in,
02280 ecoff_swap_fdr_in,
02281 ecoff_swap_rfd_in,
02282 ecoff_swap_ext_in,
02283 _bfd_ecoff_swap_tir_in,
02284 _bfd_ecoff_swap_rndx_in,
02285
02286 ecoff_swap_hdr_out,
02287 ecoff_swap_dnr_out,
02288 ecoff_swap_pdr_out,
02289 ecoff_swap_sym_out,
02290 ecoff_swap_opt_out,
02291 ecoff_swap_fdr_out,
02292 ecoff_swap_rfd_out,
02293 ecoff_swap_ext_out,
02294 _bfd_ecoff_swap_tir_out,
02295 _bfd_ecoff_swap_rndx_out,
02296
02297 _bfd_mips_elf_read_ecoff_info
02298 };
02299
02300 #define ELF_ARCH bfd_arch_mips
02301 #define ELF_MACHINE_CODE EM_MIPS
02302
02303 #define elf_backend_collect TRUE
02304 #define elf_backend_type_change_ok TRUE
02305 #define elf_backend_can_gc_sections TRUE
02306 #define elf_info_to_howto mips_info_to_howto_rela
02307 #define elf_info_to_howto_rel mips_info_to_howto_rel
02308 #define elf_backend_sym_is_global mips_elf_sym_is_global
02309 #define elf_backend_object_p mips_elf_n32_object_p
02310 #define elf_backend_symbol_processing _bfd_mips_elf_symbol_processing
02311 #define elf_backend_section_processing _bfd_mips_elf_section_processing
02312 #define elf_backend_section_from_shdr _bfd_mips_elf_section_from_shdr
02313 #define elf_backend_fake_sections _bfd_mips_elf_fake_sections
02314 #define elf_backend_section_from_bfd_section \
02315 _bfd_mips_elf_section_from_bfd_section
02316 #define elf_backend_add_symbol_hook _bfd_mips_elf_add_symbol_hook
02317 #define elf_backend_link_output_symbol_hook \
02318 _bfd_mips_elf_link_output_symbol_hook
02319 #define elf_backend_create_dynamic_sections \
02320 _bfd_mips_elf_create_dynamic_sections
02321 #define elf_backend_check_relocs _bfd_mips_elf_check_relocs
02322 #define elf_backend_adjust_dynamic_symbol \
02323 _bfd_mips_elf_adjust_dynamic_symbol
02324 #define elf_backend_always_size_sections \
02325 _bfd_mips_elf_always_size_sections
02326 #define elf_backend_size_dynamic_sections \
02327 _bfd_mips_elf_size_dynamic_sections
02328 #define elf_backend_relocate_section _bfd_mips_elf_relocate_section
02329 #define elf_backend_finish_dynamic_symbol \
02330 _bfd_mips_elf_finish_dynamic_symbol
02331 #define elf_backend_finish_dynamic_sections \
02332 _bfd_mips_elf_finish_dynamic_sections
02333 #define elf_backend_final_write_processing \
02334 _bfd_mips_elf_final_write_processing
02335 #define elf_backend_additional_program_headers \
02336 _bfd_mips_elf_additional_program_headers
02337 #define elf_backend_modify_segment_map _bfd_mips_elf_modify_segment_map
02338 #define elf_backend_gc_mark_hook _bfd_mips_elf_gc_mark_hook
02339 #define elf_backend_gc_sweep_hook _bfd_mips_elf_gc_sweep_hook
02340 #define elf_backend_copy_indirect_symbol \
02341 _bfd_mips_elf_copy_indirect_symbol
02342 #define elf_backend_hide_symbol _bfd_mips_elf_hide_symbol
02343 #define elf_backend_grok_prstatus elf32_mips_grok_prstatus
02344 #define elf_backend_grok_psinfo elf32_mips_grok_psinfo
02345 #define elf_backend_ecoff_debug_swap &mips_elf32_ecoff_debug_swap
02346
02347 #define elf_backend_got_header_size (4 * MIPS_RESERVED_GOTNO)
02348
02349
02350
02351 #define elf_backend_may_use_rel_p 1
02352 #define elf_backend_may_use_rela_p 1
02353 #define elf_backend_default_use_rela_p 1
02354 #define elf_backend_sign_extend_vma TRUE
02355
02356 #define elf_backend_discard_info _bfd_mips_elf_discard_info
02357 #define elf_backend_ignore_discarded_relocs \
02358 _bfd_mips_elf_ignore_discarded_relocs
02359 #define elf_backend_write_section _bfd_mips_elf_write_section
02360 #define elf_backend_mips_irix_compat elf_n32_mips_irix_compat
02361 #define elf_backend_mips_rtype_to_howto mips_elf_n32_rtype_to_howto
02362 #define bfd_elf32_find_nearest_line _bfd_mips_elf_find_nearest_line
02363 #define bfd_elf32_new_section_hook _bfd_mips_elf_new_section_hook
02364 #define bfd_elf32_set_section_contents _bfd_mips_elf_set_section_contents
02365 #define bfd_elf32_bfd_get_relocated_section_contents \
02366 _bfd_elf_mips_get_relocated_section_contents
02367 #define bfd_elf32_bfd_link_hash_table_create \
02368 _bfd_mips_elf_link_hash_table_create
02369 #define bfd_elf32_bfd_final_link _bfd_mips_elf_final_link
02370 #define bfd_elf32_bfd_merge_private_bfd_data \
02371 _bfd_mips_elf_merge_private_bfd_data
02372 #define bfd_elf32_bfd_set_private_flags _bfd_mips_elf_set_private_flags
02373 #define bfd_elf32_bfd_print_private_bfd_data \
02374 _bfd_mips_elf_print_private_bfd_data
02375 #define bfd_elf32_bfd_relax_section _bfd_mips_relax_section
02376
02377
02378
02379 #define TARGET_LITTLE_SYM bfd_elf32_nlittlemips_vec
02380 #define TARGET_LITTLE_NAME "elf32-nlittlemips"
02381 #define TARGET_BIG_SYM bfd_elf32_nbigmips_vec
02382 #define TARGET_BIG_NAME "elf32-nbigmips"
02383
02384
02385
02386
02387 #define ELF_MAXPAGESIZE 0x1000
02388
02389 #include "elf32-target.h"
02390
02391
02392 #undef TARGET_LITTLE_SYM
02393 #undef TARGET_LITTLE_NAME
02394 #undef TARGET_BIG_SYM
02395 #undef TARGET_BIG_NAME
02396
02397 #undef ELF_MAXPAGESIZE
02398
02399 #define TARGET_LITTLE_SYM bfd_elf32_ntradlittlemips_vec
02400 #define TARGET_LITTLE_NAME "elf32-ntradlittlemips"
02401 #define TARGET_BIG_SYM bfd_elf32_ntradbigmips_vec
02402 #define TARGET_BIG_NAME "elf32-ntradbigmips"
02403
02404
02405
02406 #define ELF_MAXPAGESIZE 0x10000
02407 #define elf32_bed elf32_tradbed
02408
02409
02410 #include "elf32-target.h"