Re: request: calling conventions documentation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Michael Kerrisk (man-pages) dixit:

>So, the manual page already has the info below. And from your mail
>above, it's not immediately clear to me what you would like to see
>added. Could you provide a concrete example for a specific
>architecture?

Sure. I’m using i386 as I’m the most familiar with it.


>       Arch/ABI      arg1  arg2  arg3  arg4  arg5  arg6  arg7  Notes
>       ──────────────────────────────────────────────────────────────
>       i386          ebx   ecx   edx   esi   edi   ebp   -

This is syscall args. It doesn’t say how userspace args are
handled (not in registers by default, but the return value
is in edx:eax normally), nor which registers are caller-saved
(eax, ecx, edx) or callee-saved (ebx, ebp, esi, edi). Add the
name of the stack pointer register (here esp) and you have
additionally mapped out the entire basic register file.

https://en.wikipedia.org/wiki/X86_calling_conventions#List_of_x86_calling_conventions
(look at IA-32 / cdecl) has more information, I guess, but
that’s the most important ones. (It’s also incorrect; many
Unix systems only align the stack to 4 bytes, and 64-bit
values are returned in EDX:EAX, not EAX:EDX, on either.)

Some architectures have a more complex register file involving
renaming on function call (IIRC sparc does this); this is
something I’d also like to see mentioned. Anything more complex
the user would still need to look up, but even having this much
would enable really fast lookup of the basics that are surprisingly
hard to track down for all architectures as there doesn’t seem to
be a single place for this. (I recently had to fix something on
sh4 and wished for it.)

Thanks,
//mirabilos
-- 
When he found out that the m68k port was in a pretty bad shape, he did
not, like many before him, shrug and move on; instead, he took it upon
himself to start compiling things, just so he could compile his shell.
How's that for dedication. -- Wouter, about my Debian/m68k revival



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux