delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/08/08/23:15:36

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Trace-PostClient-IP: 68.147.131.211
From: Brian Inglis <Brian DOT Inglis AT SystematicSw DOT Invalid>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Sequence of Symbol Allocation
Organization: Systematic Software
Message-ID: <r6pdh01o8hs8hu0qftdc540aicng2cu1gv@4ax.com>
References: <E94D7E69-E940-11D8-9F0B-003065C18A1C AT gmx DOT ch> <ui1dh016me4c079jlsl5rhgjlfq67p4f9f AT 4ax DOT com> <F14EF265-E97C-11D8-889C-003065C18A1C AT gmx DOT ch>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Lines: 38
Date: Mon, 09 Aug 2004 03:12:18 GMT
NNTP-Posting-Host: 24.71.223.147
X-Complaints-To: abuse AT shaw DOT ca
X-Trace: pd7tw1no 1092021138 24.71.223.147 (Sun, 08 Aug 2004 21:12:18 MDT)
NNTP-Posting-Date: Sun, 08 Aug 2004 21:12:18 MDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Sun, 8 Aug 2004 22:53:04 +0200 in comp.os.msdos.djgpp, Werner
Schönenberger <werner DOT schoenenberger AT gmx DOT ch> wrote:

>> If the application uses C code and normal C startup code, allocating
>> those variables as if they were C extern in the BSS segment will cause
>> them to be zeroed at program initialization.
>> Alternatively, look at how GCC handles BSS zeroing, for an example of
>> how to do it properly, by arranging symbols with the linker.

>thank you for the information. Unfortunately almost all code is written 
>in assembler which also doesn't make it easy to understand and to find 
>all the traps. But nevertheless to check out GCC might help to find a 
>solution.

If you define a file globals.c (below), provide a(n alias for the
entry point) symbol in your program called _main (or main if in C
code), compile it (with gcc option -fno-leading-underscore) and link
it with gcc to your other code, you should find that the symbols are
defined in order in memory and initialized to all bytes zero when your
code is called, and the names should not be prefixed by the normal _. 
You might also have to change the current name of the entry point
symbol in your program to _main if it conflicts with the C startup
code: file crt0.S symbol start for gcc IIRC. 

globals.c:
short  A;
short  b;
long   c;
short  d;
double e;
short  f;
short  Z;

-- 
Thanks. Take care, Brian Inglis 	Calgary, Alberta, Canada

Brian DOT Inglis AT CSi DOT com 	(Brian dot Inglis at SystematicSw dot ab dot ca)
    fake address		use address above to reply

- Raw text -


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