This is the mail archive of the
mailing list for the GCC project.
Re: Fix Thumb-2 Linux nested functions with -O0 libgcc
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: "Joseph S. Myers" <joseph at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 28 May 2009 16:37:27 +0100
- Subject: Re: Fix Thumb-2 Linux nested functions with -O0 libgcc
- References: <Pine.LNX.firstname.lastname@example.org>
On Wed, 2009-05-20 at 14:55 +0000, Joseph S. Myers wrote:
> This patch fixes a problem calling nested functions on ARM EABI
> GNU/Linux if libgcc is built for Thumb-2 with -O0.
> The libgcc function __clear_cache, used when stack trampolines are in
> use, is defined using an asm that puts the inputs in register
> variables, an ARM-specific syscall number in a register variable for
> r7, and calls the syscall.
> r7 is also used as the frame pointer for Thumb. If GCC eliminates the
> frame pointer the asm works OK, but if not (in particular if building
> with -O0) then the generated code ends up trying to use the syscall
> number stored in r7 as the frame pointer for restoring values from the
> stack. To avoid this problem arising, it seems simplest to implement
> this simple function directly in assembly, which this patch does.
> Tested with no regressions with cross to arm-none-linux-gnueabi. OK
> to commit?
> 2009-05-20 Joseph Myers <email@example.com>
> * config/arm/lib1funcs.asm (__clear_cache): Define if
> * config/arm/linux-eabi.h (CLEAR_INSN_CACHE): Define to give an
> error if used.
> * config/arm/t-linux-eabi (LIB1ASMFUNCS): Add _clear_cache.
This is OK, however...
> +#ifdef L_clear_cache
> +@ EABI GNU/Linux call to cacheflush syscall.
> +#if !defined __ARM_EABI__ || !defined __linux__
> +#error "This is only for ARM EABI GNU/Linux"
This would be more easily extensible if written as a guard around the
implementation with a #else at the end to cache unsupported targets.
#error unsupported target