unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#8395: Compile error with Xcode 4.1 in unexec
@ 2011-03-31 14:09 William R. Otte
  2011-07-05 14:45 ` bug#8395: ASLR Issue? Bob Halley
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: William R. Otte @ 2011-03-31 14:09 UTC (permalink / raw)
  To: 8395

[-- Attachment #1: Type: text/plain, Size: 4790 bytes --]

Hi - 

I've been trying to build emacs-23 branch from bzr using Xcode 4.1 (not, not 4.0.1) with either included compiler.  While the patch for  bug 8223 resolved one issue that I'm having, I subsequently encounter another error in unexec, found attached below. 

I'm happy to help debug this, as 4.1 may not be readily available to all involved - but will require some guidance from someone familiar with the code.

thanks,
/-Will
 

Dumping under the name emacs
--- List of All Regions ---
   address     size prot maxp
--- List of Regions to be Dumped ---
   address     size prot maxp
--- Header Information ---
Magic = 0xfeedfacf
CPUType = 16777223
CPUSubType = -2147483645
FileType = 0x2
NCmds = 50
SizeOfCmds = 4208
Flags = 0x00200085
Highest address of load commands in input file: 0x5dd000
Lowest offset of all sections in __TEXT segment:   0x20c0
--- List of Load Commands in Input File ---
# cmd              cmdsize name                address     size
0 LC_SEGMENT_64          72 __PAGEZERO                0 0x100000000
1 LC_SEGMENT_64         632 __TEXT           0x100000000 0x202000
                           __text           0x1000020c0 0x1b6c2c
                           __stubs          0x1001b8cec   0x1248
                           __stub_helper    0x1001b9f34   0x1e88
                           __cstring        0x1001bbdc0  0x172db
                           __const          0x1001d30a0    0x534
                           __unwind_info    0x1001d35d4   0x20f4
                           __eh_frame       0x1001d56c8  0x2c930
2 LC_SEGMENT_64         712 __DATA           0x100202000 0x311000
                           __program_vars   0x100202000     0x28
                           __got            0x100202028     0x70
                           __nl_symbol_ptr  0x100202098     0x10
                           __la_symbol_ptr  0x1002020a8   0x1860
                           __data           0x100203920 0x2a5ee8
                           __const          0x1004a9820   0x1ff0
                           __common         0x1004ab820  0x10ce1
                           __bss            0x1004bc520  0x563b8
3 LC_SEGMENT_64          72 __LINKEDIT       0x100513000  0xca000
4 LC_DYLD_INFO_ONLY      48
5 LC_SYMTAB              24
6 LC_DYSYMTAB            80
7 LC_LOAD_DYLINKER       32
8 LC_UUID                24
9 unknown                16
10 LC_UNIXTHREAD         184
11 LC_LOAD_DYLIB          64
12 LC_LOAD_DYLIB          64
13 LC_LOAD_DYLIB          64
14 LC_LOAD_DYLIB          72
15 LC_LOAD_DYLIB          56
16 LC_LOAD_DYLIB          56
17 LC_LOAD_DYLIB          64
18 LC_LOAD_DYLIB          56
19 LC_LOAD_DYLIB          56
20 LC_LOAD_DYLIB          56
21 LC_LOAD_DYLIB          64
22 LC_LOAD_DYLIB          56
23 LC_LOAD_DYLIB          72
24 LC_LOAD_DYLIB          64
25 LC_LOAD_DYLIB          64
26 LC_LOAD_DYLIB          56
27 LC_LOAD_DYLIB          56
28 LC_LOAD_DYLIB          56
29 LC_LOAD_DYLIB          64
30 LC_LOAD_DYLIB          64
31 LC_LOAD_DYLIB          56
32 LC_LOAD_DYLIB          64
33 LC_LOAD_DYLIB          64
34 LC_LOAD_DYLIB          64
35 LC_LOAD_DYLIB          64
36 LC_LOAD_DYLIB          64
37 LC_LOAD_DYLIB          64
38 LC_LOAD_DYLIB          56
39 LC_LOAD_DYLIB          56
40 LC_LOAD_DYLIB          56
41 LC_LOAD_DYLIB          56
42 LC_LOAD_DYLIB          56
43 LC_LOAD_DYLIB          56
44 LC_LOAD_DYLIB          56
45 LC_LOAD_DYLIB          56
46 LC_LOAD_DYLIB          56
47 LC_LOAD_DYLIB          64
48 LC_LOAD_DYLIB          64
49 unknown                16
0x7feafc1fc080 (sz:   0x3f2d/  0x3f30)
0x7feafc100000 (sz:  0xfc07f/ 0xfc080)
0x7feafaefc080 (sz:   0x3f2c/  0x3f30)
0x7feafae00000 (sz:  0xfc07f/ 0xfc080)
0x7feafc0fc080 (sz:   0x3f2c/  0x3f30)
0x7feafc000000 (sz:  0xfc080/ 0xfc080)
0x7feafadfc080 (sz:   0x3f2d/  0x3f30)
0x7feafad00000 (sz:  0xfc080/ 0xfc080)
0x7feafcff8000 (sz:   0x316c/  0x7fa8)
0x7feafc800000 (sz: 0x313ffe/0x7f8000)
0x7feafbff8000 (sz:   0x7f9f/  0x7fa8)
0x7feafb800000 (sz: 0x7f7fff/0x7f8000)
0x110803000 (sz:        0/  0x1000)
--- Load Commands written to Output File ---
Writing segment __PAGEZERO       @        0 (       0/0x100000000 @          0)
Writing segment __TEXT           @        0 (0x202000/0x202000 @ 0x100000000)
Writing segment __DATA           @ 0x202000 (0x311000/0x311000 @ 0x100202000)
        section __program_vars   at 0x202000 - 0x202028 (sz:     0x28)
        section __got            at 0x202028 - 0x202098 (sz:     0x70)
        section __nl_symbol_ptr  at 0x202098 - 0x2020a8 (sz:     0x10)
        section __la_symbol_ptr  at 0x2020a8 - 0x203908 (sz:   0x1860)
unexec: cannot write section __data
make[2]: *** [bootstrap-emacs] Error 1

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 2399 bytes --]

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

* bug#8395: ASLR Issue?
  2011-03-31 14:09 bug#8395: Compile error with Xcode 4.1 in unexec William R. Otte
@ 2011-07-05 14:45 ` Bob Halley
  2011-07-06  7:41   ` YAMAMOTO Mitsuharu
  2011-07-11 18:15 ` bug#8395: Title bar issue Bob Halley
  2011-07-11 23:25 ` bug#8395: (no subject) YAMAMOTO Mitsuharu
  2 siblings, 1 reply; 10+ messages in thread
From: Bob Halley @ 2011-07-05 14:45 UTC (permalink / raw)
  To: 8395

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.

As an aside, could emacs switch to an external core image like other lisps use instead of continuing to use the fragile unexec mechanism?

--- Load Commands written to Output File ---
Writing segment __PAGEZERO       @        0 (       0/0x100000000 @          0)
write 72
sz = 72
Writing segment __TEXT           @        0 (0x1ed000/0x1ed000 @ 0x100000000)
write 712
sz = 712
Writing segment __DATA           @ 0x1ed000 (0x458000/0x458000 @ 0x1001ed000)
write 80
sz = 80
        section __program_vars   at 0x1ed000 - 0x1ed028 (sz:     0x28)
write 80
sz = 80
        section __nl_symbol_ptr  at 0x1ed028 - 0x1ed038 (sz:     0x10)
write 80
sz = 80
        section __got            at 0x1ed038 - 0x1ed208 (sz:    0x1d0)
write 80
sz = 80
        section __la_symbol_ptr  at 0x1ed208 - 0x1eda90 (sz:    0x888)
write 80
sz = 80
        section __objc_classlist at 0x1eda90 - 0x1edb00 (sz:     0x70)
write 80
sz = 80
        section __objc_protolist at 0x1edb00 - 0x1edb10 (sz:     0x10)
write 80
sz = 80
        section __objc_imageinfo at 0x1edb10 - 0x1edb18 (sz:      0x8)
write 80
sz = 80
        section __objc_const     at 0x1edb18 - 0x1efef8 (sz:   0x23e0)
write 80
sz = 80
        section __objc_selrefs   at 0x1efef8 - 0x1f1030 (sz:   0x1138)
write 80
sz = 80
        section __objc_msgrefs   at 0x1f1030 - 0x1f1120 (sz:     0xf0)
write 80
sz = 80
        section __objc_classrefs at 0x1f1120 - 0x1f1338 (sz:    0x218)
write 80
sz = 80
        section __objc_superrefs at 0x1f1338 - 0x1f13a0 (sz:     0x68)
write 80
sz = 80
        section __objc_data      at 0x1f13a0 - 0x1f1800 (sz:    0x460)
sectp->addr = 1001f1800
write 4019480
sz = -1
errno = 14 Bad address
unexec: cannot write 1 section __data






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

* bug#8395: ASLR Issue?
  2011-07-05 14:45 ` bug#8395: ASLR Issue? Bob Halley
