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:
Norman Feske 2012-05-18 19:30:19 +02:00
parent 6f12659369
commit 97cd7ca022
2 changed files with 7 additions and 2 deletions

View File

@ -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);

View File

@ -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;
}