From: ebotcazou Date: Sat, 17 Jul 2004 21:09:14 +0000 (+0000) Subject: * libgcc2.c (__enable_execute_stack): New symbol. X-Git-Tag: upstream/4.9.2~69414 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5577e296f30c21bb7a918ad14632a7d162e269fd;p=platform%2Fupstream%2Flinaro-gcc.git * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@84880 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f71c905..afea289 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,30 @@ +2004-07-17 Eric Botcazou + + * 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 * langhooks.h (builtin_function): New langhook. diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index 102cbb1..646258b 100644 --- a/gcc/config/alpha/alpha.c +++ b/gcc/config/alpha/alpha.c @@ -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 diff --git a/gcc/config/alpha/netbsd.h b/gcc/config/alpha/netbsd.h index 1eede22..d4f833a 100644 --- a/gcc/config/alpha/netbsd.h +++ b/gcc/config/alpha/netbsd.h @@ -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 diff --git a/gcc/config/alpha/osf.h b/gcc/config/alpha/osf.h index 04b7bf1..954a4ad 100644 --- a/gcc/config/alpha/osf.h +++ b/gcc/config/alpha/osf.h @@ -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) \ { \ diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index b8aa661..bcc9104 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -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 diff --git a/gcc/config/i386/netbsd-elf.h b/gcc/config/i386/netbsd-elf.h index cfd8837..bd2e9de 100644 --- a/gcc/config/i386/netbsd-elf.h +++ b/gcc/config/i386/netbsd-elf.h @@ -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)"); diff --git a/gcc/config/i386/netbsd.h b/gcc/config/i386/netbsd.h index 45ae893..dd7eae1 100644 --- a/gcc/config/i386/netbsd.h +++ b/gcc/config/i386/netbsd.h @@ -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 diff --git a/gcc/config/i386/netbsd64.h b/gcc/config/i386/netbsd64.h index 7ff09d5..66f31e0 100644 --- a/gcc/config/i386/netbsd64.h +++ b/gcc/config/i386/netbsd64.h @@ -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)"); diff --git a/gcc/config/netbsd.h b/gcc/config/netbsd.h index 40adf1a..aad3cac 100644 --- a/gcc/config/netbsd.h +++ b/gcc/config/netbsd.h @@ -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 *, \ diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h index 1ff6308..aa567bc 100644 --- a/gcc/config/sol2.h +++ b/gcc/config/sol2.h @@ -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) */ \ \ diff --git a/gcc/config/sparc/freebsd.h b/gcc/config/sparc/freebsd.h index d8dfbf0..389c00d 100644 --- a/gcc/config/sparc/freebsd.h +++ b/gcc/config/sparc/freebsd.h @@ -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) \ diff --git a/gcc/config/sparc/netbsd-elf.h b/gcc/config/sparc/netbsd-elf.h index 3cfd0fc..3c2f8a9 100644 --- a/gcc/config/sparc/netbsd-elf.h +++ b/gcc/config/sparc/netbsd-elf.h @@ -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); diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index 1dbd002..d378757 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -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 diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index ca5c995..c7aade3 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -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 diff --git a/gcc/libgcc-std.ver b/gcc/libgcc-std.ver index 749040e..1abe07c 100644 --- a/gcc/libgcc-std.ver +++ b/gcc/libgcc-std.ver @@ -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 +} diff --git a/gcc/libgcc2.c b/gcc/libgcc2.c index 8a953ea..8a3529b 100644 --- a/gcc/libgcc2.c +++ b/gcc/libgcc2.c @@ -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. */ diff --git a/gcc/mklibgcc.in b/gcc/mklibgcc.in index 9835f62..d5f7937 100644 --- a/gcc/mklibgcc.in +++ b/gcc/mklibgcc.in @@ -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'