[ARM] PR ld/21402, only override the symbol dynamic decision on undefined weak symbol

Jiong Wang wong.kwongyuan.tools@gmail.com
Mon Oct 2 14:04:00 GMT 2017


>>                     /* If we are not emitting relocations for a
>>                        general dynamic reference, then we must be in a
>>                        static link or an executable link with the
>>                        symbol binding locally.  Mark it as belonging
>>                        to module 1, the executable.  */
>>                     bfd_put_32 (output_bfd, 1,
>>                                 sgot->contents + cur_off);
>>                     bfd_put_32 (output_bfd, value - dtpoff_base (info),
>>                                 sgot->contents + cur_off + 4);
>>                   }

Renlin,

  Thanks for the explanation.

  I had misread the testcase, as the symbols prefixed with "app" are all defined
in the module and linked into executable, it is safe to resolve the module index
and offset into and against module 1 during static linking stage.

  Changes on TLS testcase looks good to me.

Regards,
Jiong

>
>> diff --git a/ld/testsuite/ld-arm/unresolved-1-dyn.d
>> b/ld/testsuite/ld-arm/unresolved-1-dyn.d
>> index 21cd959..529da37 100644
>> --- a/ld/testsuite/ld-arm/unresolved-1-dyn.d
>> +++ b/ld/testsuite/ld-arm/unresolved-1-dyn.d
>> @@ -5,4 +5,4 @@
>>
>>  Relocation section '\.rel\.dyn' .*
>>   Offset .*
>> -.* R_ARM_GLOB_DAT +00000000 +foo
>> +^.*  00000000 R_ARM_NONE.+
>
>
>
> Initially, symbol FOO will request a slot in GOT table.
> Once the dynamic section is created, it will reserve a slot for GOT entry's
> R_ARM_GLOB_DAT relocation. It's initialized to zero. And this is the same
> value for R_ARM_NONE relocation.
>
> At the moment, the srelgot->reloc_count is not synchronized with
> srelgot->size.
> In this particular case:
> srelgot->reloc_count == 0
> srelgot->size == 8
>
> Originally, when the symbol FOO is recored as dynamic symbol. A
> R_ARM_GLOB_DAT will be create against its GOT slot. And this relocation will
> use the space reserved above as
> the srelgot->reloc_count is zero. That's why there is only a R_ARM_GLOB_DAT
> relocation for foo in the relocation table before the change here.
>
> After the change, FOO is not put into the dynamic symbol table. And there is
> no R_ARM_RELATIVE elocation created for it as we don't create this for
> non-pic case.
>
> And I think, when readelf dump the relocation table, the only the size is
> used. And 0s are dumped as R_ARM_NONE.
>
> It looks this part could be cleaned a little bit.
>
> Regards,
> Renlin
>
>
> On 27/09/17 10:07, Jiong Wang wrote:
>>>
>>>      * testsuite/ld-arm/tls-app.d: Update address.
>>>      * testsuite/ld-arm/tls-app.r: Remove relocations.
>>
>>
>> Hi Renlin,
>>
>>    I have concerns on these testcases changes.
>>
>>    They look not like something straightforward to understand.
>>
>>    Could you explain why some dynamic TLS relocations are removed? This
>> patch doesn't touch TLS relaxation, so how could some dynamic TLS
>> relocations been resolved at static linking time?
>>
>>    My concern is this patch has break some internal logic that caused
>> runtime TLS relocations missing, this will cause wrong tls address
>> returned.
>>
>>   >     * testsuite/ld-arm/unresolved-1-dyn.d: Update.
>>
>>     This looks to me is redundant dynamic relocation that the linker
>> should not generate it at all.
>>
>> Regards,
>> Jiong
>>
>



More information about the Binutils mailing list