aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDavid S. Miller <davem@pierdol.cobaltmicro.com>1998-10-07 02:17:57 +0000
committerDavid S. Miller <davem@gcc.gnu.org>1998-10-06 19:17:57 -0700
commit959eb7588fd26f99adfd96a0163454649e782e4d (patch)
tree10362a8001d2a926748452d7b70c8528263e4c04 /gcc
parent849da744cd78bb82f78c7eb4c680088ebda3bbdb (diff)
downloadgcc-959eb7588fd26f99adfd96a0163454649e782e4d.zip
gcc-959eb7588fd26f99adfd96a0163454649e782e4d.tar.gz
gcc-959eb7588fd26f99adfd96a0163454649e782e4d.tar.bz2
sol2-sld-64.h (TRANSFER_FROM_TRAMPOLINE): Rework for efficiency by checking whether we need to modify the current stack...
* config/sparc/sol2-sld-64.h (TRANSFER_FROM_TRAMPOLINE): Rework for efficiency by checking whether we need to modify the current stack permission at all. (ASM_OUTPUT_CONSTRUCTOR, ASM_OUTPUT_DESTRUCTOR): Define. * config/sparc/sparc.c (sparc_initialize_trampoline): Emit __enable_execute_stack libcall here too if TRANSFER_FROM_TRAMPOLINE is defined. * config/sparc/sparc.h: Set TARGET_ARCH32 to a constant if IN_LIBGCC2. From-SVN: r22880
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog12
-rw-r--r--gcc/config/sparc/sol2-sld-64.h83
-rw-r--r--gcc/config/sparc/sparc.c4
-rw-r--r--gcc/config/sparc/sparc.h10
4 files changed, 91 insertions, 18 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3840059..4d2c2c9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,15 @@
+Wed Oct 7 02:05:20 1998 David S. Miller <davem@pierdol.cobaltmicro.com>
+
+ * config/sparc/sol2-sld-64.h (TRANSFER_FROM_TRAMPOLINE): Rework
+ for efficiency by checking whether we need to modify the current
+ stack permission at all.
+ (ASM_OUTPUT_CONSTRUCTOR, ASM_OUTPUT_DESTRUCTOR): Define.
+ * config/sparc/sparc.c (sparc_initialize_trampoline): Emit
+ __enable_execute_stack libcall here too if
+ TRANSFER_FROM_TRAMPOLINE is defined.
+ * config/sparc/sparc.h: Set TARGET_ARCH32 to a constant if
+ IN_LIBGCC2.
+
Wed Oct 7 02:27:52 1998 Jeffrey A Law (law@cygnus.com)
* Makefile.in (DRIVER_DEFINES): Remove last change.
diff --git a/gcc/config/sparc/sol2-sld-64.h b/gcc/config/sparc/sol2-sld-64.h
index 7364cbb..13b0fe3 100644
--- a/gcc/config/sparc/sol2-sld-64.h
+++ b/gcc/config/sparc/sol2-sld-64.h
@@ -293,22 +293,71 @@
#undef MD_STARTFILE_PREFIX
#define MD_STARTFILE_PREFIX "/usr/lib/sparcv9/"
+
+#endif /* ! SPARC_BI_ARCH */
+
+/*
+ * 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 bits 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.
+ *
+ */
-/* Attempt to turn on access permissions for the stack. */
-
-#define TRANSFER_FROM_TRAMPOLINE \
-void \
-__enable_execute_stack (addr) \
- void *addr; \
-{ \
- long size = getpagesize (); \
- long mask = ~(size-1); \
- char *page = (char *) (((long) addr) & mask); \
- char *end = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \
- \
- /* 7 is PROT_READ | PROT_WRITE | PROT_EXEC */ \
- if (mprotect (page, end - page, 7) < 0) \
- perror ("mprotect of trampoline code"); \
+#define TRANSFER_FROM_TRAMPOLINE \
+static int need_enable_exec_stack; \
+ \
+static void check_enabling(void) __attribute__ ((constructor)); \
+static void check_enabling(void) \
+{ \
+ extern long sysconf(int); \
+ \
+ int prot = (int) sysconf(515 /*_SC_STACK_PROT */); \
+ if (prot != 7) \
+ need_enable_exec_stack = 1; \
+} \
+ \
+void \
+__enable_execute_stack (addr) \
+ void *addr; \
+{ \
+ if (!need_enable_exec_stack) \
+ return; \
+ else { \
+ long size = getpagesize (); \
+ long mask = ~(size-1); \
+ char *page = (char *) (((long) addr) & mask); \
+ char *end = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \
+ \
+ /* 7 is PROT_READ | PROT_WRITE | PROT_EXEC */ \
+ if (mprotect (page, end - page, 7) < 0) \
+ perror ("mprotect of trampoline code"); \
+ } \
}
-
-#endif /* ! SPARC_BI_ARCH */
+
+/* A C statement (sans semicolon) to output an element in the table of
+ global constructors. */
+#undef ASM_OUTPUT_CONSTRUCTOR
+#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
+ do { \
+ ctors_section (); \
+ fprintf (FILE, "\t%s\t ", TARGET_ARCH64 ? ASM_LONGLONG : INT_ASM_OP); \
+ assemble_name (FILE, NAME); \
+ fprintf (FILE, "\n"); \
+ } while (0)
+
+/* A C statement (sans semicolon) to output an element in the table of
+ global destructors. */
+#undef ASM_OUTPUT_DESTRUCTOR
+#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
+ do { \
+ dtors_section (); \
+ fprintf (FILE, "\t%s\t ", TARGET_ARCH64 ? ASM_LONGLONG : INT_ASM_OP); \
+ assemble_name (FILE, NAME); \
+ fprintf (FILE, "\n"); \
+ } while (0)
+
diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index 16fd6b7..ae20702 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -5438,6 +5438,10 @@ sparc_initialize_trampoline (tramp, fnaddr, cxt)
SETHI i,r = 00rr rrr1 00ii iiii iiii iiii iiii iiii
JMPL r+i,d = 10dd ddd1 1100 0rrr rr1i iiii iiii iiii
*/
+#ifdef TRANSFER_FROM_TRAMPOLINE
+ emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "__enable_execute_stack"),
+ 0, VOIDmode, 1, tramp, Pmode);
+#endif
emit_move_insn (gen_rtx_MEM (SImode, plus_constant (tramp, 0)),
expand_binop (SImode, ior_optab,
diff --git a/gcc/config/sparc/sparc.h b/gcc/config/sparc/sparc.h
index e09e964..177c332 100644
--- a/gcc/config/sparc/sparc.h
+++ b/gcc/config/sparc/sparc.h
@@ -34,10 +34,18 @@ Boston, MA 02111-1307, USA. */
architectures to compile for. We allow targets to choose compile time or
runtime selection. */
#ifdef SPARC_BI_ARCH
+#ifdef IN_LIBGCC2
+#if defined(__sparcv9) || defined(__sparcv_v9) || defined(__arch64__)
+#define TARGET_ARCH32 0
+#else
+#define TARGET_ARCH32 1
+#endif /* V9 sparc */
+#else
#define TARGET_ARCH32 (! TARGET_64BIT)
+#endif /* IN_LIBGCC2 */
#else
#define TARGET_ARCH32 (DEFAULT_ARCH32_P)
-#endif
+#endif /* SPARC_BI_ARCH */
#define TARGET_ARCH64 (! TARGET_ARCH32)
/* Code model selection.