@ 2011-07-06  7:41   ` YAMAMOTO Mitsuharu
       [not found]     ` <DCE21D64-0878-48EB-88F2-0BD981E9BFE1@play-bow.org>
  0 siblings, 1 reply; 10+ messages in thread
From: YAMAMOTO Mitsuharu @ 2011-07-06  7:41 UTC (permalink / raw)
  To: Bob Halley; +Cc: 8395, William R. Otte

>>>>> On Tue, 5 Jul 2011 15:45:49 +0100, Bob Halley <halley@play-bow.org> 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
				mituharu@math.s.chiba-u.ac.jp

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
  






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

* bug#8395: ASLR Issue?
       [not found]     ` <DCE21D64-0878-48EB-88F2-0BD981E9BFE1@play-bow.org>
@ 2011-07-07 22:57       ` YAMAMOTO Mitsuharu
  2011-07-10 15:19         ` Bob Halley
  0 siblings, 1 reply; 10+ messages in thread
From: YAMAMOTO Mitsuharu @ 2011-07-07 22:57 UTC (permalink / raw)
  To: Bob Halley; +Cc: 8395, William R. Otte

(Please keep the bugtracker address)

>>>>> On Thu, 7 Jul 2011 06:17:52 -0700, Bob Halley <halley@play-bow.org> said:

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

> The patch allows temacs to link and the emacs (and aquamacs) build
> process succeeds.  The application, however, doesn't work correctly.
> It starts up but the windows it puts up have no title bar, and don't
> seem to display content either.  E.g. you can do C-x C-f, enter a
> filename, and it seems to succeed but you can't see anything.

This may or may not be a separate issue.  Could you show the result of
`$ otool -h src/temacs src/emacs' at the build tree?  Also, please try
X11 or tty-only builds if possible.

				     YAMAMOTO Mitsuharu
				mituharu@math.s.chiba-u.ac.jp





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

