Re: gcc return struct code generation

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

 



Hi,

I also think is a bug, but i'm not sure. My toy kernel has no assembly (.S) files, but of course it has c functions with
inline assembly. My context switch function it's a c funtion (yes i know there are better ways of doing this) with some
inline assembly code first to save context, some c code, and then some assembly code to restore context and do 'iret'.
It works only if the C code doesn't touch the rsp, because I 'intercept' the end of the function.

I known that is 'questionable' code, but the real question is that i expect that this simple C code not to touch RSP with optimizations
enabled in x86_64. I got surprised. Note that you point of stack aligned on 16 byte boundary is irrelevant, because it has to be aligned
on 'fn' entry call.

Jose.


----- Mensaje original -----
De: Ian Lance Taylor <iant@xxxxxxxxxx>
Para: jose gomez valcarcel <jcgv33@xxxxxxxx>
CC: "gcc-help@xxxxxxxxxxx" <gcc-help@xxxxxxxxxxx>; "jcgv@xxxxxxxxxx" <jcgv@xxxxxxxxxx>
Enviado: lunes 29 de agosto de 2011 23:29
Asunto: Re: gcc return struct code generation

jose gomez valcarcel <jcgv33@xxxxxxxx> writes:

> I just read x86_64 ABI code generation, and the result is ok. The
> struct is returned in registers RAX, RDX. The only disappointing thing
> is the allocation of 40 stack bytes, whic apparently is not used. This
> effect cause my kernel code not to mix well with hand-assembler code.

That is a good question.  I think it is a bug.  Although I'm curious as
to why allocating extra unused stack space is a problem for your kernel
code.  Some stack space will always be used, because the x86_64 ABI
requires the stack to be aligned on a 16-byte boundary before executing
a call instruction.

Ian




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux