OPTION LITERALS:ON
extern __libc_start_main:proc
exit proto systemv status:dword
printf PROTO SYSTEMV pformat:PTR, arg:VARARG
IF 0
=================================================================
/home/doc/PROJECTS/eglibc-2.19/sysdeps/x86_64/start.S
=================================================================
%rsp The stack contains the arguments and environment:
0(%rsp) argc
LP_SIZE(%rsp) argv[0]
...
(LP_SIZE*argc)(%rsp) NULL
(LP_SIZE*(argc+1))(%rsp) envp[0]
...
NULL
================================================================
ENDIF
GetMainArgs macro arg
add r15,8
xor r14,r14
.while qword ptr [r15][rsp] != 0
invoke printf,CStr("%s[%d] = %s ",10), arg, r14, [r15][rsp]
add r15,8
inc r14
.endw
endm
.code
main:
invoke printf,CStr("argc = %d ",10), [rsp]
xor r15, r15
GetMainArgs "argv"
GetMainArgs "envp"
invoke exit,0
end main ; __libc_start_main ; _start
LINK command line: ld -s ./1.o -o 1 -I/lib64/ld-linux-x86-64.so.2 -lc