* bug#8395: ASLR Issue?
  2011-07-07 22:57       ` YAMAMOTO Mitsuharu
@ 2011-07-10 15:19         ` Bob Halley
  2011-07-11  0:13           ` YAMAMOTO Mitsuharu
  0 siblings, 1 reply; 10+ messages in thread
From: Bob Halley @ 2011-07-10 15:19 UTC (permalink / raw)
  To: 8395

	
On 7 Jul 2011, at 15:57, YAMAMOTO Mitsuharu wrote:

> This may or may not be a separate issue.  Could you show the result of
> `$ otool -h src/temacs src/emacs' at the build tree?

src/temacs:
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
 0xfeedfacf 16777223          3  0x80          2    23       3696 0x00000085
src/emacs:
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
 0xfeedfacf 16777223          3  0x80          2    31       4272 0x00000085


I've done a few tests which suggest the problems with the missing title bar etc. that I reported are a separate issue.  I did a build targeted to 10.6 instead of 10.7 after removing the -fno-pie, and I had no problems unexecing, but the title bar was still gone.

I also tried running src/emacs directly (a 10.7 build with -fno-pie).   It printed this to the console:

2011-07-10 08:04:33.093 emacs[61589:707] ERROR: Can't have a toolbar in a window with <NSNextStepFrame: 0x100e40830> as it's borderview

