Re: MIPS 32-bit ABI stack pointer

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

 



Mason <mpeg.blue@xxxxxxx> writes:

> Before describing my problem, I'd like to ask a few questions.
>
> GCC supports several MIPS ABIs. Where are they documented?
> http://gcc.gnu.org/onlinedocs/gcc/MIPS-Options.html
> -mabi=32
> -mabi=o64
> -mabi=n32
> -mabi=64
> -mabi=eabi

They are documented in various places around the web.

-mabi=32 is the old MIPS ABI from the old company which was simply
called MIPS.

-mabi=o64 is an ABI I accidentally created many years ago when I did the
first gcc port to 64-bit MIPS processors.  See
http://gcc.gnu.org/projects/mipso64-abi.html .

-mabi=n32 was developed by SGI as part of their support for 64-bit MIPS.

-mabi=64 is the 64-bit version of n32.

-mabi=eabi was developed by a working group focused on embedded systems.
It is similar to n32 and 64 but uses smaller stack frames.

There is a bit more information, and some links which may or may not be
live, at http://www.linux-mips.org/wiki/MIPSABIHistory .


> Next question, when a function starts, is the stack pointer
> (r29) supposed to point to
> A) the last live value in the previous frame
> OR
> B) the first free/available word in the current frame
> ???

I believe the stack pointer normally points to the last live value
stored on the stack.  But note that some ABIs leave space on the
caller's stack which the callee is permitted to use.

> Do different compilers have different conventions/ABIs?

Different compilers implement different ABIs, yes.  Hopefully when two
compilers implement the same ABI, they are compatible.

>   .section .mdebug.abi32

This tells me that you are using -mabi=32.

> gcc stores r4 at fp+24 (fp+24 being the initial value of sp)

That is part of the space in the caller's stack frame available for use
by the callee when using -mabi=32.

> But the other compiler seems to consider case A.
>
> _kernel_ini_system:
>   addiu   r29,r29,#-0x10
>   sw      r31,0x0C(r29)
>   sw      r16,0x0(r29)
>   or      r16,r4,r0
>   sw      r17,0x4(r29)
>   ori     r17,r0,#0x1
>   jal     0x80159CF4
>   lw      r4,0x8(r16)
>
> The GHS compiler preserves the value pointed to by (the inital
> value of) sp.

Perhaps the GHS compiler documentation tells you which ABI it defaults
to, or perhaps you can simply ask.  Most likely it is -mabi=n32.

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