This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [committed, PATCH] Always create dynsym section with dynamic sections
- From: Faraz Shahbazker <faraz dot shahbazker at imgtec dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Fri, 22 Apr 2016 19:31:43 -0700
- Subject: Re: [committed, PATCH] Always create dynsym section with dynamic sections
- Authentication-results: sourceware.org; auth=none
- References: <20160223003208 dot GA30022 at intel dot com> <571A59A8 dot 4000700 at imgtec dot com> <CAMe9rOqr+E11vmpMV4Fo8Js_nCdsrcKpWKXQCUy+qSjjod=_hg at mail dot gmail dot com> <571A73BE dot 4000709 at imgtec dot com> <CAMe9rOp4nZHfL2=st5-fap84C7zOnnyjrU7e0_+QWe1jYhK6cw at mail dot gmail dot com> <DCB1C42372B1674B8F912A294CCB775A92D4E930 at BADAG02 dot ba dot imgtec dot org> <CAMe9rOpZECsq2U4Gb5CJw=y-vhmd_kDmTa0nZf+eqqTRUqDBKw at mail dot gmail dot com> <571AD1EE dot 1040005 at imgtec dot com> <CAMe9rOrcnGADH4w=-Zv8A7iXj9SjKzb5yGVcqeaLh60-tgjRtA at mail dot gmail dot com>
On 04/22/16 19:05, H.J. Lu wrote:
> On Fri, Apr 22, 2016 at 6:37 PM, Faraz Shahbazker
> <faraz.shahbazker@imgtec.com> wrote:
>> On 04/22/16 16:24, H.J. Lu wrote:
>>> On Fri, Apr 22, 2016 at 2:49 PM, Faraz Shahbazker
>>> <Faraz.Shahbazker@imgtec.com> wrote:
>>>> On 04/22/2016 12:28 PM, H.J. Lu wrote:
>>>>> On Fri, Apr 22, 2016 at 11:55 AM, Faraz Shahbazker
>>>>>> + if (dynsymcount != 0 || elf_hash_table (info)->dynamic_sections_created)
>>>>>> + ++dynsymcount;
>>>>>
>>>>> Are you saying dynamic_sections_created is 0 for MIPS here
>>>>> and will become 1 later?
>>>>
>>>> No, it will remain 0. The link is static, but the hash_table is still used to
>>>> record global symbols that have GOT relocations against them. Ofc, this
>>>> hash_table does not result in creation of a dynsym section, because well,
>>>> dynamic_sections_created is 0.
>>>>
>>>> Check the list of callers to bfd_elf_link_record_dynamic_symbol(), a number of
>>>> architectures use the link_hash_table in situations where it is not clear whether it is
>>>> being used to track dynamic symbols for a dynamic executable, as it is for x86.
>>>>
>>>
>>> So MIPS doesn't have dynamic symbols in this case. It just borrows
>>> dynsymcount for different purpose. Is this correct?
>>
>> Not quite! MIPS is expecting dynsymcount to count the number of symbols
>> that would have gone in to the .dynsym, even for a static executable. That way
>> parts of the arch-specific code can remain agnostic to the static/dynamic nature
>> of the link. It may not be used exactly as documented, but its not being used
>> for what one would call a different purpose.
>>
>> All we need is for handling of dynsymcount when renumbering to be consistent with
>> its initialization. If the initial increment for a NULL symbol was not gated by
>> dynamic_sections_created, then the increment when renumbering should also not.
>> If the increment when renumbering has to be gated by dynamic_sections_created,
>> then the initial increment must also be so.
>
> From what you are saying, shouldn't dynsymcount be incremented
> unconditionally?
No. Always, when the table is non-empty + whatever else you need.
Faraz Shahbazker