libgcc2.c (__enable_execute_stack): New symbol.

* 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
This commit is contained in:
Eric Botcazou 2004-07-17 23:09:14 +02:00 committed by Eric Botcazou
parent 6e34d3a39f
commit e7a742ec96
17 changed files with 76 additions and 21 deletions

View File

@ -1,3 +1,30 @@
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.

View File

@ -5782,7 +5782,7 @@ alpha_initialize_trampoline (rtx tramp, rtx fnaddr, rtx cxt,
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

View File

@ -76,7 +76,7 @@ Boston, MA 02111-1307, USA. */
/* 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

View File

@ -144,7 +144,7 @@ Boston, MA 02111-1307, USA. */
/* Attempt to turn on access permissions for the stack. */
#define TRANSFER_FROM_TRAMPOLINE \
#define ENABLE_EXECUTE_STACK \
void \
__enable_execute_stack (void *addr) \
{ \

View File

@ -12659,7 +12659,7 @@ x86_initialize_trampoline (rtx tramp, rtx fnaddr, rtx cxt)
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

View File

@ -120,6 +120,6 @@ Boston, MA 02111-1307, USA. */
#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)");

View File

@ -69,4 +69,4 @@
#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

View File

@ -68,6 +68,6 @@ Boston, MA 02111-1307, USA. */
}
/* 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)");

View File

@ -178,7 +178,7 @@ Boston, MA 02111-1307, USA. */
/* 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
@ -193,8 +193,7 @@ Boston, MA 02111-1307, USA. */
#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 *, \

View File

@ -162,9 +162,6 @@ Boston, MA 02111-1307, USA. */
/*
* 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.
@ -172,10 +169,10 @@ Boston, MA 02111-1307, USA. */
*/
/* 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) */ \
\

View File

@ -96,7 +96,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#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) \

View File

@ -89,7 +89,7 @@ Boston, MA 02111-1307, USA. */
#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);

View File

@ -7575,7 +7575,7 @@ sparc_initialize_trampoline (rtx tramp, rtx fnaddr, rtx cxt)
/* 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
@ -7616,7 +7616,7 @@ sparc64_initialize_trampoline (rtx tramp, rtx fnaddr, rtx cxt)
/* 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

View File

@ -4694,6 +4694,19 @@ typically be a series of @code{asm} statements. Both @var{beg} and
@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

View File

@ -216,3 +216,9 @@ GCC_3.4 {
__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
}

View File

@ -1487,6 +1487,19 @@ __clear_cache (char *beg __attribute__((__unused__)),
#endif /* L_clear_cache */
#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 */
#ifdef L_trampoline
/* Jump to a trampoline, loading the static chain address. */

View File

@ -48,8 +48,8 @@ lib2funcs='_muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3
_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'