[v1] LoongArch: Add elfNN_loongarch_mkobject to initialize LoongArch tdata

Message ID 20240906010012.910300-1-wangxin03@loongson.cn
State New
Headers
Series [v1] LoongArch: Add elfNN_loongarch_mkobject to initialize LoongArch tdata |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed

Commit Message

ywgrit Sept. 6, 2024, 1 a.m. UTC
  LoongArch: Add elfNN_loongarch_mkobject to initialize LoongArch tdata.
  

Comments

Lulu Cai Sept. 18, 2024, 7:07 a.m. UTC | #1
Thanks, the patch has been applied.

On 9/6/24 9:00 AM, Xin Wang wrote:
> LoongArch: Add elfNN_loongarch_mkobject to initialize LoongArch tdata.
>
> diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
> index 69d81533a67..3e09579f018 100644
> --- a/bfd/elfnn-loongarch.c
> +++ b/bfd/elfnn-loongarch.c
> @@ -84,6 +84,14 @@ struct _bfd_loongarch_elf_obj_tdata
>      && elf_tdata (bfd) != NULL						\
>      && elf_object_id (bfd) == LARCH_ELF_DATA)
>   
> +static bool
> +elfNN_loongarch_object (bfd *abfd)
> +{
> +  return bfd_elf_allocate_object (abfd,
> +				  sizeof (struct _bfd_loongarch_elf_obj_tdata),
> +				  LARCH_ELF_DATA);
> +}
> +
>   struct relr_entry
>   {
>     asection *sec;
> @@ -6144,6 +6152,8 @@ elf_loongarch64_hash_symbol (struct elf_link_hash_entry *h)
>   #define bfd_elfNN_bfd_reloc_name_lookup loongarch_reloc_name_lookup
>   #define elf_info_to_howto_rel NULL /* Fall through to elf_info_to_howto.  */
>   #define elf_info_to_howto loongarch_info_to_howto_rela
> +#define bfd_elfNN_mkobject						  \
> +  elfNN_loongarch_object
>   #define bfd_elfNN_bfd_merge_private_bfd_data				  \
>     elfNN_loongarch_merge_private_bfd_data
>
  
Xi Ruoyao Oct. 9, 2024, 5:48 p.m. UTC | #2
On Wed, 2024-09-18 at 15:07 +0800, Lulu Cai wrote:
> 
> Thanks, the patch has been applied.

Hi,

2.43.1 can crash due to uninitialized tdata, for e.g. building Python
3.13.0 with PGO+LTO.  So IMO this should be backport this to 2.42 & 2.43
release branches as well.

Thanks!

> On 9/6/24 9:00 AM, Xin Wang wrote:
> > LoongArch: Add elfNN_loongarch_mkobject to initialize LoongArch
> > tdata.
> > 
> > diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
> > index 69d81533a67..3e09579f018 100644
> > --- a/bfd/elfnn-loongarch.c
> > +++ b/bfd/elfnn-loongarch.c
> > @@ -84,6 +84,14 @@ struct _bfd_loongarch_elf_obj_tdata
> >      && elf_tdata (bfd) !=
> > NULL						\
> >      && elf_object_id (bfd) == LARCH_ELF_DATA)
> >   
> > +static bool
> > +elfNN_loongarch_object (bfd *abfd)
> > +{
> > +  return bfd_elf_allocate_object (abfd,
> > +				  sizeof (struct
> > _bfd_loongarch_elf_obj_tdata),
> > +				  LARCH_ELF_DATA);
> > +}
> > +
> >   struct relr_entry
> >   {
> >     asection *sec;
> > @@ -6144,6 +6152,8 @@ elf_loongarch64_hash_symbol (struct
> > elf_link_hash_entry *h)
> >   #define bfd_elfNN_bfd_reloc_name_lookup
> > loongarch_reloc_name_lookup
> >   #define elf_info_to_howto_rel NULL /* Fall through to
> > elf_info_to_howto.  */
> >   #define elf_info_to_howto loongarch_info_to_howto_rela
> > +#define
> > bfd_elfNN_mkobject						  \
> > +  elfNN_loongarch_object
> >   #define
> > bfd_elfNN_bfd_merge_private_bfd_data				  \
> >     elfNN_loongarch_merge_private_bfd_data
> >   
> 
>
  
Lulu Cai Oct. 14, 2024, 1:13 a.m. UTC | #3
On 10/10/24 1:48 AM, Xi Ruoyao wrote:
> On Wed, 2024-09-18 at 15:07 +0800, Lulu Cai wrote:
>> Thanks, the patch has been applied.
> Hi,
>
> 2.43.1 can crash due to uninitialized tdata, for e.g. building Python
> 3.13.0 with PGO+LTO.  So IMO this should be backport this to 2.42 & 2.43
> release branches as well.
>
> Thanks!

Thanks, I'll deal with this later.

>> On 9/6/24 9:00 AM, Xin Wang wrote:
>>> LoongArch: Add elfNN_loongarch_mkobject to initialize LoongArch
>>> tdata.
>>>
>>> diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
>>> index 69d81533a67..3e09579f018 100644
>>> --- a/bfd/elfnn-loongarch.c
>>> +++ b/bfd/elfnn-loongarch.c
>>> @@ -84,6 +84,14 @@ struct _bfd_loongarch_elf_obj_tdata
>>>       && elf_tdata (bfd) !=
>>> NULL						\
>>>       && elf_object_id (bfd) == LARCH_ELF_DATA)
>>>    
>>> +static bool
>>> +elfNN_loongarch_object (bfd *abfd)
>>> +{
>>> +  return bfd_elf_allocate_object (abfd,
>>> +				  sizeof (struct
>>> _bfd_loongarch_elf_obj_tdata),
>>> +				  LARCH_ELF_DATA);
>>> +}
>>> +
>>>    struct relr_entry
>>>    {
>>>      asection *sec;
>>> @@ -6144,6 +6152,8 @@ elf_loongarch64_hash_symbol (struct
>>> elf_link_hash_entry *h)
>>>    #define bfd_elfNN_bfd_reloc_name_lookup
>>> loongarch_reloc_name_lookup
>>>    #define elf_info_to_howto_rel NULL /* Fall through to
>>> elf_info_to_howto.  */
>>>    #define elf_info_to_howto loongarch_info_to_howto_rela
>>> +#define
>>> bfd_elfNN_mkobject						  \
>>> +  elfNN_loongarch_object
>>>    #define
>>> bfd_elfNN_bfd_merge_private_bfd_data				  \
>>>      elfNN_loongarch_merge_private_bfd_data
>>>    
>>
  
Lulu Cai Nov. 1, 2024, 6:13 a.m. UTC | #4
On 10/10/24 1:48 AM, Xi Ruoyao wrote:
> On Wed, 2024-09-18 at 15:07 +0800, Lulu Cai wrote:
>> Thanks, the patch has been applied.
> Hi,
>
> 2.43.1 can crash due to uninitialized tdata, for e.g. building Python
> 3.13.0 with PGO+LTO.  So IMO this should be backport this to 2.42 & 2.43
> release branches as well.
>
> Thanks!
>

This patch has been backported to the 2.42 and 2.43 branches, thanks.

>> On 9/6/24 9:00 AM, Xin Wang wrote:
>>> LoongArch: Add elfNN_loongarch_mkobject to initialize LoongArch
>>> tdata.
>>>
>>> diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
>>> index 69d81533a67..3e09579f018 100644
>>> --- a/bfd/elfnn-loongarch.c
>>> +++ b/bfd/elfnn-loongarch.c
>>> @@ -84,6 +84,14 @@ struct _bfd_loongarch_elf_obj_tdata
>>>       && elf_tdata (bfd) !=
>>> NULL						\
>>>       && elf_object_id (bfd) == LARCH_ELF_DATA)
>>>    
>>> +static bool
>>> +elfNN_loongarch_object (bfd *abfd)
>>> +{
>>> +  return bfd_elf_allocate_object (abfd,
>>> +				  sizeof (struct
>>> _bfd_loongarch_elf_obj_tdata),
>>> +				  LARCH_ELF_DATA);
>>> +}
>>> +
>>>    struct relr_entry
>>>    {
>>>      asection *sec;
>>> @@ -6144,6 +6152,8 @@ elf_loongarch64_hash_symbol (struct
>>> elf_link_hash_entry *h)
>>>    #define bfd_elfNN_bfd_reloc_name_lookup
>>> loongarch_reloc_name_lookup
>>>    #define elf_info_to_howto_rel NULL /* Fall through to
>>> elf_info_to_howto.  */
>>>    #define elf_info_to_howto loongarch_info_to_howto_rela
>>> +#define
>>> bfd_elfNN_mkobject						  \
>>> +  elfNN_loongarch_object
>>>    #define
>>> bfd_elfNN_bfd_merge_private_bfd_data				  \
>>>      elfNN_loongarch_merge_private_bfd_data
>>>    
>>
  

Patch

diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
index 69d81533a67..3e09579f018 100644
--- a/bfd/elfnn-loongarch.c
+++ b/bfd/elfnn-loongarch.c
@@ -84,6 +84,14 @@  struct _bfd_loongarch_elf_obj_tdata
    && elf_tdata (bfd) != NULL						\
    && elf_object_id (bfd) == LARCH_ELF_DATA)
 
+static bool
+elfNN_loongarch_object (bfd *abfd)
+{
+  return bfd_elf_allocate_object (abfd,
+				  sizeof (struct _bfd_loongarch_elf_obj_tdata),
+				  LARCH_ELF_DATA);
+}
+
 struct relr_entry
 {
   asection *sec;
@@ -6144,6 +6152,8 @@  elf_loongarch64_hash_symbol (struct elf_link_hash_entry *h)
 #define bfd_elfNN_bfd_reloc_name_lookup loongarch_reloc_name_lookup
 #define elf_info_to_howto_rel NULL /* Fall through to elf_info_to_howto.  */
 #define elf_info_to_howto loongarch_info_to_howto_rela
+#define bfd_elfNN_mkobject						  \
+  elfNN_loongarch_object
 #define bfd_elfNN_bfd_merge_private_bfd_data				  \
   elfNN_loongarch_merge_private_bfd_data