#include <stdio.h>
#include <elf.h>
int main(int argc, char* argv[])
{
void** p = (void**)argv;
printf("%p\n", p);
printf("Argument count: %d\n", *((int*)p - 1));
int i;
for (i = 0; i < argc; ++i)
{
printf("Argument %d: %s\n", i, (char*)*p);
p++;
}
// skip 0
p++;
printf("Environment:\n");
while (*p) {
printf("%s\n", (char*)*p);
p++;
}
// skip 0
p++;
printf("Auxiliary Vectors:\n");
Elf64_auxv_t* aux = (Elf64_auxv_t*)p;
while (aux->a_type != AT_NULL) {
printf("Type: %02ld Value: %#lx\n", aux->a_type, aux->a_un.a_val);
aux++;
}
return 0;
}
0x7ffded5deaf8
Argument count: 0
Argument 0: ./allen
Environment:
XDG_VTNR=7
LC_PAPER=zh_CN.UTF-8
LC_ADDRESS=zh_CN.UTF-8
XDG_SESSION_ID=c1
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/root
SELINUX_INIT=YES
LC_MONETARY=zh_CN.UTF-8
CLUTTER_IM_MODULE=xim
GPG_AGENT_INFO=/run/user/0/keyring-dxWI1Y/gpg:0:1
TERM=xterm
VTE_VERSION=3409
SHELL=/bin/bash
WINDOWID=31457292
LC_NUMERIC=zh_CN.UTF-8
UPSTART_SESSION=unix:abstract=/com/ubuntu/upstart-session/0/1359
GNOME_KEYRING_CONTROL=/run/user/0/keyring-dxWI1Y
GTK_MODULES=overlay-scrollbar:unity-gtk-module
USER=root
JRE_HOME=/usr/jdk1.6.0_45/jre
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:
LC_TELEPHONE=zh_CN.UTF-8
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
SSH_AUTH_SOCK=/run/user/0/keyring-dxWI1Y/ssh
DEFAULTS_PATH=/usr/share/gconf/ubuntu.default.path
XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg
DESKTOP_SESSION=ubuntu
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
MAIL=/var/mail/root
QT_IM_MODULE=ibus
QT_QPA_PLATFORMTHEME=appmenu-qt5
LC_IDENTIFICATION=zh_CN.UTF-8
PWD=/root/Desktop/link-load-library-code-master/chapter7
JOB=gnome-session
XMODIFIERS=@im=ibus
JAVA_HOME=/usr/jdk1.6.0_45
GNOME_KEYRING_PID=1474
LANG=en_US.UTF-8
MANDATORY_PATH=/usr/share/gconf/ubuntu.mandatory.path
LC_MEASUREMENT=zh_CN.UTF-8
COMPIZ_CONFIG_PROFILE=ubuntu
IM_CONFIG_PHASE=1
GDMSESSION=ubuntu
SESSIONTYPE=gnome-session
SHLVL=3
HOME=/root
XDG_SEAT=seat0
LANGUAGE=en
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
UPSTART_INSTANCE=
UPSTART_EVENTS=started starting
LOGNAME=root
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-IC0s7XoiCf
XDG_DATA_DIRS=/usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/
CLASSPATH=.::/usr/jdk1.6.0_45/lib:/usr/jdk1.6.0_45/jre/lib
QT4_IM_MODULE=xim
LESSOPEN=| /usr/bin/lesspipe %s
TEXTDOMAIN=im-config
INSTANCE=Unity
UPSTART_JOB=unity-settings-daemon
XDG_RUNTIME_DIR=/run/user/0
DISPLAY=:0
XDG_CURRENT_DESKTOP=Unity
GTK_IM_MODULE=ibus
LESSCLOSE=/usr/bin/lesspipe %s %s
LC_TIME=zh_CN.UTF-8
TEXTDOMAINDIR=/usr/share/locale/
LC_NAME=zh_CN.UTF-8
XAUTHORITY=/root/.Xauthority
COLORTERM=gnome-terminal
_=./allen
OLDPWD=/root/Desktop/link-load-library-code-master
Auxiliary Vectors:
Type: 33 Value: 0x7ffded5fe000
Type: 16 Value: 0xfabfbff
Type: 06 Value: 0x1000
Type: 17 Value: 0x64
Type: 03 Value: 0x400040
Type: 04 Value: 0x38
Type: 05 Value: 0x9
Type: 07 Value: 0x7f6e08f1e000
Type: 08 Value: 0
Type: 09 Value: 0x400490
Type: 11 Value: 0
Type: 12 Value: 0
Type: 13 Value: 0
Type: 14 Value: 0
Type: 23 Value: 0
Type: 25 Value: 0x7ffded5dee89
Type: 31 Value: 0x7ffded5dfff0
Type: 15 Value: 0x7ffded5dee99
转载于:https://blog.51cto.com/haidragon/2169050