GNU bug report logs - #2507
23.0.91; Stripping emacs.exe on MS-Windows produces an invalid program

Previous Next

Package: emacs;

Reported by: Eli Zaretskii <eliz <at> gnu.org>

Date: Sat, 28 Feb 2009 11:05:07 UTC

Severity: minor

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 2507 in the body.
You can then email your comments to 2507 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#2507; Package emacs. (Sat, 28 Feb 2009 11:05:07 GMT) Full text and rfc822 format available.

Acknowledgement sent to Eli Zaretskii <eliz <at> gnu.org>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Sat, 28 Feb 2009 11:05:07 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: emacs-pretest-bug <at> gnu.org
Subject: 23.0.91; Stripping emacs.exe on MS-Windows produces an invalid program
Date: Sat, 28 Feb 2009 13:01:07 +0200
Please write in English if possible, because the Emacs maintainers
usually do not have translators to read other languages for them.

Your bug report will be posted to the emacs-pretest-bug <at> gnu.org mailing list.

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

  strip emacs.exe
  emacs -Q

results in the OS popping an error dialog saying:

  emacs.exe is not a valid Win32 application

If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
If you would like to further debug the crash, please read the file
d:/gnu/emacs/etc/DEBUG for instructions.


In GNU Emacs 23.0.91.1 (i386-mingw-nt5.1.2600)
 of 2009-02-28 on HOME-C4E4A596F7
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4)'

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: ENU
  value of $XMODIFIERS: nil
  locale-coding-system: cp1255
  default-enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  tool-bar-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
M-x r e p o r t - e m a c s - b u <tab> <return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#2507; Package emacs. (Sat, 28 Feb 2009 12:20:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Eli Zaretskii <eliz <at> gnu.org>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Sat, 28 Feb 2009 12:20:03 GMT) Full text and rfc822 format available.

Message #10 received at 2507 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: 2507 <at> debbugs.gnu.org
Subject: Re: bug#2507: 23.0.91;	Stripping emacs.exe on MS-Windows produces an invalid program
Date: Sat, 28 Feb 2009 14:14:16 +0200
> Date: Sat, 28 Feb 2009 13:01:07 +0200
> From: Eli Zaretskii <eliz <at> gnu.org>
> Cc: 
> 
>   strip emacs.exe
>   emacs -Q
> 
> results in the OS popping an error dialog saying:
> 
>   emacs.exe is not a valid Win32 application

More info: building Emacs like this:

    make USER_LDFLAGS=-s install

produces an already stripped emacs.exe that is 8548352 bytes large.
So this should serve as a stop-gap in case we cannot easily find a
cure for running `strip' on the dumped Emacs.

One further idea to ponder is that the fact we now compile with
DWARF-2 debug info is the reason for the problem with stripping the
dumped Emacs.  Can someone please try rebuilding with "-gstabs"
instead of "-gdwarf-2 -g3", and see if that produces an emacs.exe
which can be safely stripped?




bug reassigned from package `emacs' to `emacs,w32'. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> emacsbugs.donarmstrong.com. (Sun, 01 Mar 2009 01:00:05 GMT) Full text and rfc822 format available.

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#2507; Package emacs,w32. (Sun, 01 Mar 2009 06:10:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Harald Maier <harald <at> maierh.de>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com. (Sun, 01 Mar 2009 06:10:03 GMT) Full text and rfc822 format available.

