loongarch ld testsuite xpasses

mengqinggang mengqinggang@loongson.cn
Wed Aug 7 01:16:19 GMT 2024


Thank you very much, I will keep an eye on this issue.


在 2024/8/7 上午9:01, Alan Modra 写道:
> Some tests started passing with commit 3a83f0342e54.  However,
> supporting a changed ld output format is not so simple, and the change
> to the loongarch_elf_hash_table macro needs further changes to the
> rest of the code.  It is true that some uses of
> loongarch_elf_hash_table do not need to check the type of the hash
> table, but others like loongarch_elf_relax_section do need to check.
> bfd_relax_section is called in lang_size_sections using the input bfd,
> not the output bfd.  If the input bfd may be of different type to the
> output, then the hash table type must be checked before accessing
> elements of the hash table.  This patch corrects
> loongarch_elf_relax_section.  I haven't checked all the uses of the
> hash table throughout the loongarch backend.
>
> bfd/
> 	* elfnn-loongarch.c (loongarch_elf_relax_section): Don't relax
> 	unless the hash table is loongarch_elf_link_hash_table.
> 	Move variable declarations.  Formatting.
> ld/
> 	* testsuite/ld-elf/pr21884.d: Don't xfail loongarach.
> 	* testsuite/ld-unique/pr21529.d: Likewise.
>
> diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
> index 71fa8fa6f01..af8cb2575e7 100644
> --- a/bfd/elfnn-loongarch.c
> +++ b/bfd/elfnn-loongarch.c
> @@ -5247,16 +5247,15 @@ loongarch_get_max_alignment (asection *sec)
>   
>   static bool
>   loongarch_elf_relax_section (bfd *abfd, asection *sec,
> -			       struct bfd_link_info *info,
> -			       bool *again)
> +			     struct bfd_link_info *info,
> +			     bool *again)
>   {
> -  struct loongarch_elf_link_hash_table *htab = loongarch_elf_hash_table (info);
> -  struct bfd_elf_section_data *data = elf_section_data (sec);
> -  Elf_Internal_Shdr *symtab_hdr = &elf_symtab_hdr (abfd);
> -  Elf_Internal_Rela *relocs;
>     *again = false;
> -  bfd_vma max_alignment = 0;
> +  if (!is_elf_hash_table (info->hash)
> +      || elf_hash_table_id (elf_hash_table (info)) != LARCH_ELF_DATA)
> +    return true;
>   
> +  struct loongarch_elf_link_hash_table *htab = loongarch_elf_hash_table (info);
>     if (bfd_link_relocatable (info)
>         || sec->sec_flg0
>         || (sec->flags & SEC_RELOC) == 0
> @@ -5268,6 +5267,8 @@ loongarch_elf_relax_section (bfd *abfd, asection *sec,
>         || *(htab->data_segment_phase) == 4)
>       return true;
>   
> +  struct bfd_elf_section_data *data = elf_section_data (sec);
> +  Elf_Internal_Rela *relocs;
>     if (data->relocs)
>       relocs = data->relocs;
>     else if (!(relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL,
> @@ -5278,6 +5279,7 @@ loongarch_elf_relax_section (bfd *abfd, asection *sec,
>         && !bfd_malloc_and_get_section (abfd, sec, &data->this_hdr.contents))
>       return true;
>   
> +  Elf_Internal_Shdr *symtab_hdr = &elf_symtab_hdr (abfd);
>     if (symtab_hdr->sh_info != 0
>         && !symtab_hdr->contents
>         && !(symtab_hdr->contents =
> @@ -5290,7 +5292,7 @@ loongarch_elf_relax_section (bfd *abfd, asection *sec,
>   
>     /* Estimate the maximum alignment for all output sections once time
>        should be enough.  */
> -  max_alignment = htab->max_alignment;
> +  bfd_vma max_alignment = htab->max_alignment;
>     if (max_alignment == (bfd_vma) -1)
>       {
>         max_alignment = loongarch_get_max_alignment (sec);
> diff --git a/ld/testsuite/ld-elf/pr21884.d b/ld/testsuite/ld-elf/pr21884.d
> index e289b419f8f..3d44ccfe602 100644
> --- a/ld/testsuite/ld-elf/pr21884.d
> +++ b/ld/testsuite/ld-elf/pr21884.d
> @@ -3,7 +3,7 @@
>   #ld: -T pr21884.t
>   #objdump: -b binary -s
>   #xfail: aarch64*-*-* arm*-*-* avr-*-* ia64-*-* m68hc1*-*-* nds32*-*-*
> -#xfail: riscv*-*-* score-*-* v850-*-* loongarch*-*-*
> +#xfail: riscv*-*-* score-*-* v850-*-*
>   # Skip targets which can't change output format to binary.
>   
>   .*:     file format binary
> diff --git a/ld/testsuite/ld-unique/pr21529.d b/ld/testsuite/ld-unique/pr21529.d
> index 896f8722782..fb637943909 100644
> --- a/ld/testsuite/ld-unique/pr21529.d
> +++ b/ld/testsuite/ld-unique/pr21529.d
> @@ -1,6 +1,6 @@
>   #ld: --oformat binary -T pr21529.ld -e main
>   #objdump: -s -b binary
> -#xfail: aarch64*-*-* arm*-*-* avr-*-* ia64-*-* m68hc1*-*-* nds32*-*-* riscv*-*-* score-*-* v850-*-* loongarch*-*-*
> +#xfail: aarch64*-*-* arm*-*-* avr-*-* ia64-*-* m68hc1*-*-* nds32*-*-* riscv*-*-* score-*-* v850-*-*
>   # Skip targets which can't change output format to binary.
>   
>   #pass
>



More information about the Binutils mailing list