eyra icon indicating copy to clipboard operation
eyra copied to clipboard

Missing symbols: `dlopen`, `dlclose`, `posix_fallocate`

Open rice7th opened this issue 1 year ago • 5 comments

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.

rice7th avatar Feb 29 '24 18:02 rice7th

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.

sunfishcode avatar Feb 29 '24 19:02 sunfishcode

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.

bjorn3 avatar Feb 29 '24 19:02 bjorn3

@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.

rice7th avatar Mar 01 '24 08:03 rice7th