Subject: bug#8395: ASLR Issue?

From: YAMAMOTO Mitsuharu <[email-masked]>
Date: Wed, 06 Jul 2011 16:41:48 +0900

>>>>> On Tue, 5 Jul 2011 15:45:49 +0100, Bob Halley <[email-masked]> said:

> I too see this problem trying to build Aquamacs' emacs-24-based
> branch on Lion GM with Xcode 4.1 preview 7.  The problem is *not* an
> unknown section name.  I added some debugging printfs, and this is
> what I see.  Basically things seem to be going OK until we try to
> write __data, where we get EFAULT when we try to write() it.  I
> don't know why sectp->addr is giving EFAULT; perhaps ASLR?  If I
> discover more, I will add to the ticket.

Could you try the patch below?  (I can't test it myself.)

As far as I tested, gcc -fno-pie *.o does not give an error on older
versions (though gcc -fno-pie *.c does in cc1).  So we can go without
additional configure-time checks if this modification works on Xcode
4.1 and/or Lion.

				     YAMAMOTO Mitsuharu
				[email-masked]

For trunk:
=== modified file 'configure.in'
*** configure.in	2011-07-05 08:21:38 +0000
--- configure.in	2011-07-06 06:13:33 +0000
***************
*** 3349,3355 ****
       libs_nsgui=
       headerpad_extra=690
     fi
!    LD_SWITCH_SYSTEM_TEMACS="-prebind $libs_nsgui -Xlinker -headerpad -Xlinker $headerpad_extra"
  
     ## This is here because src/Makefile.in did some extra fiddling around
     ## with LD_SWITCH_SYSTEM.  The cpp logic was:
--- 3349,3355 ----
       libs_nsgui=
       headerpad_extra=690
     fi
!    LD_SWITCH_SYSTEM_TEMACS="-fno-pie -prebind $libs_nsgui -Xlinker -headerpad -Xlinker $headerpad_extra"
  
     ## This is here because src/Makefile.in did some extra fiddling around
     ## with LD_SWITCH_SYSTEM.  The cpp logic was:

For emacs-23 branch:
=== modified file 'src/s/darwin.h'
*** src/s/darwin.h	2011-01-02 23:50:46 +0000
--- src/s/darwin.h	2011-07-06 06:07:50 +0000
***************
*** 181,187 ****
     end of the header for adding load commands.  Needed for dumping.
     0x690 is the total size of 30 segment load commands (at 56
     each); under Cocoa 31 commands are required.  */
! #define LD_SWITCH_SYSTEM_TEMACS -prebind LIBS_NSGUI -Xlinker -headerpad -Xlinker HEADERPAD_EXTRA
  
  #define C_SWITCH_SYSTEM_TEMACS -Dtemacs
  
--- 181,187 ----
     end of the header for adding load commands.  Needed for dumping.
     0x690 is the total size of 30 segment load commands (at 56
     each); under Cocoa 31 commands are required.  */
! #define LD_SWITCH_SYSTEM_TEMACS -fno-pie -prebind LIBS_NSGUI -Xlinker -headerpad -Xlinker HEADERPAD_EXTRA
  
  #define C_SWITCH_SYSTEM_TEMACS -Dtemacs