1

I'm reading in book which explains about calling convention in linux, and how system call is implemented.

I read about fastcall which it passes the parameters to the system call to 6 diffrenet registers.

I also read that when I need to pass more than 6 registers I do need to pass a structure which contains those parameters.

Can someone show me how? I really dont found any info out there.

user3061385
  • 157
  • 1
  • 2
  • 9
  • 2
    You probably don't pass many parameters; you define a `struct` and you pass a pointer to that `struct` with a *few* (no more than 4) other parameters. See [sigaction(2)](http://man7.org/linux/man-pages/man2/sigaction.2.html) or [poll(2)](http://man7.org/linux/man-pages/man2/poll.2.html) as an example; the kernel has to limit the number of syscall arguments (since they are passed thru registers, ...) – Basile Starynkevitch Jan 25 '14 at 11:15
  • @Basile Starynkevitch I super agree with you. it's all in theory.. – user3061385 Jan 25 '14 at 11:17
  • First six parameters are in %rdi, %rsi, %rdx, %rcx, %r8 and %r9. Anything more and they'll be passed on the stack. –  Jan 26 '14 at 09:30
  • @SamiLaine I use 32bit registers.. I read about that if I need to pass more than 6 paramers I should pass a pointer to a structure which contains the paramerts – user3061385 Jan 26 '14 at 16:14
  • See: http://stackoverflow.com/questions/2535989/what-are-the-calling-conventions-for-unix-linux-system-calls-on-x86-64 –  Jan 27 '14 at 06:14
  • On Linux, no syscall has more than six arguments “period”. None of the libcs for Linux support it, either. – mirabilos Jan 29 '14 at 15:37

0 Answers0