* libgcc2.c (__enable_execute_stack): New symbol.
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 17 Jul 2004 21:09:14 +0000 (21:09 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 17 Jul 2004 21:09:14 +0000 (21:09 +0000)
* 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

17 files changed:
gcc/ChangeLog
gcc/config/alpha/alpha.c
gcc/config/alpha/netbsd.h
gcc/config/alpha/osf.h
gcc/config/i386/i386.c
gcc/config/i386/netbsd-elf.h
gcc/config/i386/netbsd.h
gcc/config/i386/netbsd64.h
gcc/config/netbsd.h
gcc/config/sol2.h
gcc/config/sparc/freebsd.h
gcc/config/sparc/netbsd-elf.h
gcc/config/sparc/sparc.c
gcc/doc/tm.texi
gcc/libgcc-std.ver
gcc/libgcc2.c
gcc/mklibgcc.in

index f71c905..afea289 100644 (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.
index 102cbb1..646258b 100644 (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
index 1eede22..d4f833a 100644 (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
index 04b7bf1..954a4ad 100644 (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)                                    \
 {                                                                      \
index b8aa661..bcc9104 100644 (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
index cfd8837..bd2e9de 100644 (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)");
index 45ae893..dd7eae1 100644 (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
index 7ff09d5..66f31e0 100644 (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)");
index 40adf1a..aad3cac 100644 (file)
@@ -178,7 +178,7 @@ Boston, MA 02111-1307, USA.  */
 \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
@@ -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 *,          \
index 1ff6308..aa567bc 100644 (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) */      \
                                                                        \
index d8dfbf0..389c00d 100644 (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)                                     \
index 3cfd0fc..3c2f8a9 100644 (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);
index 1dbd002..d378757 100644 (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
index ca5c995..c7aade3 100644 (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
index 749040e..1abe07c 100644 (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
+}
index 8a953ea..8a3529b 100644 (file)
@@ -1487,6 +1487,19 @@ __clear_cache (char *beg __attribute__((__unused__)),
 
 #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.  */
index 9835f62..d5f7937 100644 (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'