This is the mail archive of the 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: Fix Thumb-2 Linux nested functions with -O0 libgcc

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  <>
> 	* config/arm/lib1funcs.asm (__clear_cache): Define if
> 	L_clear_cache.
> 	* 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"
> +#endif

This would be more easily extensible if written as a guard around the
implementation with a #else at the end to cache unsupported targets.

#if supported_target_1
#elif supported_target_2
#error unsupported target


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