>  Also, please try
> X11 or tty-only builds if possible.

I'll try that later; I'll have to pull plain emacs 24 code as this doesn't seem to work with the Aquamacs code base.






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

* bug#8395: ASLR Issue?
  2011-07-10 15:19         ` Bob Halley
@ 2011-07-11  0:13           ` YAMAMOTO Mitsuharu
  2011-07-11 14:11             ` Bob Halley
  0 siblings, 1 reply; 10+ messages in thread
From: YAMAMOTO Mitsuharu @ 2011-07-11  0:13 UTC (permalink / raw)
  To: Bob Halley; +Cc: 8395

>>>>> On Sun, 10 Jul 2011 08:19:47 -0700, Bob Halley <halley@play-bow.org> said:

> On 7 Jul 2011, at 15:57, YAMAMOTO Mitsuharu wrote:

>> This may or may not be a separate issue.  Could you show the result of
>> `$ otool -h src/temacs src/emacs' at the build tree?

> src/temacs:
> Mach header
>       magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
>  0xfeedfacf 16777223          3  0x80          2    23       3696 0x00000085
> src/emacs:
> Mach header
>       magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
>  0xfeedfacf 16777223          3  0x80          2    31       4272 0x00000085

Thanks.  As MH_PIE (0x200000) is not set in flags, the -fno-pie option
seems to work as intended (i.e., to suppress address randomization).

>> Also, please try X11 or tty-only builds if possible.

> I'll try that later; I'll have to pull plain emacs 24 code as this
> doesn't seem to work with the Aquamacs code base.

Thanks again.  If the change I posted turns out to work with X11 or
tty-only builds, I'll commit it.  Of course, if Lion is released
early, I'll try those builds myself.

				     YAMAMOTO Mitsuharu
				mituharu@math.s.chiba-u.ac.jp





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

* bug#8395: ASLR Issue?
  2011-07-11  0:13           ` YAMAMOTO Mitsuharu
@ 2011-07-11 14:11             ` Bob Halley
  2011-07-11 23:22               ` YAMAMOTO Mitsuharu
  0 siblings, 1 reply; 10+ messages in thread
From: Bob Halley @ 2011-07-11 14:11 UTC (permalink / raw)
  To: YAMAMOTO Mitsuharu; +Cc: 8395


On 10 Jul 2011, at 17:13, YAMAMOTO Mitsuharu wrote:

> 
> Thanks again.  If the change I posted turns out to work with X11 or
> tty-only builds, I'll commit it.  Of course, if Lion is released
> early, I'll try those builds myself.

I downloaded the Emacs 23.3 tarball, and added the __got fix to unexmacosx.c.

I then built and verified that without your patch the build fails.

I then applied your patch to src/s/darwin.h.

I did 3 builds starting from a "make distclean" state: a tty-only build, an X11 build, and a cocoa build.  I verified with otool that the PIE attribute was not present on any of the emacs executables.

The build worked fine both as a tty-only build and as an X11 build.  The cocoa build runs, but the window it makes has no title bar and is badly positioned (the top line or so is cut off by the menu bar).

/Bob






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

* bug#8395: Title bar issue
  2011-03-31 14:09 bug#8395: Compile error with Xcode 4.1 in unexec William R. Otte
  2011-07-05 14:45 ` bug#8395: ASLR Issue? Bob Halley
