LoongArch: Do not add DF_STATIC_TLS for TLS LE
Checks
Commit Message
TLS LE is exclusively for executables, while DF_STATIC_TLS is for DLLs.
DF_STATIC_TLS should only be set for TLS IE (and when it's DLL), not LE.
---
bfd/elfnn-loongarch.c | 2 --
1 file changed, 2 deletions(-)
Comments
> On Dec 28, 2023, at 23:58, Tatsuyuki Ishi <ishitatsuyuki@gmail.com> wrote:
>
> TLS LE is exclusively for executables, while DF_STATIC_TLS is for DLLs.
> DF_STATIC_TLS should only be set for TLS IE (and when it's DLL), not LE.
> ---
> bfd/elfnn-loongarch.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
> index bd448cda453..64c34e99261 100644
> --- a/bfd/elfnn-loongarch.c
> +++ b/bfd/elfnn-loongarch.c
> @@ -862,8 +862,6 @@ loongarch_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
> if (!bfd_link_executable (info))
> return false;
>
> - info->flags |= DF_STATIC_TLS;
> -
> if (!loongarch_elf_record_tls_and_got_reference (abfd, info, h,
> r_symndx,
> GOT_TLS_LE))
> --
> 2.40.1
>
>
Any interest in reviewing / merging this and the other two patches sent together?
The DF_STATIC_TLS change is pretty short, the formatting patch is trivial.
As for the last patch introducing a comment change, I’m not sure what Mengqing’s stance is, but my intention for the comment change is to provide a better context for the reader rather than comparing to a solution that is not currently implemented in the codebase.
Tatsuyuki.
On Sun, Jan 21, 2024 at 9:45 PM Tatsuyuki Ishi <ishitatsuyuki@gmail.com> wrote:
>
> > On Dec 28, 2023, at 23:58, Tatsuyuki Ishi <ishitatsuyuki@gmail.com> wrote:
> >
> > TLS LE is exclusively for executables, while DF_STATIC_TLS is for DLLs.
> > DF_STATIC_TLS should only be set for TLS IE (and when it's DLL), not LE.
> > ---
> > bfd/elfnn-loongarch.c | 2 --
> > 1 file changed, 2 deletions(-)
> >
> > diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
> > index bd448cda453..64c34e99261 100644
> > --- a/bfd/elfnn-loongarch.c
> > +++ b/bfd/elfnn-loongarch.c
> > @@ -862,8 +862,6 @@ loongarch_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
> > if (!bfd_link_executable (info))
> > return false;
> >
> > - info->flags |= DF_STATIC_TLS;
> > -
> > if (!loongarch_elf_record_tls_and_got_reference (abfd, info, h,
> > r_symndx,
> > GOT_TLS_LE))
> > --
> > 2.40.1
> >
> >
>
> Any interest in reviewing / merging this and the other two patches sent together?
> The DF_STATIC_TLS change is pretty short, the formatting patch is trivial.
> As for the last patch introducing a comment change, I’m not sure what Mengqing’s stance is, but my intention for the comment change is to provide a better context for the reader rather than comparing to a solution that is not currently implemented in the codebase.
>
> Tatsuyuki.
I think this is correct and should be applied.
On Sun, 2024-01-21 at 21:48 -0800, Fangrui Song wrote:
> On Sun, Jan 21, 2024 at 9:45 PM Tatsuyuki Ishi <ishitatsuyuki@gmail.com> wrote:
> >
> > > On Dec 28, 2023, at 23:58, Tatsuyuki Ishi <ishitatsuyuki@gmail.com> wrote:
> > >
> > > TLS LE is exclusively for executables, while DF_STATIC_TLS is for DLLs.
> > > DF_STATIC_TLS should only be set for TLS IE (and when it's DLL), not LE.
> > > ---
> > > bfd/elfnn-loongarch.c | 2 --
> > > 1 file changed, 2 deletions(-)
> > >
> > > diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
> > > index bd448cda453..64c34e99261 100644
> > > --- a/bfd/elfnn-loongarch.c
> > > +++ b/bfd/elfnn-loongarch.c
> > > @@ -862,8 +862,6 @@ loongarch_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
> > > if (!bfd_link_executable (info))
> > > return false;
> > >
> > > - info->flags |= DF_STATIC_TLS;
> > > -
> > > if (!loongarch_elf_record_tls_and_got_reference (abfd, info, h,
> > > r_symndx,
> > > GOT_TLS_LE))
> > > --
> > > 2.40.1
> > >
> > >
> >
> > Any interest in reviewing / merging this and the other two patches sent together?
> > The DF_STATIC_TLS change is pretty short, the formatting patch is trivial.
> > As for the last patch introducing a comment change, I’m not sure what Mengqing’s stance is, but my intention for the comment change is to provide a better context for the reader rather than comparing to a solution that is not currently implemented in the codebase.
> >
> > Tatsuyuki.
>
> I think this is correct and should be applied.
Will this cause a breakage in practice? If so we need to apply it for 2.42 branch too.
On Sun, Jan 21, 2024 at 10:51 PM Xi Ruoyao <xry111@xry111.site> wrote:
>
> On Sun, 2024-01-21 at 21:48 -0800, Fangrui Song wrote:
> > On Sun, Jan 21, 2024 at 9:45 PM Tatsuyuki Ishi <ishitatsuyuki@gmail.com> wrote:
> > >
> > > > On Dec 28, 2023, at 23:58, Tatsuyuki Ishi <ishitatsuyuki@gmail.com> wrote:
> > > >
> > > > TLS LE is exclusively for executables, while DF_STATIC_TLS is for DLLs.
> > > > DF_STATIC_TLS should only be set for TLS IE (and when it's DLL), not LE.
> > > > ---
> > > > bfd/elfnn-loongarch.c | 2 --
> > > > 1 file changed, 2 deletions(-)
> > > >
> > > > diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
> > > > index bd448cda453..64c34e99261 100644
> > > > --- a/bfd/elfnn-loongarch.c
> > > > +++ b/bfd/elfnn-loongarch.c
> > > > @@ -862,8 +862,6 @@ loongarch_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
> > > > if (!bfd_link_executable (info))
> > > > return false;
> > > >
> > > > - info->flags |= DF_STATIC_TLS;
> > > > -
> > > > if (!loongarch_elf_record_tls_and_got_reference (abfd, info, h,
> > > > r_symndx,
> > > > GOT_TLS_LE))
> > > > --
> > > > 2.40.1
> > > >
> > > >
> > >
> > > Any interest in reviewing / merging this and the other two patches sent together?
> > > The DF_STATIC_TLS change is pretty short, the formatting patch is trivial.
> > > As for the last patch introducing a comment change, I’m not sure what Mengqing’s stance is, but my intention for the comment change is to provide a better context for the reader rather than comparing to a solution that is not currently implemented in the codebase.
> > >
> > > Tatsuyuki.
> >
> > I think this is correct and should be applied.
>
> Will this cause a breakage in practice? If so we need to apply it for 2.42 branch too.
No. DF_STATIC_TLS is a not-so-useful dynamic tag. It helps a `readelf
-d` reader to know whether the DSO uses initial-exec.
For lld, I made a similar change in Nov 2021
(https://github.com/llvm/llvm-project/commit/6ca8fde226e907db13bc538e721af8724f0e92d0).
lld before Dec 2022 did not set DF_STATIC_TLS for non-x86
architectures (AArch64 and PPC).
I changed it to set DF_STATIC_TLS.
For both changes nobody has noticed anything.
Thank you very much, I will apply this patch soon.
For the last patch, I think we can add new comments while retaining the
original ones.
The original comments describe another implementation method and can be
compared with the existing ones.
If I wants to allocate GOT entry separately for IE/GD in the future, I
can refer to these comments.
在 2024/1/22 下午1:45, Tatsuyuki Ishi 写道:
>> On Dec 28, 2023, at 23:58, Tatsuyuki Ishi <ishitatsuyuki@gmail.com> wrote:
>>
>> TLS LE is exclusively for executables, while DF_STATIC_TLS is for DLLs.
>> DF_STATIC_TLS should only be set for TLS IE (and when it's DLL), not LE.
>> ---
>> bfd/elfnn-loongarch.c | 2 --
>> 1 file changed, 2 deletions(-)
>>
>> diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
>> index bd448cda453..64c34e99261 100644
>> --- a/bfd/elfnn-loongarch.c
>> +++ b/bfd/elfnn-loongarch.c
>> @@ -862,8 +862,6 @@ loongarch_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
>> if (!bfd_link_executable (info))
>> return false;
>>
>> - info->flags |= DF_STATIC_TLS;
>> -
>> if (!loongarch_elf_record_tls_and_got_reference (abfd, info, h,
>> r_symndx,
>> GOT_TLS_LE))
>> --
>> 2.40.1
>>
>>
> Any interest in reviewing / merging this and the other two patches sent together?
> The DF_STATIC_TLS change is pretty short, the formatting patch is trivial.
> As for the last patch introducing a comment change, I’m not sure what Mengqing’s stance is, but my intention for the comment change is to provide a better context for the reader rather than comparing to a solution that is not currently implemented in the codebase.
>
> Tatsuyuki.
Thank you very much, it has been applied.
在 2023/12/28 下午10:58, Tatsuyuki Ishi 写道:
> TLS LE is exclusively for executables, while DF_STATIC_TLS is for DLLs.
> DF_STATIC_TLS should only be set for TLS IE (and when it's DLL), not LE.
> ---
> bfd/elfnn-loongarch.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
> index bd448cda453..64c34e99261 100644
> --- a/bfd/elfnn-loongarch.c
> +++ b/bfd/elfnn-loongarch.c
> @@ -862,8 +862,6 @@ loongarch_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
> if (!bfd_link_executable (info))
> return false;
>
> - info->flags |= DF_STATIC_TLS;
> -
> if (!loongarch_elf_record_tls_and_got_reference (abfd, info, h,
> r_symndx,
> GOT_TLS_LE))
@@ -862,8 +862,6 @@ loongarch_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
if (!bfd_link_executable (info))
return false;
- info->flags |= DF_STATIC_TLS;
-
if (!loongarch_elf_record_tls_and_got_reference (abfd, info, h,
r_symndx,
GOT_TLS_LE))