- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 606
 
Description
As explained nicely in golang/go#13492, since 1996 glibc's dlopen() passes argv and a bunch of other stuff to the initialization functions of shared objects, while we don't pass any argument (see object::run_init_funcs()). Golang code (ref #522), in particular, assumes it gets argv, auxv, etc., this way.
Passing argv et al. to init functions doesn't make any sense, not to mention it isn't clear which argv we're supposed to pass (or what happens if the executable modified these things before or during the dlopen call). So according to research in the above link, NONE of the other glibc clones passes these things to DSO initialization functions. But sadly, glibc does - since the following unexplained commit in 1996:
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=dcf0671d905200c449f92ead6cf43c184637a0d5
So probably we need to do this too :-(
The above doesn't mention auxv, so probably look at newer code to see what glibc really passes these days.
By the way, looking at that commit, I discovered that glibc exposes also
extern int __libc_argc;
extern char *___libc_argv;
extern char *___libc_envp;
So probably we should have those too (even if golang doesn't use them, somebody is bound to use them someday).