@ 2011-07-11 18:15 ` Bob Halley
  2011-07-11 23:25 ` bug#8395: (no subject) YAMAMOTO Mitsuharu
  2 siblings, 0 replies; 10+ messages in thread
From: Bob Halley @ 2011-07-11 18:15 UTC (permalink / raw)
  To: 8395

The title bar problem is definitely a separate issue.  David Reitter will be committing a fix I've made and tested for that issue.




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

* bug#8395: ASLR Issue?
  2011-07-11 14:11             ` Bob Halley
@ 2011-07-11 23:22               ` YAMAMOTO Mitsuharu
  0 siblings, 0 replies; 10+ messages in thread
From: YAMAMOTO Mitsuharu @ 2011-07-11 23:22 UTC (permalink / raw)
  To: Bob Halley; +Cc: 8395

>>>>> On Mon, 11 Jul 2011 07:11:59 -0700, Bob Halley <halley@play-bow.org> said:

> I downloaded the Emacs 23.3 tarball, and added the __got fix to
> unexmacosx.c.

> I then built and verified that without your patch the build fails.

> I then applied your patch to src/s/darwin.h.

> I did 3 builds starting from a "make distclean" state: a tty-only
> build, an X11 build, and a cocoa build.  I verified with otool that
> the PIE attribute was not present on any of the emacs executables.

> The build worked fine both as a tty-only build and as an X11 build.
> The cocoa build runs, but the window it makes has no title bar and
> is badly positioned (the top line or so is cut off by the menu bar).

Thanks for the detailed report.  I've just committed the patch to
trunk and the emacs-23 branch.

				     YAMAMOTO Mitsuharu
				mituharu@math.s.chiba-u.ac.jp





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

* bug#8395: (no subject)
  2011-03-31 14:09 bug#8395: Compile error with Xcode 4.1 in unexec William R. Otte
  2011-07-05 14:45 ` bug#8395: ASLR Issue? Bob Halley
  2011-07-11 18:15 ` bug#8395: Title bar issue Bob Halley
@ 2011-07-11 23:25 ` YAMAMOTO Mitsuharu
  2 siblings, 0 replies; 10+ messages in thread
From: YAMAMOTO Mitsuharu @ 2011-07-11 23:25 UTC (permalink / raw)
  To: 8395-done

Closed with the following changes:

For trunk:

2011-07-11  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>

	* configure.in (LD_SWITCH_SYSTEM_TEMACS): Add -fno-pie on Darwin
	so as to suppress address randomization (Bug#8395).

For emacs-23 branch:

2011-07-11  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>

	* s/darwin.h (LD_SWITCH_SYSTEM_TEMACS): Add -fno-pie so as to suppress
	address randomization (Bug#8395).





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

end of thread, other threads:[~2011-07-11 23:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-31 14:09 bug#8395: Compile error with Xcode 4.1 in unexec William R. Otte
2011-07-05 14:45 ` bug#8395: ASLR Issue? Bob Halley
2011-07-06  7:41   ` YAMAMOTO Mitsuharu
     [not found]     ` <DCE21D64-0878-48EB-88F2-0BD981E9BFE1@play-bow.org>
2011-07-07 22:57       ` YAMAMOTO Mitsuharu
2011-07-10 15:19         ` Bob Halley
2011-07-11  0:13           ` YAMAMOTO Mitsuharu
2011-07-11 14:11             ` Bob Halley
2011-07-11 23:22               ` YAMAMOTO Mitsuharu
2011-07-11 18:15 ` bug#8395: Title bar issue Bob Halley
2011-07-11 23:25 ` bug#8395: (no subject) YAMAMOTO Mitsuharu

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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