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

Missing symbols: dlopen, dlclose, posix_fallocate #44

Open
rice7th opened this issue Feb 29, 2024 · 3 comments
Open

Missing symbols: dlopen, dlclose, posix_fallocate #44

rice7th opened this issue Feb 29, 2024 · 3 comments

Comments

@rice7th
Copy link

rice7th commented Feb 29, 2024

Hi sunfish!
After all the fixes I proposed to get eyra and mustang to work, my tiny miniquad project is still incapable of compiling because dlopen, dlclose and posix_fallocate are all missing. Unfortunately after careful reading I've noticed that dynamic linking is still completely unsupported, so the chance of getting any project involving miniquad or similar crates that bind to system libraries is very minimal. That said, posix_fallocate doesn't seem related to dynamic linking at all, so at least that could be a starting point.

If I get time, I might look onto the dynamic linking implementation and see what can I do, but until then my most useful contribution will be this issue.

Notes

posix_fallocate is defined in fcntl.h

dlopen, dlclose and all the other dlfcn.h functions are already defined in rust inside relibc.

Unfrotunately, I haven't studied the project enough, and something tells me that dynamic linking is quite a bit more challenging to implement than just those functions (I would really love to know what's missing to actually make dynamic linking work), but at least we have a publicly available pure rust implementation as a starting point.

@sunfishcode
Copy link
Owner

Yes; posix_fallocate ought to be a fairly straightfoward wrapper around rustix::fs::fallocate.

C-style dynamic linking is indeed missing. It's not something I need for my own current projects, so I haven't mapped out what an implementation would look like. @bjorn3 recently added startup support, but full C-style dynamic linking support would also involve ELF file parsing and loading, relocations processing, dynamic thread-local storage, and possibly more.

@bjorn3
Copy link
Contributor

bjorn3 commented Feb 29, 2024

I've been chipping away at getting musl's dynamic linker work with eyra. I've got a working prototype of it already. (see the dynlink branches on my forks of eyra, origin and c-ward. be aware that I force push to them frequently.) There are still several issues with it though. Most of the changes I have done/need to do are things that are almost certainly necessary for a pure rust dynamic linker too.

@rice7th
Copy link
Author

rice7th commented Mar 1, 2024

@bjorn3 wow that's actually pretty nice! You're doing a lot of useful work; hopefully I might get involved too.

@sunfishcode As for elf parsing and storing, there are actually a lot of libraries dedicated to just that. goblin and object easily come to mind. Regarding goblin, m4b (the author) also made a semi functioning dynamic linker in pure rust.

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

No branches or pull requests

3 participants