This is the mail archive of the gcc-patches@gcc.gnu.org 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]

[patch] Thumb trampoline setup


The attached patch fixes thumb trampoline setup on arm-linux and netbsd 
targets. These supplied their own INITIALIZE_TRAMPOLINE which didn't adjust 
for the different trampoline size. Fixed by teaching the routine in arm.h 
about __cache_clear.

Tested on arm-none-linux-gnueabi.
Applied to mainline and csl-arm-branch.

Paul

2005-01-05  Paul Brook  <paul@codesourcery.com>

	* config/arm/arm.h (ARM_EMIT_TRAMPOLINE_CACHE_CLEAR): Define.
	(INITIALIZE_TRAMPOLINE): Use it.
	* config/arm/linux-gas.h (INITIALIZE_TRAMPOLINE): Remove.
	* config/arm/netbsd.h (INITIALIZE_TRAMPOLINE): Remove.
	* config/arm/netbsd-elf.h (INITIALIZE_TRAMPOLINE): Remove.
Index: gcc/config/arm/arm.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/arm.h,v
retrieving revision 1.278
diff -u -p -r1.278 arm.h
--- gcc/config/arm/arm.h	29 Apr 2005 14:22:09 -0000	1.278
+++ gcc/config/arm/arm.h	1 May 2005 15:02:34 -0000
@@ -1986,6 +1986,16 @@ typedef struct
 /* Alignment required for a trampoline in bits.  */
 #define TRAMPOLINE_ALIGNMENT  32
 
+/* Call __clear_cache after setting up the trampoline unless this is a nop.  */
+#ifdef CLEAR_INSN_CACHE
+#define ARM_EMIT_TRAMPOLINE_CACHE_CLEAR(TRAMP)				\
+  emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "__clear_cache"),	\
+		     0, VOIDmode, 2, TRAMP, Pmode,			\
+		     plus_constant (TRAMP, TRAMPOLINE_SIZE), Pmode);
+#else
+#define ARM_EMIT_TRAMPOLINE_CACHE_CLEAR(TRAMP) do {} while (0)
+#endif
+
 /* Emit RTL insns to initialize the variable parts of a trampoline.
    FNADDR is an RTX for the address of the function's pure code.
    CXT is an RTX for the static chain value for the function.  */
@@ -2000,6 +2010,7 @@ typedef struct
 			       plus_constant (TRAMP,			\
 					      TARGET_ARM ? 12 : 20)),	\
 		  FNADDR);						\
+  ARM_EMIT_TRAMPOLINE_CACHE_CLEAR (TRAMP);				\
 }
 #endif
 
Index: gcc/config/arm/linux-gas.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/linux-gas.h,v
retrieving revision 1.15
diff -u -p -r1.15 linux-gas.h
--- gcc/config/arm/linux-gas.h	11 Nov 2004 03:17:59 -0000	1.15
+++ gcc/config/arm/linux-gas.h	1 May 2005 15:03:35 -0000
@@ -42,19 +42,6 @@
 #undef  WCHAR_TYPE_SIZE
 #define WCHAR_TYPE_SIZE BITS_PER_WORD
 
-/* Emit code to set up a trampoline and synchronize the caches.  */
-#undef  INITIALIZE_TRAMPOLINE
-#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)			\
-{									\
-  emit_move_insn (gen_rtx_MEM (SImode, plus_constant ((TRAMP), 8)),	\
-		  (CXT));						\
-  emit_move_insn (gen_rtx_MEM (SImode, plus_constant ((TRAMP), 12)),	\
-		  (FNADDR));						\
-  emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "__clear_cache"),	\
-		     0, VOIDmode, 2, TRAMP, Pmode,			\
-		     plus_constant (TRAMP, TRAMPOLINE_SIZE), Pmode);	\
-}
-
 /* Clear the instruction cache from `beg' to `end'.  This makes an
    inline system call to SYS_cacheflush.  */
 #define CLEAR_INSN_CACHE(BEG, END)					\
Index: gcc/config/arm/netbsd-elf.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/netbsd-elf.h,v
retrieving revision 1.13
diff -u -p -r1.13 netbsd-elf.h
--- gcc/config/arm/netbsd-elf.h	2 Mar 2005 16:27:42 -0000	1.13
+++ gcc/config/arm/netbsd-elf.h	1 May 2005 15:03:35 -0000
@@ -136,21 +136,6 @@
 #undef DEFAULT_STRUCTURE_SIZE_BOUNDARY
 #define DEFAULT_STRUCTURE_SIZE_BOUNDARY 8
 
-/* Emit code to set up a trampoline and synchronize the caches.  */
-#undef INITIALIZE_TRAMPOLINE
-#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)			\
-do									\
-  {									\
-    emit_move_insn (gen_rtx_MEM (SImode, plus_constant ((TRAMP), 8)),	\
-		    (CXT));						\
-    emit_move_insn (gen_rtx_MEM (SImode, plus_constant ((TRAMP), 12)),	\
-		    (FNADDR));						\
-    emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "__clear_cache"),	\
-		       0, VOIDmode, 2, TRAMP, Pmode,			\
-		       plus_constant (TRAMP, TRAMPOLINE_SIZE), Pmode);	\
-  }									\
-while (0)
-
 /* Clear the instruction cache from `BEG' to `END'.  This makes a
    call to the ARM_SYNC_ICACHE architecture specific syscall.  */
 #define CLEAR_INSN_CACHE(BEG, END)					\
Index: gcc/config/arm/netbsd.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/netbsd.h,v
retrieving revision 1.30
diff -u -p -r1.30 netbsd.h
--- gcc/config/arm/netbsd.h	18 Nov 2004 15:59:47 -0000	1.30
+++ gcc/config/arm/netbsd.h	1 May 2005 15:03:34 -0000
@@ -138,19 +138,6 @@
 #undef  DEFAULT_STRUCTURE_SIZE_BOUNDARY
 #define DEFAULT_STRUCTURE_SIZE_BOUNDARY 8
 
-/* Emit code to set up a trampoline and synchronize the caches.  */
-#undef  INITIALIZE_TRAMPOLINE
-#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)                      \
-{                                                                      \
-  emit_move_insn (gen_rtx_MEM (SImode, plus_constant ((TRAMP), 8)),   \
-                 (CXT));                                               \
-  emit_move_insn (gen_rtx_MEM (SImode, plus_constant ((TRAMP), 12)),  \
-                 (FNADDR));                                            \
-  emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "__clear_cache"),      \
-                    0, VOIDmode, 2, TRAMP, Pmode,                      \
-                    plus_constant (TRAMP, TRAMPOLINE_SIZE), Pmode);    \
-}
-
 /* Clear the instruction cache from `BEG' to `END'.  This makes a
    call to the ARM32_SYNC_ICACHE architecture specific syscall.  */
 #define CLEAR_INSN_CACHE(BEG, END)                                     \

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