[Bug,16340,AARCH64] Offset into GOT for TLS relocation computed inconsistently

Message ID 52B4008F.1000403@linaro.org
State Accepted
Headers show

Commit Message

Kugan Vivekanandarajah Dec. 20, 2013, 8:32 a.m.
[Apologies if you get this twice; Noticed a typo with email address]

Hi,

mongodb for aarch64 segfaults due to an error in applying GOT for TLS
relocation. Michael Hudson-Doyle tracked this down to wrong usage of
offset for the relocation. Attached patch (by Michael Hudson-Doyle)
fixes this. Regression tested on aarch64-none-linux-gnu with no new
regressions.

Is this OK for trunk and backport for 2.24?

Thanks,
Kugan


bfd/
+2013-12-19  Michael Hudson-Doyle  <michael.hudson@linaro.org>
+
+	* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Use correct
+	offset for GOT in TLS while calculating relocation address.
+

Comments

Christophe Lyon Jan. 13, 2014, 3:36 p.m. | #1
On 28 December 2013 02:26, Kugan <kugan.vivekanandarajah@linaro.org> wrote:
> On 22/12/13 12:47, Alan Modra wrote:
>> On Fri, Dec 20, 2013 at 07:32:15PM +1100, Kugan wrote:
>>> [Apologies if you get this twice; Noticed a typo with email address]
>>>
>>> Hi,
>>>
>>> mongodb for aarch64 segfaults due to an error in applying GOT for TLS
>>> relocation. Michael Hudson-Doyle tracked this down to wrong usage of
>>> offset for the relocation. Attached patch (by Michael Hudson-Doyle)
>>> fixes this. Regression tested on aarch64-none-linux-gnu with no new
>>> regressions.
>>>
>>> Is this OK for trunk and backport for 2.24?
>>
>> Looks good to me.  There are two more occurrences of
>> output_section->output_offset in elfnn-aarch64.c.  Please fix those
>> too.
>>
>
> Thanks Alan for the review. Please fond the patch attached which changes
> it. make check for binutils, gas and ld has no new regression with the
> patch.
>

Hi Alan,

Is this version OK?

Thanks,

Christophe.

> Thanks,
> Kugan
>
> bfd/
> +2013-12-28  Michael Hudson-Doyle  <michael.hudson@linaro.org>
> +
> +       * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Use correct
> +       offset while calculating relocation address.
> +       * elfnn-aarch64.c (elfNN_aarch64_create_small_pltn_entry): Use correct
> +       offset while calculating relocation address.
> +
>
Will Newton Jan. 24, 2014, 3:59 p.m. | #2
On 14 January 2014 04:16, Alan Modra <amodra@gmail.com> wrote:
> On Mon, Jan 13, 2014 at 04:36:41PM +0100, Christophe Lyon wrote:
>> On 28 December 2013 02:26, Kugan <kugan.vivekanandarajah@linaro.org> wrote:
>> > On 22/12/13 12:47, Alan Modra wrote:
>> >> On Fri, Dec 20, 2013 at 07:32:15PM +1100, Kugan wrote:
>> >>> [Apologies if you get this twice; Noticed a typo with email address]
>> >>>
>> >>> Hi,
>> >>>
>> >>> mongodb for aarch64 segfaults due to an error in applying GOT for TLS
>> >>> relocation. Michael Hudson-Doyle tracked this down to wrong usage of
>> >>> offset for the relocation. Attached patch (by Michael Hudson-Doyle)
>> >>> fixes this. Regression tested on aarch64-none-linux-gnu with no new
>> >>> regressions.
>> >>>
>> >>> Is this OK for trunk and backport for 2.24?
>> >>
>> >> Looks good to me.  There are two more occurrences of
>> >> output_section->output_offset in elfnn-aarch64.c.  Please fix those
>> >> too.
>> >>
>> >
>> > Thanks Alan for the review. Please fond the patch attached which changes
>> > it. make check for binutils, gas and ld has no new regression with the
>> > patch.
>> >
>>
>> Hi Alan,
>>
>> Is this version OK?
>
> Yes, it's good.  I meant my previous reply as an OK for the patch as
> posted plus preapproval for the extra fixes.  Sorry if that wasn't clear.

Is this patch ok for the 2.24 branch too?

Thanks,
Will Newton March 3, 2014, 6:10 a.m. | #3
On 24 January 2014 15:59, Will Newton <will.newton@linaro.org> wrote:
> On 14 January 2014 04:16, Alan Modra <amodra@gmail.com> wrote:
>> On Mon, Jan 13, 2014 at 04:36:41PM +0100, Christophe Lyon wrote:
>>> On 28 December 2013 02:26, Kugan <kugan.vivekanandarajah@linaro.org> wrote:
>>> > On 22/12/13 12:47, Alan Modra wrote:
>>> >> On Fri, Dec 20, 2013 at 07:32:15PM +1100, Kugan wrote:
>>> >>> [Apologies if you get this twice; Noticed a typo with email address]
>>> >>>
>>> >>> Hi,
>>> >>>
>>> >>> mongodb for aarch64 segfaults due to an error in applying GOT for TLS
>>> >>> relocation. Michael Hudson-Doyle tracked this down to wrong usage of
>>> >>> offset for the relocation. Attached patch (by Michael Hudson-Doyle)
>>> >>> fixes this. Regression tested on aarch64-none-linux-gnu with no new
>>> >>> regressions.
>>> >>>
>>> >>> Is this OK for trunk and backport for 2.24?
>>> >>
>>> >> Looks good to me.  There are two more occurrences of
>>> >> output_section->output_offset in elfnn-aarch64.c.  Please fix those
>>> >> too.
>>> >>
>>> >
>>> > Thanks Alan for the review. Please fond the patch attached which changes
>>> > it. make check for binutils, gas and ld has no new regression with the
>>> > patch.
>>> >
>>>
>>> Hi Alan,
>>>
>>> Is this version OK?
>>
>> Yes, it's good.  I meant my previous reply as an OK for the patch as
>> posted plus preapproval for the extra fixes.  Sorry if that wasn't clear.
>
> Is this patch ok for the 2.24 branch too?

Ping for 2.24?

Thanks,
Marcus Shawcroft March 6, 2014, 11:19 a.m. | #4
>> Is this patch ok for the 2.24 branch too?
>
> Ping for 2.24?
>
> Thanks,
>
> --
> Will Newton
> Toolchain Working Group, Linaro

This is Ok for 2.24.

/Marcus

Patch

diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 8f0e716..e1ab769 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -3831,7 +3831,7 @@  elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
 
       value = (symbol_got_offset (input_bfd, h, r_symndx)
 	       + globals->root.sgot->output_section->vma
-	       + globals->root.sgot->output_section->output_offset);
+	       + globals->root.sgot->output_offset);
 
       value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value,
 						   0, weak_undef_p);
@@ -3863,7 +3863,7 @@  elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
 
       value = (symbol_tlsdesc_got_offset (input_bfd, h, r_symndx)
 	       + globals->root.sgotplt->output_section->vma
-	       + globals->root.sgotplt->output_section->output_offset
+	       + globals->root.sgotplt->output_offset
 	       + globals->sgotplt_jump_table_size);
 
       value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value,