delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/08/08/13:16:02

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Sequence of Symbol Allocation
Date: 8 Aug 2004 17:08:37 GMT
Lines: 54
Message-ID: <2nn50lF2gp65U1@uni-berlin.de>
References: <E94D7E69-E940-11D8-9F0B-003065C18A1C AT gmx DOT ch>
X-Trace: news.uni-berlin.de 4UnLq1j42jKzTZ3AyZ+x1wGDhlLhIn0E3epEkIkOnvL9ZbX4w/M9Bsrc0Z
X-Orig-Path: not-for-mail
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Werner Schönenberger <werner DOT schoenenberger AT gmx DOT ch> wrote:
[...]

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

I object to these being called "progamming techniques".  Their correct
name is "bloody hacks".  And like all bloody hacks, they will come
back to haunt you one day.  Looks like for your particular project,
that day has come.

The source of your problem is given right there in "info gas symbols":

     _Warning:_ `as' does not place symbols in the object file in the
     same order they were declared.  This may break some debuggers.

Expecting .comm symbols, of all things, to remain ordered, strikes me
as begging for problems.  By their very nature, common symbols will be
gone over and reorganized by the linker.  If you don't want that,
use structs to hold them in, i.e. in C parlance, instead of

	/* globals */
	int a;
	unsigned long b;
	char c;
	
do

	/* global struct */
	struct {
	   int a;
	   unsigned long b;
	   char c;
	} struct_of_globals;


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

Well, as the old saying goes: "Don't do that, then!".

I suggest you take this on to the real authors of the software you're
dealing with: the GNU binutils people.  DJGPP is just a port of these
programs to DOS, but this issue is quite independent of that.
Actually I'ld venture a guess you'll see exactly the same behaviour if
you build your original code using GNU binutils on Sun boxes.

-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


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