Message #17 received at 2507 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Harald Maier <harald <at> maierh.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 2507 <at> debbugs.gnu.org
Subject: Re: bug#2507: 23.0.91; Stripping emacs.exe on MS-Windows produces an invalid program
Date: Sun, 01 Mar 2009 07:01:27 +0100
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Date: Sat, 28 Feb 2009 13:01:07 +0200
>> From: Eli Zaretskii <eliz <at> gnu.org>
>> Cc: 
>> 
>>   strip emacs.exe
>>   emacs -Q
>> 
>> results in the OS popping an error dialog saying:
>> 
>>   emacs.exe is not a valid Win32 application
>
> More info: building Emacs like this:
>
>     make USER_LDFLAGS=-s install
>
> produces an already stripped emacs.exe that is 8548352 bytes large.
> So this should serve as a stop-gap in case we cannot easily find a
> cure for running `strip' on the dumped Emacs.
>
> One further idea to ponder is that the fact we now compile with
> DWARF-2 debug info is the reason for the problem with stripping the
> dumped Emacs.  Can someone please try rebuilding with "-gstabs"
> instead of "-gdwarf-2 -g3", and see if that produces an emacs.exe
> which can be safely stripped?

I tried the "-gstabs" debug info, but after stripping it didn't work
too. But the output size of that compilation and linking is far smaller.

Result: 12.55 MB (-gstabs) instead of 31.33 MB (-gdwarf2 -g3).

Harald




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#2507; Package emacs,w32. (Sun, 01 Mar 2009 17:25:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Eli Zaretskii <eliz <at> gnu.org>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com. (Sun, 01 Mar 2009 17:25:05 GMT) Full text and rfc822 format available.

Message #22 received at 2507 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Harald Maier <harald <at> maierh.de>
Cc: 2507 <at> debbugs.gnu.org
Subject: Re: bug#2507: 23.0.91; Stripping emacs.exe on MS-Windows produces an invalid program
Date: Sun, 01 Mar 2009 19:15:24 +0200
> From: Harald Maier <harald <at> maierh.de>
> Cc: 2507 <at> emacsbugs.donarmstrong.com
> Date: Sun, 01 Mar 2009 07:01:27 +0100
> 
> > One further idea to ponder is that the fact we now compile with
> > DWARF-2 debug info is the reason for the problem with stripping the
> > dumped Emacs.  Can someone please try rebuilding with "-gstabs"
> > instead of "-gdwarf-2 -g3", and see if that produces an emacs.exe
> > which can be safely stripped?
> 
> I tried the "-gstabs" debug info, but after stripping it didn't work
> too.

Thanks for trying.

> But the output size of that compilation and linking is far smaller.
> 
> Result: 12.55 MB (-gstabs) instead of 31.33 MB (-gdwarf2 -g3).

This is expected: DWARF-2 produces much more voluminous debug
information (and thus enables several useful debugging features in
GDB).

Btw, the 32MB executable is only that large on disk; when you invoke
it, the debug info is not read at all, so the memory footprint of a
running Emacs is not affected.  The debug info is read only by GDB
when you run Emacs under the debugger.

(I'm not saying that we should ignore this problem, just that it only
matters for disk space and the size of the tarball.)




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#2507; Package emacs,w32. (Mon, 02 Mar 2009 12:05:08 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juanma Barranquero <lekktu <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com. (Mon, 02 Mar 2009 12:05:08 GMT) Full text and rfc822 format available.

Message #27 received at 2507 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>, 2507 <at> debbugs.gnu.org
Subject: Re: bug#2507: 23.0.91; Stripping emacs.exe on MS-Windows produces an 
	invalid program
Date: Mon, 2 Mar 2009 12:55:14 +0100
On Sat, Feb 28, 2009 at 13:14, Eli Zaretskii <eliz <at> gnu.org> wrote:

> a cure for running `strip' on the dumped Emacs.

AFAICS, the problem is not limited to the dumped Emacs. A stripped
temacs.exe fails in the same way.

    Juanma




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com:
bug#2507; Package emacs,w32. (Mon, 02 Mar 2009 19:15:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Eli Zaretskii <eliz <at> gnu.org>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>, owner <at> emacsbugs.donarmstrong.com. (Mon, 02 Mar 2009 19:15:03 GMT) Full text and rfc822 format available.

