This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: faq regarding
- To: binutils at sourceware dot cygnus dot com, ivan at torpid dot com
- Subject: Re: faq regarding
- From: msokolov at ivan dot Harhan dot ORG (Michael Sokolov)
- Date: Fri, 15 Sep 00 11:54:07 CDT
Ivan Pulleyn <ivan@torpid.com> wrote:
> My current problem is that if I declare something like:
>
> static int foo[0x10000];
>
> GCC emits:
>
> .local foo
> .comm foo,262144,32
>
> The resulting image produced by LD does not change in size.
In UNIX-tradition tools there is a notion of .bss. This is an area of memory
that is writable and assumed to be zero-filled when your program starts
running. The rule in the C standards that uninitialised global variables are
zero initially is there because they go into .bss. .bss never appears in the
linker-produced image. However, it does have address space reserved for it.
Therefore, even though your boot sector image is short, its code will refer to
a large section of memory allocated for the foo array when you refer to it.
> Does this
> mean LD is emiting something I have to fixup before executing?
No, you don't really have to fix up anything at run time. You can just do
nothing and it will work, except that the initial contents of uninitialised
global variables won't be zero but will be the random memory contents instead.
If you want it to be zero like the C standards say, just add a little startup
code that zeros it. You can make the linker script define symbols at the start
and end of .bss so that your zeroing code knows where it is in memory.
--
Michael Sokolov Harhan Engineering Laboratory
Public Service Agent International Free Computing Task Force
International Engineering and Science Task Force
615 N GOOD LATIMER EXPY STE #4
DALLAS TX 75204-5852 USA
Phone: +1-214-824-7693 (Harhan Eng Lab office)
E-mail: msokolov@ivan.Harhan.ORG (ARPA TCP/SMTP) (UUCP coming soon)