[PATCH 4/5] LoongArch: Remove "elf_seg_map (info->output_bfd) == NULL" relaxation condition

Xi Ruoyao xry111@xry111.site
Thu Oct 19 14:04:41 GMT 2023


Hi,

I don't know BFD very well, but IMO this should be applied and
backported to 2.41 ASAP because "not relaxing shared objects" is a very
serious issue.

On Fri, 2023-10-13 at 16:24 +0800, mengqinggang wrote:
> ---
>  bfd/elfnn-loongarch.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
> index 47334943fde..38a25b63813 100644
> --- a/bfd/elfnn-loongarch.c
> +++ b/bfd/elfnn-loongarch.c
> @@ -3747,6 +3747,11 @@ loongarch_relax_pcala_addi (bfd *abfd, asection *sec,
>    uint32_t pca = bfd_get (32, abfd, contents + rel_hi->r_offset);
>    uint32_t add = bfd_get (32, abfd, contents + rel_lo->r_offset);
>    uint32_t rd = pca & 0x1f;
> +
> +  /* Because previous sections' relax, output_offset may increase and need to
> +     be updated before relax. But it update after relax in
> +     size_input_section defaultly, so we manually updating here.  */
> +  sec->output_offset = sec->output_section->size;
>    bfd_vma pc = sec_addr (sec) + rel_hi->r_offset;
>    const uint32_t addi_d = 0x02c00000;
>    const uint32_t pcaddi = 0x18000000;
> @@ -3889,7 +3894,6 @@ loongarch_elf_relax_section (bfd *abfd, asection *sec,
>        || sec->sec_flg0
>        || (sec->flags & SEC_RELOC) == 0
>        || sec->reloc_count == 0
> -      || elf_seg_map (info->output_bfd) == NULL
>        || (info->disable_target_specific_optimizations
>  	  && info->relax_pass == 0)
>        /* The exp_seg_relro_adjust is enum phase_enum (0x4),

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University


More information about the Binutils mailing list