Message #32 received at 2507 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juanma Barranquero <lekktu <at> gmail.com>
Cc: 2507 <at> debbugs.gnu.org
Subject: Re: bug#2507: 23.0.91; Stripping emacs.exe on MS-Windows produces an	invalid program
Date: Mon, 02 Mar 2009 21:05:57 +0200
> Date: Mon, 2 Mar 2009 12:55:14 +0100
> From: Juanma Barranquero <lekktu <at> gmail.com>
> 
> On Sat, Feb 28, 2009 at 13:14, Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
> > a cure for running `strip' on the dumped Emacs.
> 
> AFAICS, the problem is not limited to the dumped Emacs. A stripped
> temacs.exe fails in the same way.

Probably because temacs.exe is a product of dumping temacs.bin.  See
src/makefile.w32-in.  Here's the relevant fragment from a typical
build session:

  "../nt/oo-spd/i386/addsection" "oo-spd/i386/temacs.bin" "oo-spd/i386/temacs.exe" EMHEAP 16
  Dumping from oo-spd/i386/temacs.bin
            to oo-spd/i386/temacs.exe





Severity set to 'minor' from 'normal' Request was from Chong Yidong <cyd <at> stupidchicken.com> to control <at> debbugs.gnu.org. (Thu, 24 Jun 2010 18:24:04 GMT) Full text and rfc822 format available.

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#2507; Package emacs,w32. (Mon, 11 Jul 2011 13:59:03 GMT) Full text and rfc822 format available.

Message #37 received at 2507 <at> debbugs.gnu.org (full text, mbox):

From: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 2507 <at> debbugs.gnu.org
Subject: Re: 23.0.91;
	Stripping emacs.exe on MS-Windows produces an invalid program
Date: Mon, 11 Jul 2011 15:53:45 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

> Please describe exactly what actions triggered the bug
> and the precise symptoms of the bug:
>
>   strip emacs.exe
>   emacs -Q
>
> results in the OS popping an error dialog saying:
>
>   emacs.exe is not a valid Win32 application

Presumably Emacs doesn't strip itself, otherwise it wouldn't work at all
on Windows, which it apparently does.  :-)

So it this still a problem?

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#2507; Package emacs,w32. (Mon, 11 Jul 2011 14:14:02 GMT) Full text and rfc822 format available.

Message #40 received at 2507 <at> debbugs.gnu.org (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 2507 <at> debbugs.gnu.org
Subject: Re: bug#2507: 23.0.91; Stripping emacs.exe on MS-Windows produces an
	invalid program
Date: Mon, 11 Jul 2011 16:12:20 +0200
On Mon, Jul 11, 2011 at 15:53, Lars Magne Ingebrigtsen <larsi <at> gnus.org> wrote:

> So it this still a problem?

It still happens, yes.

    Juanma




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#2507; Package emacs,w32. (Mon, 11 Jul 2011 16:02:02 GMT) Full text and rfc822 format available.

Message #43 received at 2507 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
Cc: 2507 <at> debbugs.gnu.org
Subject: Re: 23.0.91;
	Stripping emacs.exe on MS-Windows produces an invalid program
Date: Mon, 11 Jul 2011 19:03:20 +0300
> From: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
> Cc: 2507 <at> debbugs.gnu.org
> Date: Mon, 11 Jul 2011 15:53:45 +0200
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > Please describe exactly what actions triggered the bug
> > and the precise symptoms of the bug:
> >
> >   strip emacs.exe
> >   emacs -Q
> >
> > results in the OS popping an error dialog saying:
> >
> >   emacs.exe is not a valid Win32 application
> 
> Presumably Emacs doesn't strip itself, otherwise it wouldn't work at all
> on Windows, which it apparently does.  :-)

The default link command produces an unstripped binary, as on other
supported platforms.

> So it this still a problem?

Yes, of course.  No one did anything about this problem, AFAIK.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#2507; Package emacs,w32. (Mon, 11 Jul 2011 16:11:02 GMT) Full text and rfc822 format available.

Message #46 received at 2507 <at> debbugs.gnu.org (full text, mbox):

From: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 2507 <at> debbugs.gnu.org
Subject: Re: 23.0.91;
	Stripping emacs.exe on MS-Windows produces an invalid program
Date: Mon, 11 Jul 2011 18:09:41 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

> Yes, of course.  No one did anything about this problem, AFAIK.

Is it something that should be done anything about, though?  Is
stripping the binary something that you'd want to do?

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#2507; Package emacs,w32. (Mon, 11 Jul 2011 16:21:01 GMT) Full text and rfc822 format available.

Message #49 received at 2507 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
Cc: 2507 <at> debbugs.gnu.org
Subject: Re: 23.0.91;
	Stripping emacs.exe on MS-Windows produces an invalid program
Date: Mon, 11 Jul 2011 19:22:44 +0300
> From: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
> Cc: 2507 <at> debbugs.gnu.org
> Date: Mon, 11 Jul 2011 18:09:41 +0200
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > Yes, of course.  No one did anything about this problem, AFAIK.
> 
> Is it something that should be done anything about, though?

Yes.

> Is stripping the binary something that you'd want to do?

Yes.  For shipping a an official release's binaries, for example.  Or
for taking Emacs on a small mobile device.  The unstripped binary
measures 37MB on Windows, most of which is DWARF2 debug info.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#2507; Package emacs,w32. (Mon, 11 Jul 2011 19:37:02 GMT) Full text and rfc822 format available.

Message #52 received at 2507 <at> debbugs.gnu.org (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Lars Magne Ingebrigtsen <larsi <at> gnus.org>, 2507 <at> debbugs.gnu.org
Subject: Re: bug#2507: 23.0.91; Stripping emacs.exe on MS-Windows produces an
	invalid program
Date: Mon, 11 Jul 2011 21:36:09 +0200
On Mon, Jul 11, 2011 at 18:22, Eli Zaretskii <eliz <at> gnu.org> wrote:

> The unstripped binary
> measures 37MB on Windows

Or more. Mine is at ~42 MiB unstripped, ~10 MiB stripped (but I
doesn't work, of course).

    Juanma




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#2507; Package emacs,w32. (Tue, 12 Jul 2011 04:57:01 GMT) Full text and rfc822 format available.

Message #55 received at 2507 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juanma Barranquero <lekktu <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Lars Magne Ingebrigtsen <larsi <at> gnus.org>,
	2507 <at> debbugs.gnu.org
Subject: Re: bug#2507: 23.0.91;
	Stripping emacs.exe on MS-Windows produces an invalid program
Date: Tue, 12 Jul 2011 00:56:27 -0400
>> The unstripped binary measures 37MB on Windows
> Or more. Mine is at ~42 MiB unstripped, ~10 MiB stripped (but I
> doesn't work, of course).

So the stripped version can be compressed *much* further without losing
any functionality.  Cool!


        Stefan "feeling silly"




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#2507; Package emacs,w32. (Tue, 12 Jul 2011 11:05:02 GMT) Full text and rfc822 format available.

Message #58 received at 2507 <at> debbugs.gnu.org (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Lars Magne Ingebrigtsen <larsi <at> gnus.org>,
	2507 <at> debbugs.gnu.org
Subject: Re: bug#2507: 23.0.91; Stripping emacs.exe on MS-Windows produces an
	invalid program
Date: Tue, 12 Jul 2011 13:03:19 +0200
On Tue, Jul 12, 2011 at 06:56, Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:

> So the stripped version can be compressed *much* further without losing
> any functionality.  Cool!

Well, yeah. A lot.

>        Stefan "feeling silly"

As we Spaniards use to say: "Ja, ja, me parto".

    Juanma




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#2507; Package emacs,w32. (Wed, 13 Jul 2011 14:17:01 GMT) Full text and rfc822 format available.

Message #61 received at 2507 <at> debbugs.gnu.org (full text, mbox):

From: Jason Rumney <jasonr <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Juanma Barranquero <lekktu <at> gmail.com>,
	Lars Magne Ingebrigtsen <larsi <at> gnus.org>, 2507 <at> debbugs.gnu.org
Subject: Re: bug#2507: 23.0.91;
	Stripping emacs.exe on MS-Windows produces an invalid program
Date: Wed, 13 Jul 2011 22:16:36 +0800
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>>> The unstripped binary measures 37MB on Windows
>> Or more. Mine is at ~42 MiB unstripped, ~10 MiB stripped (but I
>> doesn't work, of course).
>
> So the stripped version can be compressed *much* further without losing
> any functionality.  Cool!

If you build without debug info in the first place, it does work, at
around the same size. Also if you strip temacs before dumping, it
works. The problem is only in stripping a dumped binary that had
debug info to start with. It seems the strip command removes some info
that Emacs needs to reconstruct the heap from the dumped image.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#2507; Package emacs,w32. (Sun, 07 Apr 2013 16:49:02 GMT) Full text and rfc822 format available.

Message #64 received at 2507 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Jason Rumney <jasonr <at> gnu.org>
Cc: lekktu <at> gmail.com, larsi <at> gnus.org, monnier <at> iro.umontreal.ca,
	2507 <at> debbugs.gnu.org
Subject: Re: bug#2507: 23.0.91;
	Stripping emacs.exe on MS-Windows produces an invalid program
Date: Sun, 07 Apr 2013 19:44:28 +0300
> From: Jason Rumney <jasonr <at> gnu.org>
> Date: Wed, 13 Jul 2011 22:16:36 +0800
> Cc: Juanma Barranquero <lekktu <at> gmail.com>,
> 	Lars Magne Ingebrigtsen <larsi <at> gnus.org>, 2507 <at> debbugs.gnu.org
> 
> If you build without debug info in the first place, it does work, at
> around the same size. Also if you strip temacs before dumping, it
> works. The problem is only in stripping a dumped binary that had
> debug info to start with. It seems the strip command removes some info
> that Emacs needs to reconstruct the heap from the dumped image.

That is correct.

I looked into this some more.  The problem is that we add an extra
section to the Emacs executable (by running addsection), which serves
as the static heap.  Here's the report from "objdump -h":

  temacs.exe:     file format pei-i386

  Sections:
  Idx Name          Size      VMA       LMA       File off  Algn
    0 .text         0032e604  01001000  01001000  00001000  2**4
		    CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
    1 .data         0020aea0  01330000  01330000  00330000  2**4
		    CONTENTS, ALLOC, LOAD, DATA
    2 .rdata        000dc57c  0153b000  0153b000  0053b000  2**4
		    CONTENTS, ALLOC, LOAD, READONLY, DATA
    3 .bss          0005c410  01618000  01618000  00000000  2**4
		    ALLOC
    4 .idata        000036f4  01675000  01675000  00618000  2**2
		    CONTENTS, ALLOC, LOAD, DATA
    5 .rsrc         0000d5f0  01679000  01679000  0061c000  2**2
		    CONTENTS, ALLOC, LOAD, DATA
    6 .debug_aranges 00000ce0  01687000  01687000  0062a000  2**0
		    CONTENTS, READONLY, DEBUGGING
    7 .debug_pubnames 00011b5a  01688000  01688000  0062b000  2**0
		    CONTENTS, READONLY, DEBUGGING
    8 .debug_info   003992b0  0169a000  0169a000  0063d000  2**0
		    CONTENTS, READONLY, DEBUGGING
    9 .debug_abbrev 0001181b  01a34000  01a34000  009d7000  2**0
		    CONTENTS, READONLY, DEBUGGING
   10 .debug_line   0003f37e  01a46000  01a46000  009e9000  2**0
		    CONTENTS, READONLY, DEBUGGING
   11 .debug_frame  0001b6b8  01a86000  01a86000  00a29000  2**0
		    CONTENTS, READONLY, DEBUGGING
   12 .debug_str    0000d3bb  01aa2000  01aa2000  00a45000  2**0
		    CONTENTS, READONLY, DEBUGGING
   13 .debug_macinfo 01b54308  01ab0000  01ab0000  00a53000  2**0
		    CONTENTS, READONLY, DEBUGGING
   14 EMHEAP        01b00000  03605000  03605000  00000000  2**2
		    ALLOC

The last section, EMHEAP, is the one we add.  Now look what happens
after stripping:

  temacs.exe:     file format pei-i386

  Sections:
  Idx Name          Size      VMA       LMA       File off  Algn
    0 .text         0032e604  01001000  01001000  00000400  2**4
		    CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
    1 .data         0020aea0  01330000  01330000  0032ec00  2**4
		    CONTENTS, ALLOC, LOAD, DATA
    2 .rdata        000dc57c  0153b000  0153b000  00539c00  2**4
		    CONTENTS, ALLOC, LOAD, READONLY, DATA
    3 .bss          0005c410  01618000  01618000  00000000  2**4
		    ALLOC
    4 .idata        000036f4  01675000  01675000  00616200  2**2
		    CONTENTS, ALLOC, LOAD, DATA
    5 .rsrc         0000d5f0  01679000  01679000  00619a00  2**2
		    CONTENTS, ALLOC, LOAD, DATA
    6 EMHEAP        01b00000  03605000  03605000  00000000  2**2
		    ALLOC

The debug sections are gone, but the VMA and LMA of EMHEAP were left
intact.  By contrast, if we strip temacs.bin _before_ running
addsection, and run addsection on the stripped temacs.bin, we get
this:

  temacs.exe:     file format pei-i386

  Sections:
  Idx Name          Size      VMA       LMA       File off  Algn
    0 .text         0032e604  01001000  01001000  00001000  2**4
		    CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
    1 .data         0020aea0  01330000  01330000  00330000  2**4
		    CONTENTS, ALLOC, LOAD, DATA
    2 .rdata        000dc57c  0153b000  0153b000  0053b000  2**4
		    CONTENTS, ALLOC, LOAD, READONLY, DATA
    3 .bss          0005c410  01618000  01618000  00000000  2**4
		    ALLOC
    4 .idata        000036f4  01675000  01675000  00618000  2**2
		    CONTENTS, ALLOC, LOAD, DATA
    5 .rsrc         0000d5f0  01679000  01679000  0061c000  2**2
		    CONTENTS, ALLOC, LOAD, DATA
    6 EMHEAP        01b00000  01687000  01687000  00000000  2**2
		    ALLOC

Now EMHEAP's VMA and LMA follow the section before it.

So I think the kind of workaround mentioned in

  http://debbugs.gnu.org/cgi/bugreport.cgi?bug=2507#10

above, or some variant thereof, is the right way of producing a
stripped emacs.exe.  That is, link with -s (or strip temacs.bin after
it is produced), and then run addsection to produce temacs.exe and
finally loadup+dump into emacs.exe.

An alternative is to add code to addsection.c so that it could adjust
the EMHEAP section's VMA and LMA after emacs.exe was stripped.  No,
I'm not volunteering ;-)

P.S. I tried to adjust the VMA/LMA with objcopy, but the result is not
reliable: sometimes works, sometimes crashes.  So more than just
address adjustment is needed.




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Wed, 04 Jun 2014 18:44:01 GMT) Full text and rfc822 format available.

Notification sent to Eli Zaretskii <eliz <at> gnu.org>:
bug acknowledged by developer. (Wed, 04 Jun 2014 18:44:02 GMT) Full text and rfc822 format available.

Message #69 received at 2507-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: 2507-done <at> debbugs.gnu.org
Subject: Re: bug#2507: 23.0.91;
 Stripping emacs.exe on MS-Windows produces an invalid program
Date: Wed, 04 Jun 2014 21:42:56 +0300
This problem was solved as side effect of the changes to use mmap-like
memory management for buffer text and store the dumped data in a
static array instead of a special section.

Closing.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 03 Jul 2014 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 355 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.