Skip to content

[NativeAOT] How do I receive a callback on library load in Linux? #104529

Answered by jkotas
slxdy asked this question in Q&A
Discussion options

You must be logged in to vote

The portable version are C++ global static constructor (or their low-level platform-specific mechanism - DllMain on Windows, https://stackoverflow.com/questions/39540364/does-static-initialization-and-or-other-code-get-run-when-dlopening on Linux and other ELF-based platforms, ...). You can create C++ file with global static constructor that calls back into your method, compile it to .obj/o, and link this .obj/o to your app. It comes with the same disclaimer as DllMain. It is not a reliable solution.

Replies: 2 comments 20 replies

Comment options

You must be logged in to vote
10 replies
@slxdy
Comment options

@colejohnson66
Comment options

@jkotas
Comment options

@slxdy
Comment options

@jkotas
Comment options

Comment options

You must be logged in to vote
10 replies
@slxdy
Comment options

@jkotas
Comment options

Answer selected by slxdy
@slxdy
Comment options

@jkotas
Comment options

@CeSun
Comment options

@aadog
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants