diff mbox

[AARCH64] set DF_STATIC_TLS when emitting IE relocs

Message ID 20140512171906.GA21081@redacted.bos.redhat.com
State New
Headers show

Commit Message

Kyle McMartin May 12, 2014, 5:19 p.m. UTC
For consistency with other architectures, set DF_STATIC_TLS in
shared libraries which will consume static TLS slots when loaded.

2014-05-12  Kyle McMartin <kyle@redhat.com>

    * elfnn-aarch64.c (elfNN_aarch64_check_relocs): Set DF_STATIC_TLS
      when emitting initial-exec relocs and not linking an executable.
---
 bfd/elfnn-aarch64.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Will Newton May 13, 2014, 7:49 a.m. UTC | #1
On 12 May 2014 18:19, Kyle McMartin <kmcmarti@redhat.com> wrote:
> For consistency with other architectures, set DF_STATIC_TLS in
> shared libraries which will consume static TLS slots when loaded.
>
> 2014-05-12  Kyle McMartin <kyle@redhat.com>
>
>     * elfnn-aarch64.c (elfNN_aarch64_check_relocs): Set DF_STATIC_TLS
>       when emitting initial-exec relocs and not linking an executable.
> ---
>  bfd/elfnn-aarch64.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
> index 498b7bd..229407e 100644
> --- a/bfd/elfnn-aarch64.c
> +++ b/bfd/elfnn-aarch64.c
> @@ -5272,6 +5272,9 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info,
>             if ((got_type & GOT_TLS_IE) && GOT_TLS_GD_ANY_P (got_type))
>               got_type &= ~ (GOT_TLSDESC_GD | GOT_TLS_GD);
>
> +           if (!info->executable && (got_type & GOT_TLS_IE))
> +             info->flags |= DF_STATIC_TLS;
> +
>             if (old_got_type != got_type)
>               {
>                 if (h != NULL)

This looks ok in principle, but I have a couple of questions.

In the aarch64 version we test the got_type after merging TLS methods
but in the arm version we test before. Is there a reason for that? Can
it make any difference? We should probably be consistent in any case.

Is it possible to write a test for this?

Thanks,
Kyle McMartin May 13, 2014, 2:14 p.m. UTC | #2
On Tue, May 13, 2014 at 08:49:51AM +0100, Will Newton wrote:
> > --- a/bfd/elfnn-aarch64.c
> > +++ b/bfd/elfnn-aarch64.c
> > @@ -5272,6 +5272,9 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info,
> >             if ((got_type & GOT_TLS_IE) && GOT_TLS_GD_ANY_P (got_type))
> >               got_type &= ~ (GOT_TLSDESC_GD | GOT_TLS_GD);
> >
> > +           if (!info->executable && (got_type & GOT_TLS_IE))
> > +             info->flags |= DF_STATIC_TLS;
> > +
> >             if (old_got_type != got_type)
> >               {
> >                 if (h != NULL)
> 
> This looks ok in principle, but I have a couple of questions.
> 
> In the aarch64 version we test the got_type after merging TLS methods
> but in the arm version we test before. Is there a reason for that? Can
> it make any difference? We should probably be consistent in any case.
> 

I'll fix this to be consistent between the two. It shouldn't make any
difference because we never clear the TLS_IE flag.

> Is it possible to write a test for this?
>

Yeah, I'll resubmit with a test case as soon as I finish writing a
testcase for another TLS issue in glibc. :/

--Kyle
Nick Clifton June 17, 2014, 11:08 a.m. UTC | #3
Hi Kyle,

>> In the aarch64 version we test the got_type after merging TLS methods
>> but in the arm version we test before. Is there a reason for that? Can
>> it make any difference? We should probably be consistent in any case.
>>
>
> I'll fix this to be consistent between the two. It shouldn't make any
> difference because we never clear the TLS_IE flag.
>
>> Is it possible to write a test for this?
>>
>
> Yeah, I'll resubmit with a test case as soon as I finish writing a
> testcase for another TLS issue in glibc. :/


Has there been any progress on this ?

Cheers
   Nick
Kyle McMartin June 18, 2014, 3:30 p.m. UTC | #4
On Tue, Jun 17, 2014 at 12:08:07PM +0100, Nicholas Clifton wrote:
> Hi Kyle,
> 
> >>In the aarch64 version we test the got_type after merging TLS methods
> >>but in the arm version we test before. Is there a reason for that? Can
> >>it make any difference? We should probably be consistent in any case.
> >>
> >
> >I'll fix this to be consistent between the two. It shouldn't make any
> >difference because we never clear the TLS_IE flag.
> >
> >>Is it possible to write a test for this?
> >>
> >
> >Yeah, I'll resubmit with a test case as soon as I finish writing a
> >testcase for another TLS issue in glibc. :/
> 
> 
> Has there been any progress on this ?
> 

Sorry, I've been horribly busy with other things... I'll send an update
patch today.

regards, Kyle
diff mbox

Patch

diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 498b7bd..229407e 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -5272,6 +5272,9 @@  elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info,
 	    if ((got_type & GOT_TLS_IE) && GOT_TLS_GD_ANY_P (got_type))
 	      got_type &= ~ (GOT_TLSDESC_GD | GOT_TLS_GD);
 
+	    if (!info->executable && (got_type & GOT_TLS_IE))
+	      info->flags |= DF_STATIC_TLS;
+
 	    if (old_got_type != got_type)
 	      {
 		if (h != NULL)