From: Hans-Bernhard Broeker Newsgroups: comp.os.msdos.djgpp Subject: Re: Still a few questions about relocating COFF symbols (dynamic loading) Date: 23 Jul 2002 09:30:58 GMT Organization: Aachen University of Technology (RWTH) Lines: 38 Message-ID: References: NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de X-Trace: nets3.rz.RWTH-Aachen.DE 1027416658 639 137.226.32.75 (23 Jul 2002 09:30:58 GMT) X-Complaints-To: abuse AT rwth-aachen DOT de NNTP-Posting-Date: 23 Jul 2002 09:30:58 GMT Originator: broeker@ To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com dshnv wrote: > When I have a source file like this: > #include > 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. Of course you don't. Return to your C textbook and read about the difference between static and automatic variables to see why. > 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. You're looking at the wrong file, I think. Note that file.o is produced by the compiler alone. It's the *linker* which will proceed to put things from [common] into .bss, after having checked for duplicates, which it would unite. It may be best to avoid (i.e.: forbid) uninitialized, non-"static"-qualified file-scope variable definitions like your "global_bss". Require them to either be initialized, or explicitly labelled as private ("static"), or as "extern" to make them declarations instead of (tentative) definitions. -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.