Message board for the users of flat assembler.
> Linux > argc, argv, argp in AMD64
Just a really quick question. If I link my code to glibc and execute the application, argc, argv, and argp are placed in rdi, rsi and rdx respectively at the start of main, as per the AMD64 SYS V ABI spec.
However if I assemble my application directly to ELF executable, rdi, rsi and rdx are all blank. So where are agrc, argv and argp pointers, when I assemble to my app as a ELF executable, that is what are the register/stack contents when the Linux kernel passes control to my app?
PS. Already googled, but all I get are for 32bit apps, and not x86_64 apps.
PPS. Kernel v22.214.171.124 (stock from kernel.org). Looking through the kernel source hasn't been fruitful either.
|07 Jun 2006, 03:33||
yes, that's right
if you try to load ELF64 under debugger, you can find how and why
in ELF64 created directly by FASM you get args in the stack
qword [rsp+8]=pointer to arg0
qword [rsp+8 + argc*8]=0 end of args
qword [rsp+8 + argc*8 + 8]=pointer to first string of environment
qword [...]=0 end of envirnment
in ELF64 created by linker there are routines for loading libs before main, so
routines read args from stack and prepare them into regs
don't try to step this init routines, you'll waste a lot ot the time until you go to your main asm code
try fdbg from Projects and Ideas section of the forum
I'm working on it, next release with fully functionality will come in few days (I hope until this weekend, I'm finishig the last thing - hardware breakpoints, which is the most belowed debugger feature for me...)
updates on my home page are more frequent than here in the forum, a newer version of fdbg for Linux 64-bit AMD64 is there from 2006 june 05 (hasn't hw bp)
I wasted a lot of time with gdb with ugly asm syntax for uncover problems like your and then I decided to write more FASM-friendly debugger
quick debug trick to bypass init lib routines in case of linking with libc:
put db 0cch at the begin of your asm code
load under debugger
program stops in your main asm code
|07 Jun 2006, 07:32||
Thanks for the info, exactly what I was after.
|09 Jun 2006, 01:19||
< Last Thread | Next Thread >
Copyright © 1999-2020, Tomasz Grysztar.
Powered by rwasa.