
According to the image,the stack is populated with the auxiliary vector entry on start up.
I don't know of it before.
How can I access/print them?
int main(int argc, char *argv[], char *envp[]);
Does it mean main has a hidden fourth parameter?
The aux vector is located immediately past the end of the environment vector, which is accessible (per POSIX) as extern char **environ;. environ points to a NULL-pointer terminated array of char * pointers to environment variables. Iterate through the environment until you reach NULL, then advance one element further and cast the result to whatever type you want to use to access the aux vector. Personally, I treat it as an array of size_t or uintptr_t values that come in pairs, since this is easier and more portable than the elf.h Elf32_auxv_t and Elf64_auxv_t types (which require that you special-case whether you're building for a 32-bit or 64-bit target).
Note that the existence and location of the aux vector are not specified by POSIX, but this is where they will be located on any ELF-ABI-based implementation that use an aux vector.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With