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
function nullptr in shared library data section #781
Comments
It magically started working after I did a rebuild against a newer llvm version so this might be a llvm bug. The .init_array field is still 0 according to objdump but the constructor is called. |
What's the use case for this? I would generally recommend against trying to have a shared library constructor. It's quite intentional that we don't have static constructors. But if it solves a problem, let's talk about that. |
The use case is auto-registration of Node.js add-ons: https://github.com/nodejs/node/blob/v9.5.0/src/node.h#L485-L515 |
It looks like the goal is to call |
I am also trying to export
This code works as expected. |
Trying to load lib.so crashes with a nullptr dereference in glibc's dynamic linker. Changing the type to
[1]usize
and using@ptrToInt(init)
isn't accepted ("unable to evaluate constant expression".)The right address is filled in (and called) with
zig --library c build-exe lib.zig
.(Aside: something like
__attribute__((constructor))
would be nice.)The text was updated successfully, but these errors were encountered: