Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix up fmod_preload for newer glibc versions #17

Closed
wants to merge 1 commit into from

Conversation

ashquarky
Copy link

@ashquarky ashquarky commented Dec 23, 2023

The private _dl_sym function is missing from newer glibcs. Instead use dlvsym, a stable function meant for getting a specific versioned symbol. On ARM64, GLIBC_2.17 is dlsym's version (other architectures would need different strings).

Note that this also uses dlsym to get the address of.. dlsym, which should play a bit nicer with anyone else who's hooking that. There's a few libraries I've seen around that do it so they can mess with OpenGL or whatever. (Edit: the original code does this too, don't mind me)

Tested working on Ubuntu Jammy for Switch and Fedora 39 Asahi. NOT tested on 18.04, which is still pretty popular on Switch.

Newer glibcs don't have this. Note the string "GLIBC_2.17" is different
for different architectures - but we only target ARM64 anyway.
@pixelomer
Copy link
Owner

Thank you for your contribution!

The goal is to eventually get rid of fmod_preload and use Mono runtime configurations instead (see #7). I'll keep this open until that is implemented since merging it right now could potentially break Switch compatibility.

@ashquarky
Copy link
Author

I did test this on my Switch, it's just running 22.04 instead of 18.04. I am pretty sure it would be compatible - dlvsym was added in glibc 2.1, we reference glibc 2.17 directly, and as far as I can tell 18.04 ships glibc 2.27; so it should all be new enough - i just don't have a test system.

Mono runtime configs is a nice solution though, I wasn't aware you could map DLLs and symbols around like that.

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.

2 participants