Auxiliary Vector

The Auxiliary Vector (or AUXV as it is more commonly referred to in source code) is part of the ELF standard, and is passed by the operating system to the program about to be run. The structure it is kept in looks like

typedef struct
{
  int a_type;                   /* Entry type */
  union
    {
      long int a_val;           /* Integer value */
      void *a_ptr;              /* Pointer value */
      void (*a_fcn) (void);     /* Function pointer value */
    } a_un;
} Elf32_auxv_t;

Viewing AUXV

On occasion, you might want to have a look at what the auxv your programming is running with

Dynamic Loader

If you program is dynamically linked, and hence is loaded by the dynamic loader, you can use the LD_SHOW_AUXV environment variable.

For example

$ LD_SHOW_AUXV=1 /bin/true
AT_??? (0x20): 0xa000000000010660
AT_??? (0x21): 0xa000000000000000
AT_HWCAP:        0
AT_PAGESZ:       16384
AT_CLKTCK:       1024
AT_PHDR:         0x4000000000000040
AT_PHENT:        56
AT_PHNUM:        7
AT_BASE:         0x2000000000000000
AT_FLAGS:        0x0
AT_ENTRY:        0x4000000000001160
AT_UID:          1002
AT_EUID:         1002
AT_GID:          1002
AT_EGID:         1002
AT_SECURE:       0

proc

On 2.6 kernels, you can also check out the auxv via /proc , e.g.

ianw@baci:~$ hexdump -x /proc/self/auxv
0000000    0020    0000    0000    0000    0660    0001    0000    a000
0000010    0021    0000    0000    0000    0000    0000    0000    a000
0000020    0010    0000    0000    0000    0000    0000    0000    0000
0000030    0006    0000    0000    0000    4000    0000    0000    0000
0000040    0011    0000    0000    0000    0400    0000    0000    0000
0000050    0003    0000    0000    0000    0040    0000    0000    4000
0000060    0004    0000    0000    0000    0038    0000    0000    0000
0000070    0005    0000    0000    0000    0007    0000    0000    0000
0000080    0007    0000    0000    0000    0000    0000    0000    2000
0000090    0008    0000    0000    0000    0000    0000    0000    0000
00000a0    0009    0000    0000    0000    16e0    0000    0000    4000
00000b0    000b    0000    0000    0000    03ea    0000    0000    0000
00000c0    000c    0000    0000    0000    03ea    0000    0000    0000
00000d0    000d    0000    0000    0000    03ea    0000    0000    0000
00000e0    000e    0000    0000    0000    03ea    0000    0000    0000
00000f0    0017    0000    0000    0000    0000    0000    0000    0000
0000100    0000    0000    0000    0000    0000    0000    0000    0000
0000110

This isn't as useful as it doesn't try to give symoblic names for each entry.

via main()

On some architectures (only PowerPC currently, I think) the auxv is the fourth argument passed to main(), e.g.

ianw@mingus:~$ cat test.c
#include <link.h>
#include <elf.h>

int main(int argc, char *argv[], char *env[], ElfW(auxv_t) auxv[])
{
        int i = 0;
        while ( 1 )
        {
                if (auxv[i].a_type == 0)
                        break;
                printf("auxv[%2d] : a_type=%2x | a_val=%lx\n", i, auxv[i].a_type, auxv[i].a_un.a_val);
                i++;
        }

}
ianw@mingus:~$ ./test
auxv[ 0] : a_type=16 | a_val=16
auxv[ 1] : a_type=16 | a_val=16
auxv[ 2] : a_type=13 | a_val=20
auxv[ 3] : a_type=14 | a_val=20
auxv[ 4] : a_type=15 | a_val=0
auxv[ 5] : a_type=10 | a_val=8c000000
auxv[ 6] : a_type= 6 | a_val=1000
auxv[ 7] : a_type=11 | a_val=64
auxv[ 8] : a_type= 3 | a_val=10000034
auxv[ 9] : a_type= 4 | a_val=20
auxv[10] : a_type= 5 | a_val=7
auxv[11] : a_type= 7 | a_val=30000000
auxv[12] : a_type= 8 | a_val=0
auxv[13] : a_type= 9 | a_val=100002c8
auxv[14] : a_type= b | a_val=3e8
auxv[15] : a_type= c | a_val=3e8
auxv[16] : a_type= d | a_val=3e8
auxv[17] : a_type= e | a_val=3e8
auxv[18] : a_type=17 | a_val=0
ianw@mingus:~$

IA64wiki: AuxiliaryVector (last edited 2009-12-10 03:13:55 by localhost)

Gelato@UNSW is sponsored by
the University of New South Wales National ICT Australia The Gelato Federation Hewlett-Packard Company Australian Research Council
Please contact us with any questions or comments.