diff options
Diffstat (limited to 'bfd/elfnn-loongarch.c')
-rw-r--r-- | bfd/elfnn-loongarch.c | 113 |
1 files changed, 47 insertions, 66 deletions
diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c index c75f520..1ddea2f 100644 --- a/bfd/elfnn-loongarch.c +++ b/bfd/elfnn-loongarch.c @@ -3403,8 +3403,9 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, name = loongarch_sym_name (input_bfd, h, sym); if (sec != NULL && discarded_section (sec)) - RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, rel, - 1, relend, howto, 0, contents); + RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, + rel, 1, relend, R_LARCH_NONE, + howto, 0, contents); if (bfd_link_relocatable (info)) continue; @@ -5374,22 +5375,17 @@ loongarch_relax_pcala_addi (bfd *abfd, asection *sec, asection *sym_sec, symval = sec_addr (sec) + loongarch_calc_relaxed_addr (info, symval - sec_addr (sec)); - /* If pc and symbol not in the same segment, add/sub segment alignment if the - section has not undergone alignment processing because distances may grow - after alignment. */ - if (!loongarch_sec_closed_for_deletion (sec)) - { - if (!loongarch_two_sections_in_same_segment (info->output_bfd, - sec->output_section, - sym_sec->output_section)) - max_alignment = info->maxpagesize > max_alignment ? info->maxpagesize - : max_alignment; - - if (symval > pc) - pc -= (max_alignment > 4 ? max_alignment : 0); - else if (symval < pc) - pc += (max_alignment > 4 ? max_alignment : 0); - } + /* If pc and symbol not in the same segment, add/sub segment alignment. */ + if (!loongarch_two_sections_in_same_segment (info->output_bfd, + sec->output_section, + sym_sec->output_section)) + max_alignment = info->maxpagesize > max_alignment ? info->maxpagesize + : max_alignment; + + if (symval > pc) + pc -= (max_alignment > 4 ? max_alignment : 0); + else if (symval < pc) + pc += (max_alignment > 4 ? max_alignment : 0); const uint32_t pcaddi = LARCH_OP_PCADDI; @@ -5444,22 +5440,17 @@ loongarch_relax_call36 (bfd *abfd, asection *sec, asection *sym_sec, symval = sec_addr (sec) + loongarch_calc_relaxed_addr (info, symval - sec_addr (sec)); - /* If pc and symbol not in the same segment, add/sub segment alignment if the - section has not undergone alignment processing because distances may grow - after alignment. */ - if (!loongarch_sec_closed_for_deletion (sec)) - { - if (!loongarch_two_sections_in_same_segment (info->output_bfd, - sec->output_section, - sym_sec->output_section)) - max_alignment = info->maxpagesize > max_alignment ? info->maxpagesize - : max_alignment; - - if (symval > pc) - pc -= (max_alignment > 4 ? max_alignment : 0); - else if (symval < pc) - pc += (max_alignment > 4 ? max_alignment : 0); - } + /* If pc and symbol not in the same segment, add/sub segment alignment. */ + if (!loongarch_two_sections_in_same_segment (info->output_bfd, + sec->output_section, + sym_sec->output_section)) + max_alignment = info->maxpagesize > max_alignment ? info->maxpagesize + : max_alignment; + + if (symval > pc) + pc -= (max_alignment > 4 ? max_alignment : 0); + else if (symval < pc) + pc += (max_alignment > 4 ? max_alignment : 0); /* Is pcalau12i + addi.d insns? */ if (!LARCH_INSN_JIRL (jirl) @@ -5513,22 +5504,17 @@ loongarch_relax_pcala_ld (bfd *abfd, asection *sec, symval = sec_addr (sec) + loongarch_calc_relaxed_addr (info, symval - sec_addr (sec)); - /* If pc and symbol not in the same segment, add/sub segment alignment if the - section has not undergone alignment processing because distances may grow - after alignment. */ - if (!loongarch_sec_closed_for_deletion (sec)) - { - if (!loongarch_two_sections_in_same_segment (info->output_bfd, - sec->output_section, - sym_sec->output_section)) - max_alignment = info->maxpagesize > max_alignment ? info->maxpagesize - : max_alignment; - - if (symval > pc) - pc -= (max_alignment > 4 ? max_alignment : 0); - else if (symval < pc) - pc += (max_alignment > 4 ? max_alignment : 0); - } + /* If pc and symbol not in the same segment, add/sub segment alignment. */ + if (!loongarch_two_sections_in_same_segment (info->output_bfd, + sec->output_section, + sym_sec->output_section)) + max_alignment = info->maxpagesize > max_alignment ? info->maxpagesize + : max_alignment; + + if (symval > pc) + pc -= (max_alignment > 4 ? max_alignment : 0); + else if (symval < pc) + pc += (max_alignment > 4 ? max_alignment : 0); if ((ELFNN_R_TYPE (rel_lo->r_info) != R_LARCH_GOT_PC_LO12) || (LARCH_GET_RD (ld) != rd) @@ -5651,22 +5637,17 @@ loongarch_relax_tls_ld_gd_desc (bfd *abfd, asection *sec, asection *sym_sec, symval = sec_addr (sec) + loongarch_calc_relaxed_addr (info, symval - sec_addr (sec)); - /* If pc and symbol not in the same segment, add/sub segment alignment if the - section has not undergone alignment processing because distances may grow - after alignment. */ - if (!loongarch_sec_closed_for_deletion (sec)) - { - if (!loongarch_two_sections_in_same_segment (info->output_bfd, - sec->output_section, - sym_sec->output_section)) - max_alignment = info->maxpagesize > max_alignment ? info->maxpagesize - : max_alignment; - - if (symval > pc) - pc -= (max_alignment > 4 ? max_alignment : 0); - else if (symval < pc) - pc += (max_alignment > 4 ? max_alignment : 0); - } + /* If pc and symbol not in the same segment, add/sub segment alignment. */ + if (!loongarch_two_sections_in_same_segment (info->output_bfd, + sec->output_section, + sym_sec->output_section)) + max_alignment = info->maxpagesize > max_alignment ? info->maxpagesize + : max_alignment; + + if (symval > pc) + pc -= (max_alignment > 4 ? max_alignment : 0); + else if (symval < pc) + pc += (max_alignment > 4 ? max_alignment : 0); const uint32_t pcaddi = LARCH_OP_PCADDI; |