delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/08/08/16:15:53

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: <ui1dh016me4c079jlsl5rhgjlfq67p4f9f@4ax.com>
References: <E94D7E69-E940-11D8-9F0B-003065C18A1C AT gmx DOT ch>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Lines: 69
Date: Sun, 08 Aug 2004 20:09:01 GMT
NNTP-Posting-Host: 24.71.223.147
X-Complaints-To: abuse AT shaw DOT ca
X-Trace: pd7tw3no 1091995741 24.71.223.147 (Sun, 08 Aug 2004 14:09:01 MDT)
NNTP-Posting-Date: Sun, 08 Aug 2004 14:09:01 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 15:43:20 +0200 in comp.os.msdos.djgpp, Werner
Schönenberger <werner DOT schoenenberger AT gmx DOT ch> wrote:

>Dear List,
>
>I am rather new to the DJGPP environment and have a specific question 
>to the sequence of symbol allocation in the DJGPP environment.
>
>A couple of month ago, I received some piece of source code that was 
>developed as far as I know in a SUN environment for a Motorola 68xxx 
>processor based system. About 90% of the source code was programmed in 
>assembler and therefore assembler oriented programming techniques were 
>used. Some people ported the SUN based development to the PC using the 
>DJGPP.  Almost everything now runs well except one major problem that 
>still exists: the sequence of the symbol allocation does not match to 
>the sequence in the source code. After several weeks of searching, I 
>still did not find a solution and so desperately need some help. The 
>problem in this situation is that the original source code uses some 
>programming techniques to optimize initialization or variable access. 
>E.g. for initialization of global symbols it uses a loop "from address 
>of variable A to address of variable Z set everything to 0".  Now after 
>linkage, if the address of variable "A"  is not the first and "Z" not 
>the last variable of the symbol section to initialize, it will not 
>initialize correctly. Example:
>
>Source Code:
>   .comm A,2
>   .comm b,2
>   .comm c,4
>   .comm d,2
>   .comm e,8
>   .comm f,2
>   .comm Z,2
>
>This will lead to a symbol list in the MAP file after linkage which 
>might look like
>
>   0x0004e670 b
>   0x0004e672 f
>   0x0004e674 d
>   0x0004e676 Z   <--
>   0x0004e678 e
>   0x0004e680 A   <--
>   0x0004e682 c
>
>If now the loop tries to initalize the variables between address "A" 
>and "Z", it will not succeed. There are also an unknown number of code 
>examples that uses two following variables within one instruction. For 
>example one single MOV command to the variable A, casted to WORD, will 
>set the values for "A" and "b" of  the example above within one 
>instruction. But of course this will fail if the sequence of the 
>variable after the linkage does not correspond to the sequence in the 
>source code.
>
>Until now, I did not find a solution how the sequence of allocation can 
>be forced to be the same as in the source code. If anybody has some 
>ideas, please let me know. Any help is appreciated.

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. 

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