Skip to content

Commit

Permalink
use less fatal pointer calculations for ps_strings
Browse files Browse the repository at this point in the history
  • Loading branch information
anttikantee committed Jun 23, 2015
1 parent 23b7f40 commit d42cb48
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions lib/librumprun_base/netbsd_initfini.c
Expand Up @@ -47,13 +47,11 @@ static char *initial_env[] = {
};

extern void *environ;
void _libc_init(void);
extern char *__progname;

/* XXX */
static struct ps_strings thestrings;
extern struct ps_strings *__ps_strings;

void _libc_init(void);

typedef void (*initfini_fn)(void);
extern const initfini_fn __init_array_start[1];
extern const initfini_fn __init_array_end[1];
Expand Down Expand Up @@ -81,19 +79,27 @@ runfini(void)
(*fn)();
}

struct initinfo {
char *argv_dummy;
char *env_dummy;
AuxInfo ai[2];
} __attribute__((__packed__));

void
_netbsd_userlevel_init(void)
{
static AuxInfo auxinfo[2];
static struct initinfo ii;
static struct ps_strings ps;
AuxInfo *ai = ii.ai;
int rv;

auxinfo[0].a_type = AT_STACKBASE;
auxinfo[0].a_v = (unsigned long)bmk_mainstackbase;
auxinfo[1].a_type = AT_NULL;
auxinfo[1].a_v = 0;
ai[0].a_type = AT_STACKBASE;
ai[0].a_v = (unsigned long)bmk_mainstackbase;
ai[1].a_type = AT_NULL;
ai[1].a_v = 0;

thestrings.ps_argvstr = (void *)((char *)&auxinfo - 2);
__ps_strings = &thestrings;
ps.ps_argvstr = &ii.argv_dummy;
__ps_strings = &ps;

/*
* We get no "environ" from the kernel. The initial
Expand Down

0 comments on commit d42cb48

Please sign in to comment.