Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Mon, 27 Jun 2016 13:07:59 -0700
From: Daniel Wilkerson <>
Cc: Mark Winterrowd <>
Subject: request for help with aux

The musl crt0 code seems to expect that when the process starts that
the stack pointer points to a data page having the following four data
structures immediately contiguous: argc, argv, env, aux.

I'm writing a loader for musl-riscv and I need to know how to
initialize this data.  The only one I wonder about is the aux array.
It seems that aux is a collection of name/value pairs which are used
as follows in musl-riscv/src/env/__libc_start_main.c:

    void __init_libc(char **envp, char *pn)
            size_t i, *auxv, aux[AUX_CNT] = { 0 };
            __environ = envp;
            for (i=0; envp[i]; i++);
            libc.auxv = auxv = (void *)(envp+i+1);
            for (i=0; auxv[i]; i+=2) if (auxv[i]<AUX_CNT) aux[auxv[i]] = auxv[i\
            __hwcap = aux[AT_HWCAP];
            __sysinfo = aux[AT_SYSINFO];
            libc.page_size = aux[AT_PAGESZ];

            if (pn) {
                    __progname = __progname_full = pn;
                    for (i=0; pn[i]; i++) if (pn[i]=='/') __progname = pn+i+1;

            __init_ssp((void *)aux[AT_RANDOM]);

            if (aux[AT_UID]==aux[AT_EUID] && aux[AT_GID]==aux[AT_EGID]
                    && !aux[AT_SECURE]) return;

            struct pollfd pfd[3] = { {.fd=0}, {.fd=1}, {.fd=2} };
    #ifdef SYS_poll
            __syscall(SYS_poll, pfd, 3, 0);
            __syscall(SYS_ppoll, pfd, 3, &(struct timespec){0}, 0, _NSIG/8);
            for (i=0; i<3; i++) if (pfd[i].revents&POLLNVAL)
                    if (__sys_open("/dev/null", O_RDWR)<0)
   = 1;

This seems to initalize aux to be all zeros, so it seems that in
theory all of the aux values could be optional:

        size_t i, *auxv, aux[AUX_CNT] = { 0 };

What I'm wondering is where to find the semantics of all of the aux
names; I could hunt through all of the code, but any high-level
suggestions you could provide could help a lot.  As a bonus, which
ones might not have sensible defaults and are actually non-optional,
if any.


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.