public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/24959]  New: Trampolines fail on i686-apple-darwin
@ 2005-11-20 16:19 gcc at microbizz dot nl
  2005-11-20 21:17 ` [Bug target/24959] " gcc at microbizz dot nl
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: gcc at microbizz dot nl @ 2005-11-20 16:19 UTC (permalink / raw)
  To: gcc-bugs

The testsuite program gcc.c-torture/execute/nestfunc-3.c crashes with a bus
error on i686-apple-darwin8. Tried it with gcc-3.4.4, gcc-4.0.2 and
gcc-4.1-20051112.


-- 
           Summary: Trampolines fail on i686-apple-darwin
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gcc at microbizz dot nl
 GCC build triplet: i686-apple-darwin
  GCC host triplet: i686-apple-darwin
GCC target triplet: i686-apple-darwin


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24959


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug target/24959] Trampolines fail on i686-apple-darwin
  2005-11-20 16:19 [Bug target/24959] New: Trampolines fail on i686-apple-darwin gcc at microbizz dot nl
@ 2005-11-20 21:17 ` gcc at microbizz dot nl
  2005-11-21 19:28 ` gcc at microbizz dot nl
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: gcc at microbizz dot nl @ 2005-11-20 21:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from gcc at microbizz dot nl  2005-11-20 21:17 -------
Subject:  Trampolines fail on i686-apple-darwin

Note the gcc.c-torture/execute/nestfunc-5.c fails also (with a bus 
error).

Adriaan van Os


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24959


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug target/24959] Trampolines fail on i686-apple-darwin
  2005-11-20 16:19 [Bug target/24959] New: Trampolines fail on i686-apple-darwin 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
  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
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: gcc at microbizz dot nl @ 2005-11-21 19:28 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug target/24959] Trampolines fail on i686-apple-darwin because stack is not executable
  2005-11-20 16:19 [Bug target/24959] New: Trampolines fail on i686-apple-darwin 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
@ 2005-11-21 20:43 ` pinskia at gcc dot gnu dot org
  2005-11-21 20:49 ` pinskia at gcc dot gnu dot org
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-21 20:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2005-11-21 20:43 -------
I should note that in Apple's GCC for i686-darwin, they warn about this.  I
think they should look into fixing the issue here.  Anyways confirmed.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  GCC build triplet|i686-apple-darwin           |
   GCC host triplet|i686-apple-darwin           |
            Summary|Trampolines fail on i686-   |Trampolines fail on i686-
                   |apple-darwin                |apple-darwin because stack
                   |                            |is not executable


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24959


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug target/24959] Trampolines fail on i686-apple-darwin because stack is not executable
  2005-11-20 16:19 [Bug target/24959] New: Trampolines fail on i686-apple-darwin gcc at microbizz dot nl
                   ` (2 preceding siblings ...)
  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
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-21 20:49 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-11-21 20:49:38
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24959


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug target/24959] Trampolines fail on i686-apple-darwin because stack is not executable
  2005-11-20 16:19 [Bug target/24959] New: Trampolines fail on i686-apple-darwin gcc at microbizz dot nl
                   ` (3 preceding siblings ...)
  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
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: gcc at microbizz dot nl @ 2005-11-22  9:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from gcc at microbizz dot nl  2005-11-22 09:12 -------
Subject:  Trampolines fail on i686-apple-darwin because stack is not executable

Clarification - I forgot to mention that the code above (the 
ENABLE_EXECUTE_STACK macro) must be added to gcc/config/i386/darwin.h 
not to gcc/config/darwin.h. It  works also for gcc-3.4.4.

Adriaan van Os


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24959


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug target/24959] Trampolines fail on i686-apple-darwin because stack is not executable
  2005-11-20 16:19 [Bug target/24959] New: Trampolines fail on i686-apple-darwin gcc at microbizz dot nl
                   ` (4 preceding siblings ...)
  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
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-12  1:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pinskia at gcc dot gnu dot org  2006-01-12 01:56 -------
gcc.c-torture/execute/20000822-1.c fails the same way.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24959


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug target/24959] Trampolines fail on i686-apple-darwin because stack is not executable
  2005-11-20 16:19 [Bug target/24959] New: Trampolines fail on i686-apple-darwin gcc at microbizz dot nl
                   ` (5 preceding siblings ...)
  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
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-12  1:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2006-01-12 01:57 -------
I will submit this.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pinskia at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24959


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug target/24959] Trampolines fail on i686-apple-darwin because stack is not executable
  2005-11-20 16:19 [Bug target/24959] New: Trampolines fail on i686-apple-darwin gcc at microbizz dot nl
                   ` (6 preceding siblings ...)
  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
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: ssen at opendarwin dot org @ 2006-01-17 15:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from ssen at opendarwin dot org  2006-01-17 15:15 -------
I think this should be done for both PowerPC and x86 targets for Darwin. The
vendor compiler rejects nested functions for both targets presumably because of
this, and so trampolines should enable stack execution for both targets


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24959


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug target/24959] Trampolines fail on i686-apple-darwin because stack is not executable
  2005-11-20 16:19 [Bug target/24959] New: Trampolines fail on i686-apple-darwin gcc at microbizz dot nl
                   ` (7 preceding siblings ...)
  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
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: gcc at microbizz dot nl @ 2006-01-17 15:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from gcc at microbizz dot nl  2006-01-17 15:30 -------
Subject: Re:  Trampolines fail on i686-apple-darwin because
 stack is not executable

Currently it is not necessary for powerpc, but Apple may indeed change 
this in a future version of powerpc-darwin.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24959


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug target/24959] Trampolines fail on i686-apple-darwin because stack is not executable
  2005-11-20 16:19 [Bug target/24959] New: Trampolines fail on i686-apple-darwin gcc at microbizz dot nl
                   ` (8 preceding siblings ...)
  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
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-25 18:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from pinskia at gcc dot gnu dot org  2006-01-25 18:35 -------
(In reply to comment #8)
> Currently it is not necessary for powerpc, but Apple may indeed change 
> this in a future version of powerpc-darwin.
In a way it is already needed for powerpc-darwin.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24959


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug target/24959] Trampolines fail on i686-apple-darwin because stack is not executable
  2005-11-20 16:19 [Bug target/24959] New: Trampolines fail on i686-apple-darwin gcc at microbizz dot nl
                   ` (9 preceding siblings ...)
  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
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-02-20 23:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from pinskia at gcc dot gnu dot org  2006-02-20 23:53 -------
No longer working on this, too much troubles are causing to me to fix Darwin
bugs.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|pinskia at gcc dot gnu dot  |unassigned at gcc dot gnu
                   |org                         |dot org
             Status|ASSIGNED                    |NEW


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24959


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug target/24959] Trampolines fail on i686-apple-darwin because stack is not executable
  2005-11-20 16:19 [Bug target/24959] New: Trampolines fail on i686-apple-darwin gcc at microbizz dot nl
                   ` (10 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: echristo at apple dot com @ 2006-02-27  9:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from echristo at apple dot com  2006-02-27 08:35 -------
There are two ways to fix this, the easiest way is to pass -allow_stack_execute
through to the linker when we want an executable stack. This is problematic
since we'll not be specifying it on the command line. We can turn on an
allowable stack at all times, but this is less safe than turning it on only
when necessary. The other way is to use mprotect like the patch has below.


-- 

echristo at apple dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |echristo at apple dot com
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2005-11-21 20:49:38         |2006-02-27 08:35:11
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24959


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug target/24959] Trampolines fail on i686-apple-darwin because stack is not executable
  2005-11-20 16:19 [Bug target/24959] New: Trampolines fail on i686-apple-darwin gcc at microbizz dot nl
                   ` (11 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: gcc at microbizz dot nl @ 2006-02-27 12:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from gcc at microbizz dot nl  2006-02-27 12:03 -------
Subject: Re:  Trampolines fail on i686-apple-darwin because
 stack is not executable

I agree that calling mprotect is the best fix.

Adriaan van Os


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24959


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug target/24959] Trampolines fail on i686-apple-darwin because stack is not executable
  2005-11-20 16:19 [Bug target/24959] New: Trampolines fail on i686-apple-darwin gcc at microbizz dot nl
                   ` (12 preceding siblings ...)
  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
  15 siblings, 0 replies; 17+ messages in thread
From: echristo at apple dot com @ 2006-02-28  1:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from echristo at apple dot com  2006-02-28 01:48 -------
Patch in testing.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24959


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug target/24959] Trampolines fail on i686-apple-darwin because stack is not executable
  2005-11-20 16:19 [Bug target/24959] New: Trampolines fail on i686-apple-darwin gcc at microbizz dot nl
                   ` (13 preceding siblings ...)
  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
  15 siblings, 0 replies; 17+ messages in thread
From: echristo at apple dot com @ 2006-03-03 20:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #14 from echristo at apple dot com  2006-03-03 20:17 -------
Fixed.


-- 

echristo at apple dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24959


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [Bug target/24959] Trampolines fail on i686-apple-darwin because stack is not executable
  2005-11-20 16:19 [Bug target/24959] New: Trampolines fail on i686-apple-darwin gcc at microbizz dot nl
                   ` (14 preceding siblings ...)
  2006-03-03 20:18 ` echristo at apple dot com
@ 2007-01-10 19:27 ` pinskia at gcc dot gnu dot org
  15 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-01-10 19:27 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.2.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24959


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2007-01-10 19:27 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-20 16:19 [Bug target/24959] New: Trampolines fail on i686-apple-darwin 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
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

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).