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
This commit is contained in:
parent
849da744cd
commit
959eb7588f
@ -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.
|
||||
|
@ -293,22 +293,71 @@
|
||||
|
||||
#undef MD_STARTFILE_PREFIX
|
||||
#define MD_STARTFILE_PREFIX "/usr/lib/sparcv9/"
|
||||
|
||||
/* 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"); \
|
||||
}
|
||||
|
||||
|
||||
#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.
|
||||
*
|
||||
*/
|
||||
|
||||
#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"); \
|
||||
} \
|
||||
}
|
||||
|
||||
/* 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)
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user