This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: x86 procedure calling convention.


On 09/16/2012 10:05 AM, phi gcc wrote:

> Pardon my naive question, I am newbe in x86 (32bit) architecture and I
> got hard time to find info on x86 procedure convention with GCC.
> 
> The doc I found so far say that with __attribute__((fastcall)) it is
> possible to pass up to 2 long into regs ecx, edx.
> 
> Yet looking at linux kernel code I got this on a piece of code.
> 
> disass crash_kexec
> 0xc049a8c0 crash_kexec:
> ....
> 0x00000000c049a922         movl   kexec_crash_image,%eax
> 0x00000000c049a927         calll  machine_kexec
> 
> The C code shows
> void crash_kexec(struct pt_regs *regs)
> {...
>                         machine_kexec(kexec_crash_image);
>  }
> 
> and machine_kexec() prolog shows
> 0xc042c2a0 machine_kexec:
> 0x00000000c042c2a0         pushl  %ebp
> 0x00000000c042c2a1         pushl  %edi
> 0x00000000c042c2a2         pushl  %esi
> 0x00000000c042c2a3         pushl  %ebx
> 0x00000000c042c2a4         movl   %eax,%ebx
> 0x00000000c042c2a6         subl   $0x2c,%esp
> 
> With a save of eax (suposedly args0) into a callee save.
> 
> So my question, does GCC under some circumstance does pass args0 into rax ?

GCC can call static functions in any way it likes, or it can inline them.
Calling conventions aren't relevant here: a static function isn't reachable
from any external caller.

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]