This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: nested functions on Arm
On Wed, Sep 13, 2000 at 01:11:14PM +0100, Richard Earnshaw wrote:
> > The nested function handling on Arm is completely broken in the
> > moment. This prevents glibc from being used on Arm in the moment.
> >
> > The problem is this piece from config/arm/arm.h:
> >
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > /* Output assembler code for a block containing the constant parts
> > of a trampoline, leaving space for the variable parts.
> >
> > On the ARM, (if r8 is the static chain regnum, and remembering that
> > referencing pc adds an offset of 8) the trampoline looks like:
> > ldr r8, [pc, #0]
> > ldr pc, [pc]
> > .word static chain value
> > .word function's address
> > ??? FIXME: When the trampoline returns, r8 will be clobbered. */
> > #define ARM_TRAMPOLINE_TEMPLATE(FILE) \
> > { \
> > asm_fprintf (FILE, "\tldr\t%r, [%r, #0]\n", \
> > STATIC_CHAIN_REGNUM, PC_REGNUM); \
> > asm_fprintf (FILE, "\tldr\t%r, [%r, #0]\n", \
> > PC_REGNUM, PC_REGNUM); \
> > ASM_OUTPUT_INT (FILE, const0_rtx); \
> > ASM_OUTPUT_INT (FILE, const0_rtx); \
> > }
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > r8 must be saved by the called function but the trampoline code
> > clobbers the register even before control reaches the actual function.
>
> This is a known problem. Unfortunately, I've no idea how to solve it.
> The fundamental problem is that we need a call clobbered register to pass
> the static chain, but there are none spare in the ARM ABI (r0-r3 are used
> for arguments, lr has the return address and ip is either used by the
> prologue code or, sometimes, for passing the PIC table base); all the
> other registers are call-saved.
IIRC, you should be able to make the static chain be in a call-saved register.
Either that or you can probably add a new macro that passes the static chain
register as the first argument (much like we can do for structure returns).
--
Michael Meissner, Red Hat, Inc.
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work: meissner@redhat.com phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org fax: +1 978-692-4482