delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/10/30/04:55:47

Date: Tue, 30 Oct 2001 11:55:00 +0200
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
Message-Id: <9743-Tue30Oct2001115500+0200-eliz@is.elta.co.il>
X-Mailer: emacs 21.1.50 (via feedmail 8 I) and Blat ver 1.8.9
CC: djgpp-workers AT delorie DOT com
In-reply-to: <3BDDD2F5.4D609543@phekda.freeserve.co.uk> (message from Richard
Dawe on Mon, 29 Oct 2001 22:06:45 +0000)
Subject: Re: Patch for develop.txi: BSS and restarted programs
References: <3BDDD2F5 DOT 4D609543 AT phekda DOT freeserve DOT co DOT uk>
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> Date: Mon, 29 Oct 2001 22:06:45 +0000
> From: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
> 
> Below is a patch for develop.txi in the knowledge base, which describes
> what to do about BSS and restarting programs (aka Emacs ;) ) restarting.

Thanks.

> OK to commit?

I have a few comments:

> + Uninitialised static and global data is placed in the section @dfn{bss}.

That @dfn is not really approppriate here, since you are not
explaining what BSS is.  Better use @code{bss}, or even "the
@code{bss} section".

> + The BSS is zeroed by the start-up code.  It would seem that one can rely
> + on uninitialised static and global variables being initialised to zero.
> + Unfortunately it is possible that the start-up code is not called.
> + This happens where programs are restarted --- Emacs is one example.

That's backwards: in the case of Emacs, the startup code is actually
executed several times, one each for every time Emacs is dumped.

The _real_ problem is not with the startup code.  The variables in the
BSS section are AFAIK initialized by the linker, not by the startup
code.

Also, I think uninitialized variables in BSS are not the only ones for
which this issue is relevant: static initialized variables are also
subject to this.

The problem with Emacs is that the program was already running when it
was dumped, so static variables have values in them that may be
different from their initial values.  Dumping will then record their
actual values at dump time, not the values they had when the program
was first started.  So, when the program starts after it was dumped, a
static variable won't have a zero value (or any other initial value
you programmed), but instead the last value it had before the program
was dumped.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019