c - Write System Call Argument Registers -


i have piece of assembly code write system call (is correct?) via

call write@plt 

before doing so, values of rax, address rsp, edi, rsi , rdx set/modified.

how know registers used arguments write or system function calls in general?

my guess write it's rsp, edi , rsi since in c takes 3 arguments:

ssize_t write(int fd, const void *buf, size_t nbytes); 

when call write@plt don't directly invoke write(2) system call, tiny wrapper around (a tiny c function syscall , sets errno on failure).

so write function using standard c calling convention, defined in abi (application binary interface). linux x86-64 read sysv abi interface x86-64

read vdso(7) find out bit more how syscalls done. others might use sysenter machine instruction, etc... details given in abi spec (stricto sensu, real syscall not using stack , passes arguments & results thru registers). read linux assembly howto (more focused on 32 bits x86).

also, c standard libraries linux free software, gnu glibc or perhaps musl-libc, etc... study source code understand exacty how write implemented.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -