Bug 23840 - .symver fails with multiple versions [...] for symbol `...'
Summary: .symver fails with multiple versions [...] for symbol `...'
Status: RESOLVED DUPLICATE of bug 25295
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: unspecified
: P2 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-29 12:37 UTC by Szabolcs Nagy
Modified: 2020-04-21 12:37 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Szabolcs Nagy 2018-10-29 12:37:09 UTC
.global foo
foo:
  ret
.symver foo, bar@V1
.symver foo, baz@V2

fails with

c.s: Assembler messages:
c.s:5: Error: multiple versions [`baz@V2'|`bar@V1'] for symbol `foo'

i see no reason to disallow multiple symbol versions
to point to the same location.

currently this can be worked around by using another
symbol, but such hack should not be needed (only the
location, binding and visibility should matter, the
symbol name should not, so ideally symver should even
work with an address expression that's not a symbol)

.global foo
.global foo_hack
foo:
foo_hack:
  ret
.symver foo, bar@V1
.symver foo_hack, baz@V2
Comment 1 Alan Modra 2018-10-29 21:58:53 UTC
I've run into this before too.  The gas error is just due to an implementation detail, and could be fixed if someone cared enough to rewrite the .symver support.
Comment 2 Fangrui Song 2020-03-31 06:29:47 UTC
If we treat .symver foo, bar@V1 as "rename foo to bar@V1", this behavior will be explainable.
Actually, I think renaming is the most reasonable behavior.

This was what I wanted to do in clang integrated assembler
https://github.com/llvm/llvm-project/commit/38426c114f6e50f8638bdd656f2f423151bc8eca

Unfortunately a ChromeOS dev reverted it because libfuse3 and alsa-lib have unreasonable use cases. I'll restore the patch when I get around to fix the two packages or find people to fix them.
Comment 3 H.J. Lu 2020-04-06 22:09:25 UTC
Will be fixed with PR 25295.

*** This bug has been marked as a duplicate of bug 25295 ***
Comment 4 Sourceware Commits 2020-04-21 12:37:48 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6914be53bd662eefd979d0c82d2e20e108c4ee66

commit 6914be53bd662eefd979d0c82d2e20e108c4ee66
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Apr 21 05:33:04 2020 -0700

    gas: Extend .symver directive
    
    Extend .symver directive to update visibility of the original symbol and
    assign one original symbol to different versioned symbols:
    
      .symver foo, foo@VERS_1, local    # Change foo to a local symbol.
      .symver foo, foo@VERS_2, hidden   # Change foo to a hidden symbol.
      .symver foo, foo@@VERS_3, remove  # Remove foo from symbol table.
      .symver foo, bar@V1               # Assign foo to bar@V1 and baz@V2.
      .symver foo, baz@V2
    
            PR gas/23840
            PR gas/25295
            * NEWS: Mention .symver extension.
            * config/obj-elf.c (obj_elf_find_and_add_versioned_name): New
            function.
            (obj_elf_symver): Call obj_elf_find_and_add_versioned_name to
            add a version name.  Add local, hidden and remove visibility
            support.
            (elf_frob_symbol): Handle the list of version names.  Update the
            original symbol to local, hidden or remove it from the symbol
            table.
            (elf_frob_file_before_adjust): Handle the list of version names.
            * config/obj-elf.h (elf_visibility): New.
            (elf_versioned_name_list): Likewise.
            (elf_obj_sy): Change local to bitfield. Add rename, bad_version
            and visibility.  Change versioned_name pointer to struct
            elf_versioned_name_list.
            * doc/as.texi: Update .symver directive.
            * testsuite/gas/symver/symver.exp: Run all *.d tests.  Add more
            error checking tests.
            * testsuite/gas/symver/symver6.d: New file.
            * testsuite/gas/symver/symver7.d: Likewise.
            * testsuite/gas/symver/symver7.s: Likewise.
            * testsuite/gas/symver/symver8.d: Likewise.
            * testsuite/gas/symver/symver8.s: Likewise.
            * testsuite/gas/symver/symver9.s: Likewise.
            * testsuite/gas/symver/symver9a.d: Likewise.
            * testsuite/gas/symver/symver9b.d: Likewise.
            * testsuite/gas/symver/symver10.s: Likewise.
            * testsuite/gas/symver/symver10a.d: Likewise.
            * testsuite/gas/symver/symver10b.d: Likewise.
            * testsuite/gas/symver/symver11.d: Likewise.
            * testsuite/gas/symver/symver11.s: Likewise.
            * testsuite/gas/symver/symver12.d: Likewise.
            * testsuite/gas/symver/symver12.s: Likewise.
            * testsuite/gas/symver/symver13.d: Likewise.
            * testsuite/gas/symver/symver13.s: Likewise.
            * testsuite/gas/symver/symver14.d: Likewise.
            * testsuite/gas/symver/symver14.l: Likewise.
            * testsuite/gas/symver/symver15.d: Likewise.
            * testsuite/gas/symver/symver15.l: Likewise.
            * testsuite/gas/symver/symver6.l: Removed.
            * testsuite/gas/symver/symver6.s: Updated.