mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-09 04:15:52 +00:00
Hook for passing env pointer to main function
The new 'genode_envp' variable declared in '_main.cc' allows libc plugins to supplying custom environment pointers to the main function. This is needed by 3rd-party software such as GNU make, which expects the environment pointer as third argument of the main function.
This commit is contained in:
parent
6f12659369
commit
97cd7ca022
@ -31,7 +31,7 @@
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
extern int main(int argc, char **argv);
|
||||
extern int main(int argc, char **argv, char **envp);
|
||||
extern void init_exception_handling(); /* implemented in base/cxx */
|
||||
|
||||
enum { ATEXIT_SIZE = 256 };
|
||||
@ -212,6 +212,7 @@ static char *argv[1] = { argv0 };
|
||||
*/
|
||||
char **genode_argv = argv;
|
||||
int genode_argc = 1;
|
||||
char **genode_envp = 0;
|
||||
|
||||
|
||||
/**
|
||||
@ -250,7 +251,7 @@ extern "C" int _main()
|
||||
/* now, it is save to call printf */
|
||||
|
||||
/* call real main function */
|
||||
int ret = main(genode_argc, genode_argv);
|
||||
int ret = main(genode_argc, genode_argv, genode_envp);
|
||||
|
||||
genode_exit(ret);
|
||||
|
||||
|
@ -1025,6 +1025,7 @@ namespace {
|
||||
/* external symbols provided by Genode's startup code */
|
||||
extern char **genode_argv;
|
||||
extern int genode_argc;
|
||||
extern char **genode_envp;
|
||||
|
||||
/* pointer to environment, provided by libc */
|
||||
extern char **environ;
|
||||
@ -1108,6 +1109,9 @@ void init_libc_noux(void)
|
||||
/* register list of environment variables at libc 'environ' pointer */
|
||||
environ = env_array;
|
||||
|
||||
/* define env pointer to be passed to main function (in '_main.cc') */
|
||||
genode_envp = environ;
|
||||
|
||||
/* initialize noux libc plugin */
|
||||
static Plugin noux_plugin;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user