delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/07/22/19:46:11

From: dshnv AT www DOT com (dshnv)
Newsgroups: comp.os.msdos.djgpp
Subject: Still a few questions about relocating COFF symbols (dynamic loading)
Date: 22 Jul 2002 14:44:39 -0700
Organization: http://groups.google.com/
Lines: 45
Message-ID: <cd0304ab.0207221344.2fb8967a@posting.google.com>
NNTP-Posting-Host: 212.83.68.244
X-Trace: posting.google.com 1027374279 11266 127.0.0.1 (22 Jul 2002 21:44:39 GMT)
X-Complaints-To: groups-abuse AT google DOT com
NNTP-Posting-Date: 22 Jul 2002 21:44:39 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi,

I already used the google groups to browse through this newsgroup to
find information about this subject, but a few thinks still puzzle me.

When I have a source file like this:
#include <stdio.h>

char global_data[100] = { 0 };
int global_bss;

int main()
{
     int foo, bar;

     printf("%d\n", foo );
}

and I perform a objdump file.o, I don't see a _foo or a _bar in the
relocation or symbol table. Also, the size of .bss is 0. I thought
that foo and bar, since they consist of unitialised data, would go to
the .bss, and that therefore the size of the .bss would be 8 (and of
course 0 on disk). I know that ELF has a value for both memsize as
well as disksize but COFF doesn't. But I assume that the section size
in a COFF file is the memory size, so that the .bss would be 8 (if
_foo and _bar would appear in the .bss that is).
Is it right that I can just leave these _foo and _bar variables alone,
that I don't have to perform any kind of relocation, but just ignore
them? If not, how am I to figure the real size of the .bss if the
section header sais the .bss is 0 bytes in size.

I already know that global_bss does not appear in the .bss but is
defined as member of the [common] section. But I have to reserve
memory for it anyway, so I thought of appending it at the end of the
.bss.

But if I load the file (e.g. file.o), how do I know how much memory I
have to allocate for the image, since I do not know what the size of
the .bss is, and how many bytes it will grow if I append x number of
common symbols to it.

Does someone here has any experience with this and knows how to fix
this?
Help! :),
Thanks.

- Raw text -


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