This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] fix nested procedures for FreeBSD/sparc64
- From: "David O'Brien" <obrien at FreeBSD dot org>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 31 Oct 2002 00:56:17 -0800
- Subject: [PATCH] fix nested procedures for FreeBSD/sparc64
- Organization: The NUXI BSD Group
- Reply-to: obrien at FreeBSD dot org
I'd like to commit this to both mainline and the 3.2 branch:
This simply copies the TRANSFER_FROM_TRAMPOLINE bits from sparc/sol2.h as
FreeBSD needs the same treatment.
2002-10-31 David O'Brien <obrien@FreeBSD.org>
* config/sparc/freebsd.h (TRANSFER_FROM_TRAMPOLINE): Define
__enable_execute_stack function.
Index: config/sparc/freebsd.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/sparc/freebsd.h,v
retrieving revision 1.12
diff -u -r1.12 freebsd.h
--- config/sparc/freebsd.h 15 Sep 2002 12:03:42 -0000 1.12
+++ config/sparc/freebsd.h 31 Oct 2002 08:54:25 -0000
@@ -154,3 +154,34 @@
/* We use GNU ld so undefine this so that attribute((init_priority)) works. */
#undef CTORS_SECTION_ASM_OP
#undef DTORS_SECTION_ASM_OP
+
+#define TRANSFER_FROM_TRAMPOLINE \
+static int need_enable_exec_stack; \
+ \
+static void check_enabling(void) __attribute__ ((constructor)); \
+static void check_enabling(void) \
+{ \
+ extern int sysctlbyname(const char *, void *, size_t *, void *, size_t);\
+ size_t len; \
+ int prot; \
+ \
+ prot = 0; \
+ len = sizeof(prot); \
+ sysctlbyname ("kern.stackprot", &prot, &len, NULL, 0); \
+ if (prot != 7) \
+ need_enable_exec_stack = 1; \
+} \
+ \
+extern void __enable_execute_stack (void *); \
+void \
+__enable_execute_stack (addr) \
+ void *addr; \
+{ \
+ if (!need_enable_exec_stack) \
+ return; \
+ else { \
+ /* 7 is PROT_READ | PROT_WRITE | PROT_EXEC */ \
+ if (mprotect (addr, TRAMPOLINE_SIZE, 7) < 0) \
+ perror ("mprotect of trampoline code"); \
+ } \
+}