* libgcc2.c (__enable_execute_stack): New symbol.
* libgcc-std.ver (GCC_3.4.2): New version. Inherit from GCC_3.4
and declare __enable_execute_stack.
* mklibgcc.in (lib2funcs): Add _enable_execute_stack.
* config/netbsd.h (NETBSD_ENABLE_EXECUTE_STACK): ANSIfy.
* config/sol2.h (TRANSFER_FROM_TRAMPOLINE): Rename into
ENABLE_EXECUTE_STACK.
* config/alpha/alpha.c (alpha_initialize_trampoline): Conditionalize
on ENABLE_EXECUTE_STACK instead of TRANSFER_FROM_TRAMPOLINE.
* config/alpha/netbsd.h (TRANSFER_FROM_TRAMPOLINE): Rename into
ENABLE_EXECUTE_STACK.
* config/alpha/osf.h (TRANSFER_FROM_TRAMPOLINE): Likewise.
* config/i386/i386.c (x86_initialize_trampoline): Conditionalize
on ENABLE_EXECUTE_STACK instead of TRANSFER_FROM_TRAMPOLINE.
* config/i386/netbsd-elf.h (TRANSFER_FROM_TRAMPOLINE): Rename into
ENABLE_EXECUTE_STACK.
* config/i386/netbsd.h (TRANSFER_FROM_TRAMPOLINE): Likewise.
* config/i386/netbsd64.h (TRANSFER_FROM_TRAMPOLINE): Likewise.
* config/sparc/freebsd.h (TRANSFER_FROM_TRAMPOLINE): Likewise.
* config/sparc/netbsd-elf.h (TRANSFER_FROM_TRAMPOLINE): Likewise.
* config/sparc/sparc.c (sparc_initialize_trampoline): Conditionalize
on ENABLE_EXECUTE_STACK instead of TRANSFER_FROM_TRAMPOLINE.
(sparc64_initialize_trampoline): Likewise.
* doc/tm.texi (trampolines): Add ENABLE_EXECUTE_STACK macro.
From-SVN: r84880
+2004-07-17 Eric Botcazou <ebotcazou@act-europe.fr>
+
+ * libgcc2.c (__enable_execute_stack): New symbol.
+ * libgcc-std.ver (GCC_3.4.2): New version. Inherit from GCC_3.4
+ and declare __enable_execute_stack.
+ * mklibgcc.in (lib2funcs): Add _enable_execute_stack.
+ * config/netbsd.h (NETBSD_ENABLE_EXECUTE_STACK): ANSIfy.
+ * config/sol2.h (TRANSFER_FROM_TRAMPOLINE): Rename into
+ ENABLE_EXECUTE_STACK.
+ * config/alpha/alpha.c (alpha_initialize_trampoline): Conditionalize
+ on ENABLE_EXECUTE_STACK instead of TRANSFER_FROM_TRAMPOLINE.
+ * config/alpha/netbsd.h (TRANSFER_FROM_TRAMPOLINE): Rename into
+ ENABLE_EXECUTE_STACK.
+ * config/alpha/osf.h (TRANSFER_FROM_TRAMPOLINE): Likewise.
+ * config/i386/i386.c (x86_initialize_trampoline): Conditionalize
+ on ENABLE_EXECUTE_STACK instead of TRANSFER_FROM_TRAMPOLINE.
+ * config/i386/netbsd-elf.h (TRANSFER_FROM_TRAMPOLINE): Rename into
+ ENABLE_EXECUTE_STACK.
+ * config/i386/netbsd.h (TRANSFER_FROM_TRAMPOLINE): Likewise.
+ * config/i386/netbsd64.h (TRANSFER_FROM_TRAMPOLINE): Likewise.
+ * config/sparc/freebsd.h (TRANSFER_FROM_TRAMPOLINE): Likewise.
+ * config/sparc/netbsd-elf.h (TRANSFER_FROM_TRAMPOLINE): Likewise.
+ * config/sparc/sparc.c (sparc_initialize_trampoline): Conditionalize
+ on ENABLE_EXECUTE_STACK instead of TRANSFER_FROM_TRAMPOLINE.
+ (sparc64_initialize_trampoline): Likewise.
+ * doc/tm.texi (trampolines): Add ENABLE_EXECUTE_STACK macro.
+
2004-07-17 Joseph S. Myers <jsm@polyomino.org.uk>
* langhooks.h (builtin_function): New langhook.
emit_move_insn (gen_rtx_MEM (SImode, addr), temp1);
}
-#ifdef TRANSFER_FROM_TRAMPOLINE
+#ifdef ENABLE_EXECUTE_STACK
emit_library_call (init_one_libfunc ("__enable_execute_stack"),
0, VOIDmode, 1, tramp, Pmode);
#endif
/* Attempt to enable execute permissions on the stack. */
-#define TRANSFER_FROM_TRAMPOLINE NETBSD_ENABLE_EXECUTE_STACK
+#define ENABLE_EXECUTE_STACK NETBSD_ENABLE_EXECUTE_STACK
#undef TARGET_VERSION
/* Attempt to turn on access permissions for the stack. */
-#define TRANSFER_FROM_TRAMPOLINE \
+#define ENABLE_EXECUTE_STACK \
void \
__enable_execute_stack (void *addr) \
{ \
abort ();
}
-#ifdef TRANSFER_FROM_TRAMPOLINE
+#ifdef ENABLE_EXECUTE_STACK
emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "__enable_execute_stack"),
LCT_NORMAL, VOIDmode, 1, tramp, Pmode);
#endif
#define DEFAULT_PCC_STRUCT_RETURN 1
/* Attempt to enable execute permissions on the stack. */
-#define TRANSFER_FROM_TRAMPOLINE NETBSD_ENABLE_EXECUTE_STACK
+#define ENABLE_EXECUTE_STACK NETBSD_ENABLE_EXECUTE_STACK
#define TARGET_VERSION fprintf (stderr, " (NetBSD/i386 ELF)");
#define GOT_SYMBOL_NAME "GLOBAL_OFFSET_TABLE_"
/* Attempt to enable execute permissions on the stack. */
-#define TRANSFER_FROM_TRAMPOLINE NETBSD_ENABLE_EXECUTE_STACK
+#define ENABLE_EXECUTE_STACK NETBSD_ENABLE_EXECUTE_STACK
}
/* Attempt to enable execute permissions on the stack. */
-#define TRANSFER_FROM_TRAMPOLINE NETBSD_ENABLE_EXECUTE_STACK
+#define ENABLE_EXECUTE_STACK NETBSD_ENABLE_EXECUTE_STACK
#define TARGET_VERSION fprintf (stderr, " (NetBSD/x86_64 ELF)");
\f
/* Attempt to turn on execute permission for the stack. This may be
- used by TRANSFER_FROM_TRAMPOLINE of the target needs it (that is,
+ used by INITIALIZE_TRAMPOLINE of the target needs it (that is,
if the target machine can change execute permissions on a page).
There is no way to query the execute permission of the stack, so
#define NETBSD_ENABLE_EXECUTE_STACK \
extern void __enable_execute_stack (void *); \
void \
-__enable_execute_stack (addr) \
- void *addr; \
+__enable_execute_stack (void *addr) \
{ \
extern int mprotect (void *, size_t, int); \
extern int __sysctl (int *, unsigned int, void *, size_t *, \
/*
* Attempt to turn on access permissions for the stack.
*
- * This code must be defined when compiling gcc but not when compiling
- * libgcc2.a, unless we're generating code for 64-bit SPARC
- *
* _SC_STACK_PROT is only defined for post 2.6, but we want this code
* to run always. 2.6 can change the stack protection but has no way to
* query it.
*/
/* sys/mman.h is not present on some non-Solaris configurations
- that use sol2.h, so TRANSFER_FROM_TRAMPOLINE must use a magic
+ that use sol2.h, so ENABLE_EXECUTE_STACK must use a magic
number instead of the appropriate PROT_* flags. */
-#define TRANSFER_FROM_TRAMPOLINE \
+#define ENABLE_EXECUTE_STACK \
\
/* #define STACK_PROT_RWX (PROT_READ | PROT_WRITE | PROT_EXEC) */ \
\
#undef SPARC_DEFAULT_CMODEL
#define SPARC_DEFAULT_CMODEL CM_MEDLOW
-#define TRANSFER_FROM_TRAMPOLINE \
+#define ENABLE_EXECUTE_STACK \
static int need_enable_exec_stack; \
static void check_enabling(void) __attribute__ ((constructor)); \
static void check_enabling(void) \
#undef STDC_0_IN_SYSTEM_HEADERS
/* Attempt to enable execute permissions on the stack. */
-#define TRANSFER_FROM_TRAMPOLINE NETBSD_ENABLE_EXECUTE_STACK
+#define ENABLE_EXECUTE_STACK NETBSD_ENABLE_EXECUTE_STACK
#undef TARGET_VERSION
#define TARGET_VERSION fprintf (stderr, " (%s)", TARGET_NAME);
/* Call __enable_execute_stack after writing onto the stack to make sure
the stack address is accessible. */
-#ifdef TRANSFER_FROM_TRAMPOLINE
+#ifdef ENABLE_EXECUTE_STACK
emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "__enable_execute_stack"),
LCT_NORMAL, VOIDmode, 1, tramp, Pmode);
#endif
/* Call __enable_execute_stack after writing onto the stack to make sure
the stack address is accessible. */
-#ifdef TRANSFER_FROM_TRAMPOLINE
+#ifdef ENABLE_EXECUTE_STACK
emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "__enable_execute_stack"),
LCT_NORMAL, VOIDmode, 1, tramp, Pmode);
#endif
@var{end} are both pointer expressions.
@end defmac
+The operating system may also require the stack to be made executable
+before calling the trampoline. To implement this requirement, define
+the following macro.
+
+@defmac ENABLE_EXECUTE_STACK
+Define this macro if certain operations must be performed before executing
+code located on the stack. The macro should expand to a series of C
+file-scope constructs (e.g. functions) and provide a unique entry point
+named @code{__enable_execute_stack}. The target is responsible for
+emitting calls to the entry point in the code, for example from the
+@code{INITIALIZE_TRAMPOLINE} macro.
+@end defmac
+
To use a standard subroutine, define the following macro. In addition,
you must make sure that the instructions in a trampoline fill an entire
cache line with identical instructions, or else ensure that the
__paritydi2
__parityti2
}
+
+%inherit GCC_3.4.2 GCC_3.4
+GCC_3.4.2 {
+ # Used to deal with trampoline initialization on some platforms
+ __enable_execute_stack
+}
#endif /* L_clear_cache */
\f
+#ifdef L_enable_execute_stack
+/* Attempt to turn on execute permission for the stack. */
+
+#ifdef ENABLE_EXECUTE_STACK
+ ENABLE_EXECUTE_STACK
+#else
+void
+__enable_execute_stack (void *addr __attribute__((__unused__)))
+{}
+#endif /* ENABLE_EXECUTE_STACK */
+
+#endif /* L_enable_execute_stack */
+\f
#ifdef L_trampoline
/* Jump to a trampoline, loading the static chain address. */
_cmpdi2 _ucmpdi2 _floatdidf _floatdisf _fixunsdfsi _fixunssfsi
_fixunsdfdi _fixdfdi _fixunssfdi _fixsfdi _fixxfdi _fixunsxfdi
_floatdixf _fixunsxfsi _fixtfdi _fixunstfdi _floatditf _clear_cache
- _trampoline __main _absvsi2 _absvdi2 _addvsi3 _addvdi3
- _subvsi3 _subvdi3 _mulvsi3 _mulvdi3 _negvsi2 _negvdi2 _ctors
+ _enable_execute_stack _trampoline __main _absvsi2 _absvdi2 _addvsi3
+ _addvdi3 _subvsi3 _subvdi3 _mulvsi3 _mulvdi3 _negvsi2 _negvdi2 _ctors
_ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 _ctzsi2 _ctzdi2 _popcount_tab
_popcountsi2 _popcountdi2 _paritysi2 _paritydi2'