-
-
Notifications
You must be signed in to change notification settings - Fork 756
Odin shared libraries call the main program's _startup_runtime
on Linux
#5169
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
Comments
If foreign importing the
|
Almost the same if loaded this way: package main
import "base:runtime"
import "core:dynlib"
Procs :: struct {
get_alpha: proc() -> int,
get_beta: proc() -> int,
}
@(init)
program_init :: proc() {
runtime.println_any("Init from the main program.")
}
@(init)
program_init_2 :: proc() {
runtime.println_any("Another init from the main program.")
}
main :: proc() {
procs: Procs
count, _ := dynlib.initialize_symbols(&procs, "alpha.dll" when ODIN_OS == .Windows else "alpha.so"); assert(count > 0)
count, _ = dynlib.initialize_symbols(&procs, "beta.dll" when ODIN_OS == .Windows else "beta.so"); assert(count > 0)
runtime.println_any(procs.get_alpha())
runtime.println_any(procs.get_beta())
} Except the prints have a different order:
|
So I can't replicate it on Linux when loaded through
But I do get the same output as you do when we
|
Thank you for the investigation and reproduction. I hadn't even known about |
It should also be able to import |
I've only just started reading about the PLT, GOT, and linkers to try to figure this one out, as well as reading through the SysV ABI documentation. We call I tried setting it to be forced inline and changing its linkage with As I was looking through the disassembly of I'm still new to all this, as I've really never had to deal with the innards of linking before, and I scarcely understand LLVM. But I do know how to work a hex editor, so I popped open Some further digging led me to a possible fix, which I will send up shortly. |
Given the following main program:
main.odin
And the two following libraries:
alpha/lib.odin
beta/lib.odin
Compiled with:
Running the main program produces this output:
I'm curious if this also happens on Windows, or if this is another SysV problem.
The text was updated successfully, but these errors were encountered: