[PATCH v3] elf: Don't set its DT_VERSYM entry for unversioned symbol

Jan Beulich jbeulich@suse.com
Fri Oct 31 07:48:53 GMT 2025
On 31.10.2025 00:21, H.J. Lu wrote:
> On Thu, Oct 30, 2025 at 10:27 PM Jan Beulich <jbeulich@suse.com> wrote:
>>
>> On 29.10.2025 03:09, H.J. Lu wrote:
>>> On Wed, Oct 29, 2025 at 9:54 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>>>>
>>>> Undefined symbol without version shouldn't have the BASE version in its
>>>> DT_VERSYM entry.  Instead its DT_VERSYM entry should be all zero to
>>>> indicate that the symbol doesn't have a version.
>>>>
>>>> bfd/
>>>>
>>>> PR ld/33577
>>>> * elflink.c (elf_link_output_extsym): Don't set its DT_VERSYM
>>>> entry for unversioned symbol.
>>>>
>>>> ld/
>>>>
>>>> PR ld/33577
>>>> * testsuite/ld-elf/undefined.d: New file.
>>>> * testsuite/ld-elf/undefined.map: Likewise.
>>>> * testsuite/ld-elf/undefined.s: Likewise.
>>>>
>>>> OK for master?
>>>
>>> Here is the v2 patch to only check undefined symbols.
>>
>> Just one question: Wouldn't the new testcase be a better fit in ld-elfvers/?
>> If you agree, okay with it moved there.
> 
> Here is the v3 patch with updated tests in ld-elfvers.   I also updated
> elf_link_output_extsym to handle defined symbol without version with
> a test.

I'm irritated by you now altering an existing test, but there being no
new test anymore. Can you clarify this for me, please?

> ---
> 1. Referenced symbol without '@' has no version.
> 2. Defined symbol without the .symver directive has no version if there
> is no linker version script.

As we're talking about the linker, how would the linker know whether there
had been a .symver directive? Possibly related - is strchr() finding an @
(or not) really a sufficient indication? Symbol names can in principle
include @ for other reasons, and I'm not sure how well the versioning
machinery would cope with such.

Jan

> Symbol without version shouldn't have the base version in its DT_VERSYM
> entry.  Instead, its DT_VERSYM entry should be all zero to indicate that
> the symbol doesn't have a version.
> 
> NB: Symbol with the base version has a '@' suffix, like "foo@", defined
> with
> 
> .symver hide_original_foo, foo@
> 
> bfd/
> 
> PR ld/33577
> * elflink.c (elf_link_output_extsym): Don't set its DT_VERSYM
> entry for the symbol without version.
> 
> ld/
> 
> PR ld/33577
> * ld-elfvers/vers16.dsym: Remove the "Base" version on symbols
> without version.



More information about the Binutils mailing list