Mail Archives: djgpp/2002/07/22/19:46:11
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 -