[Bug 223752] clang __attribute__((constructor)) gets wrong input parameters
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Mon Nov 20 10:15:51 UTC 2017
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=223752
--- Comment #21 from David Chisnall <theraven at FreeBSD.org> ---
It's also worth noting that functions declared with this attribute can have
some complex interaction with threading. If a process spawns a thread which
calls `dlopen` then all of the library's constructors will be called in that
thread. At this point, it's not clear whether the run-time linker will even
have access to the arguments that you want. It's also not clear what `envp`
should be (the current environment, or the environment from process creation
time?)
I believe glibc provides an `__arguments` variable, along the same lines as
`__environ`, which allows the process to get access to the arguments from
arbitrary points in the code. Implementing something like this would probably
be the best solution for this use case.
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-toolchain
mailing list