public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "gcc at microbizz dot nl" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/24959] Trampolines fail on i686-apple-darwin Date: Mon, 21 Nov 2005 19:28:00 -0000 [thread overview] Message-ID: <20051121192811.2506.qmail@sourceware.org> (raw) In-Reply-To: <bug-24959-6064@http.gcc.gnu.org/bugzilla/> ------- Comment #2 from gcc at microbizz dot nl 2005-11-21 19:28 ------- Subject: Trampolines fail on i686-apple-darwin On closer inspection, the problem is that the stack is non-executable. Adding the following code (borrowed from gcc/config/netbsd.h) to darwin.h fixes the problem Adriaan van Os /* Attempt to turn on execute permission for the stack. This may be 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 we always issue the mprotect() call. Note that we go out of our way to use namespace-non-invasive calls here. Unfortunately, there is no libc-internal name for mprotect(). Also note that no errors should be emitted by this code; it is considered dangerous for library calls to send messages to stdout/stderr. */ #define ENABLE_EXECUTE_STACK \ extern void __enable_execute_stack (void *); \ void \ __enable_execute_stack (void *addr) \ { \ extern int mprotect (void *, size_t, int); \ extern int __sysctl (int *, unsigned int, void *, size_t *, \ void *, size_t); \ \ static int size; \ static long mask; \ \ char *page, *end; \ \ if (size == 0) \ { \ int mib[2]; \ size_t len; \ \ mib[0] = 6; /* CTL_HW */ \ mib[1] = 7; /* HW_PAGESIZE */ \ len = sizeof (size); \ (void) __sysctl (mib, 2, &size, &len, NULL, 0); \ mask = ~((long) size - 1); \ } \ \ page = (char *) (((long) addr) & mask); \ end = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \ \ /* 7 == PROT_READ | PROT_WRITE | PROT_EXEC */ \ (void) mprotect (page, end - page, 7); \ } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24959
next prev parent reply other threads:[~2005-11-21 19:28 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 2005-11-20 16:19 [Bug target/24959] New: " gcc at microbizz dot nl 2005-11-20 21:17 ` [Bug target/24959] " gcc at microbizz dot nl 2005-11-21 19:28 ` gcc at microbizz dot nl [this message] 2005-11-21 20:43 ` [Bug target/24959] Trampolines fail on i686-apple-darwin because stack is not executable pinskia at gcc dot gnu dot org 2005-11-21 20:49 ` pinskia at gcc dot gnu dot org 2005-11-22 9:12 ` gcc at microbizz dot nl 2006-01-12 1:56 ` pinskia at gcc dot gnu dot org 2006-01-12 1:57 ` pinskia at gcc dot gnu dot org 2006-01-17 15:15 ` ssen at opendarwin dot org 2006-01-17 15:30 ` gcc at microbizz dot nl 2006-01-25 18:35 ` pinskia at gcc dot gnu dot org 2006-02-20 23:53 ` pinskia at gcc dot gnu dot org 2006-02-27 9:08 ` echristo at apple dot com 2006-02-27 12:38 ` gcc at microbizz dot nl 2006-02-28 1:48 ` echristo at apple dot com 2006-03-03 20:18 ` echristo at apple dot com 2007-01-10 19:27 ` pinskia at gcc dot gnu dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20051121192811.2506.qmail@sourceware.org \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).