0

I have read that Linux works with stack to pass arguments to functions on 32 bits x86 computers.

But i have looked deeper and it seems that kernel uses eax for first parameter (see commit_creds)

So i do not understand.

Thanks

Bob5421
  • 7,757
  • 14
  • 81
  • 175
  • It's dictated by ABI to the platform in question. https://en.wikipedia.org/wiki/X86_calling_conventions Note, for single module the additional compile and link time optimizations can be done. Over all LTO technique may be applied as well on top of entire build set. – 0andriy Apr 15 '19 at 20:15

1 Answers1

0

I think this: Function parameter passing in a Linux kernel interrupt handler (from asm to C) has explanation to your concern. Putting it shortly, EAX will be used for optimization.

  • Hello, welcome to Stack Overflow. Please avoid posting lone links in answers as links can change. You can post links as long as you also post answer material directly in the post. – Russ J Apr 13 '19 at 22:58
  • This is for syscall. I was talking about kernel internal function call – Bob5421 Apr 14 '19 at 05:22
  • I do not want to know the convention for irq or syscall, i want to know the convention for internal kernel function calls (when a kernel function calls another kernel function) – Bob5421 Apr 25 '19 at 07:14
  • Did you really read the linked thread? It does make much sense from performance perspective to put function parameter in a register regardless whether it is a kernel internal function or a user space application. – Jakub Palider Apr 26 '19 at 07:19