Skip to content

Add handling of the .symver asm directives - #994

Merged
marxin merged 12 commits into
wild-linker:mainfrom
marxin:symver-fix-emission
Sep 26, 2025
Merged

marxin merged 12 commits into
wild-linker:mainfrom
marxin:symver-fix-emission

Conversation

@marxin

@marxin marxin commented Jul 7, 2025

Copy link
Copy Markdown
Collaborator

After reworking of changes, the PR includes rudimentary .symver support that leads to successful linking of the alsa-lib shared library. When we encounter a symbol defined by .symver, we correctly mark it in the .gnu.version section.

There might still be missing gaps when it comes to symbol resolution if any other symbol points to a one defined via .symver, but let's see where can we get with this change.

@marxin
marxin marked this pull request as ready for review September 25, 2025 18:27

@davidlattimore davidlattimore left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Awesome! I had assumed that this might have a slight performance impact, but it seems fine.

@marxin
marxin merged commit c4b19d1 into wild-linker:main Sep 26, 2025
19 checks passed
@marxin
marxin deleted the symver-fix-emission branch September 26, 2025 16:55
@mati865

mati865 commented Sep 27, 2025

Copy link
Copy Markdown
Member

I'm back from hiking and upon @marxin request I've run his Gentoo test build.

As the first step I have removed RUN emerge alsa-lib elfutils from https://github.com/marxin/gentoo-docker-testing/blob/main/Dockerfile and it works much better than before but it's still incomplete. Great work though!
Lvm2 build failed with:

make[1]: Entering directory '/var/tmp/portage/sys-fs/lvm2-2.03.22-r7/work/LVM2.2.03.22/libdm'
if x86_64-pc-linux-gnu-readelf -Ws ioctl/libdevmapper.so | grep -q dm_stats_create_region@@; then \
SYM=$(x86_64-pc-linux-gnu-readelf -Ws ioctl/libdevmapper.so | grep dm_stats_create_region@DM_1_02_106); \
if test -n "$SYM"; then touch .symver_check; \
else echo >&2 "Missing versioned symbols in ioctl/libdevmapper.so"; false; fi; \
else touch .symver_check; fi
Missing versioned symbols in ioctl/libdevmapper.so

The symbols inside the shared object:

cd /var/tmp/portage/sys-fs/lvm2-2.03.22-r7/work/LVM2.2.03.22/libdm
readelf -Ws ioctl/libdevmapper.so | grep dm_stats_create_region@
   359: 0000000000027330   322 FUNC    GLOBAL DEFAULT   13 dm_stats_create_region@@DM_1_02_107
   360: 000000000002bac0    28 FUNC    GLOBAL DEFAULT   13 dm_stats_create_region@@DM_1_02_106
   361: 000000000002bae0    29 FUNC    GLOBAL DEFAULT   13 dm_stats_create_region@@DM_1_02_104

Notice @ vs @@ difference.

According to https://maskray.me/blog/2020-11-26-all-about-symbol-versioning we should create symbol with only one @ if the symbol is defined.

@marxin

marxin commented Sep 29, 2025

Copy link
Copy Markdown
Collaborator Author

Thanks @mati865 for the testing effort and I think I have a fix: #1129. Feel free to continue with the gentoo-docker if you have spare cycles.

@mati865

mati865 commented Sep 29, 2025

Copy link
Copy Markdown
Member

@marxin it doesn't fix lvm2 build.
The part that I was referring to, is "If foo is defined, produce foo and foo@v1 with the same binding and st_other value.".

@marxin

marxin commented Oct 1, 2025

Copy link
Copy Markdown
Collaborator Author

@mati865 I've just re-run locally the build of lvm2 and the build process finishes correctly (with #1129) with the following symbol listing:

readelf -Ws libdm/ioctl/libdevmapper.so | grep dm_stats_create_region@
   354: 0000000000049400    28 FUNC    GLOBAL DEFAULT   14 dm_stats_create_region@DM_1_02_106
   355: 0000000000049420    29 FUNC    GLOBAL DEFAULT   14 dm_stats_create_region@DM_1_02_104
   356: 0000000000044d30   317 FUNC    GLOBAL DEFAULT   14 dm_stats_create_region@@DM_1_02_107

While running on the main branch, I hit the aforementioned issue:

    [CHECK] ioctl/libdevmapper.so
Missing versioned symbols in ioctl/libdevmapper.so

@mati865

mati865 commented Oct 1, 2025

Copy link
Copy Markdown
Member

Hmm, I'm sure I've copied the binary after building it. Perhaps I've built the debug one by mistake, I'll try later.

@mati865

mati865 commented Oct 1, 2025

Copy link
Copy Markdown
Member

🤦🏻‍♂️ I had run cp target/release/wild /usr/bin in Gentoo container ...

Sorry for the confusion.

@marxin

marxin commented Oct 2, 2025

Copy link
Copy Markdown
Collaborator Author

No worries, that happens. Anyways, thanks for the testing effort.

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.

3 participants