Skip to content

Fix: Symtab symbol version added by .symver#1811

Merged
davidlattimore merged 2 commits intowild-linker:mainfrom
Blazearth:fix-symtab-symbol-version
Apr 5, 2026
Merged

Fix: Symtab symbol version added by .symver#1811
davidlattimore merged 2 commits intowild-linker:mainfrom
Blazearth:fix-symtab-symbol-version

Conversation

@Blazearth
Copy link
Copy Markdown
Contributor

Fixes #1360
Now symtab version added by symver follows the same behaviour as GNU ld

readelf -Ws wild/tests/build/elf/x86_64/symbol-version-symver/default/symbol-version-symver.c.ld

Symbol table '.dynsym' contains 10 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND puts
     2: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS VER_1.0
     3: 0000000000001064    26 FUNC    GLOBAL DEFAULT   10 unversioned_impl
     4: 000000000000104a    26 FUNC    GLOBAL DEFAULT   10 bar@@VER_1.0
     5: 0000000000001030    26 FUNC    GLOBAL DEFAULT   10 foo@VER_1.0
     6: 0000000000001064    26 FUNC    GLOBAL DEFAULT   10 remain_unversioned
     7: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS VER_2.0
     8: 0000000000001030    26 FUNC    GLOBAL DEFAULT   10 foo_impl
     9: 000000000000104a    26 FUNC    GLOBAL DEFAULT   10 bar_impl

Symbol table '.symtab' contains 14 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS symbol-version-symver.c
     2: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS 
     3: 0000000000003e90     0 OBJECT  LOCAL  DEFAULT   14 _DYNAMIC
     4: 0000000000003fe0     0 OBJECT  LOCAL  DEFAULT   15 _GLOBAL_OFFSET_TABLE_
     5: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS VER_1.0
     6: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND puts
     7: 0000000000001064    26 FUNC    GLOBAL DEFAULT   10 unversioned_impl
     8: 000000000000104a    26 FUNC    GLOBAL DEFAULT   10 bar_impl
     9: 000000000000104a    26 FUNC    GLOBAL DEFAULT   10 bar@@VER_1.0
    10: 0000000000001030    26 FUNC    GLOBAL DEFAULT   10 foo@VER_1.0
    11: 0000000000001064    26 FUNC    GLOBAL DEFAULT   10 remain_unversioned@
    12: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS VER_2.0
    13: 0000000000001030    26 FUNC    GLOBAL DEFAULT   10 foo_impl
readelf -Ws wild/tests/build/elf/x86_64/symbol-version-symver/default/symbol-version-symver.c.wild

Symbol table '.dynsym' contains 8 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND puts
     2: 0000000000001a64    26 FUNC    GLOBAL DEFAULT   12 unversioned_impl
     3: 0000000000001a30    26 FUNC    GLOBAL DEFAULT   12 foo@VER_1.0
     4: 0000000000001a4a    26 FUNC    GLOBAL DEFAULT   12 bar@@VER_1.0
     5: 0000000000001a30    26 FUNC    GLOBAL DEFAULT   12 foo_impl
     6: 0000000000001a64    26 FUNC    GLOBAL DEFAULT   12 remain_unversioned
     7: 0000000000001a4a    26 FUNC    GLOBAL DEFAULT   12 bar_impl

Symbol table '.symtab' contains 15 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT    1 __ehdr_start
     2: 0000000000001a7e     0 NOTYPE  LOCAL  DEFAULT   12 etext
     3: 0000000000001a7e     0 NOTYPE  LOCAL  DEFAULT   12 _etext
     4: 0000000000001a7e     0 NOTYPE  LOCAL  DEFAULT   12 __etext
     5: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT   12 __executable_start
     6: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS symbol-version-symver.c
     7: 0000000000002cf0     0 NOTYPE  GLOBAL DEFAULT   14 _GLOBAL_OFFSET_TABLE_
     8: 0000000000002a80     0 NOTYPE  GLOBAL DEFAULT   13 _DYNAMIC
     9: 0000000000001a30    26 FUNC    GLOBAL DEFAULT   12 foo_impl
    10: 0000000000001a4a    26 FUNC    GLOBAL DEFAULT   12 bar_impl
    11: 0000000000001a64    26 FUNC    GLOBAL DEFAULT   12 unversioned_impl
    12: 0000000000001a30    26 FUNC    GLOBAL DEFAULT   12 foo@VER_1.0
    13: 0000000000001a4a    26 FUNC    GLOBAL DEFAULT   12 bar@@VER_1.0
    14: 0000000000001a64    26 FUNC    GLOBAL DEFAULT   12 remain_unversioned

Copy link
Copy Markdown
Collaborator

@marxin marxin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, generally it looks fine.

Can we include some ExpectDynSym and ExpectSym into the existing symbol-version-symver.c test?

@Blazearth
Copy link
Copy Markdown
Contributor Author

//#ExpectDynSym:foo
used foo not foo@VER_1.0 as .dynsym stores the base name in .dynstr, the object crate (which the test framework uses to read symbols) returns the raw string from .dynstr, which is just foo and version info is stored separately in the .gnu.version section.

@Blazearth Blazearth requested a review from marxin April 5, 2026 18:09
Copy link
Copy Markdown
Collaborator

@marxin marxin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for working on that.

@davidlattimore davidlattimore merged commit 36d52e4 into wild-linker:main Apr 5, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Symtab symbols lose version added by .symver

3 participants