[1/3] Use version index 1 for defined symbols
Alan Modra
amodra@gmail.com
Fri Nov 21 11:29:13 GMT 2025
On Thu, Nov 20, 2025 at 04:30:17PM +0100, Michael Matz wrote:
> It's reasonable to use version index 0 for undefined
> symbols, so let's continue doing that. For defined (global)
> symbols that aren't otherwise versioned continue using
> VER_NDX_GLOBAL (partly reverting behaviour introduced in
> commit f685e395).
When I approved HJ's patch earlier, I wondered about two things, one
was whether I should ask him to write the patch without "noversion".
ie. write "iversym.vs_vers = 0" instead of "noversion = true". You
can get exactly the same output without using the extra variable.
The other thing was whether v3 was required. (What you're doing here
is effectively going back to v2.) I decided to trust HJ knew what he
was doing (he usually does), and that if there was fallout he'd fix
it. So while I'm happy to OK this patch and your second in the
series, rather than reverting the entire patch, I'd like to hear what
HJ has to say.
> bfd/
> PR ld/33577
> * elflink.c (elf_link_output_extsym): Don't set noversion
> for defined syms.
>
> ld/
> PR ld/33577
> * ld-elfvers/vers16.dsym: Add back the "Base" version for
> defined syms.
> ---
> I got approval for this on in bugzilla, but as there are relations to a
> readelf change I'll make this part of the whole series.
>
> ---
> bfd/elflink.c | 8 +-------
> ld/testsuite/ld-elfvers/vers16.dsym | 2 +-
> 2 files changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/bfd/elflink.c b/bfd/elflink.c
> index ec3ad9735fe..7d284c08c00 100644
> --- a/bfd/elflink.c
> +++ b/bfd/elflink.c
> @@ -11158,13 +11158,7 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
> else
> {
> if (h->verinfo.vertree == NULL)
> - {
> - iversym.vs_vers = 1;
> - if (elf_tdata (flinfo->output_bfd)->cverdefs == 0)
> - /* Defined symbol has no version if there is no
> - linker version script. */
> - noversion = true;
> - }
> + iversym.vs_vers = 1;
> else
> iversym.vs_vers = h->verinfo.vertree->vernum + 1;
> if (flinfo->info->create_default_symver)
> diff --git a/ld/testsuite/ld-elfvers/vers16.dsym b/ld/testsuite/ld-elfvers/vers16.dsym
> index 076d0eb07ed..a32abd7aad9 100644
> --- a/ld/testsuite/ld-elfvers/vers16.dsym
> +++ b/ld/testsuite/ld-elfvers/vers16.dsym
> @@ -1,2 +1,2 @@
> -[0-9a-f]+ g +DF (\.text|\.opd|\*ABS\*) [0-9a-f]+ +(0x[0-9a-f]+ )?_?show_bar
> +[0-9a-f]+ g +DF (\.text|\.opd|\*ABS\*) [0-9a-f]+( +Base +)? +(0x[0-9a-f]+ )?_?show_bar
> [0-9a-f]+ +DF \*UND\* [0-9a-f]+ +(0x[0-9a-f]+ )?_?show_foo
> --
> 2.48.1
--
Alan Modra
More information about the Binutils
mailing list