linux-mips
[Top] [All Lists]

Re: question regarding bss section

To: "Teresa Tao" <TERESAT@TTI-DM.COM>
Subject: Re: question regarding bss section
From: Wolfgang Denk <wd@denx.de>
Date: Mon, 27 Oct 2003 19:16:24 +0100
Cc: linux-mips@linux-mips.org
In-reply-to: Your message of "Mon, 27 Oct 2003 09:44:05 PST." <92F2591F460F684C9C309EB0D33256FA01B750B3@trid-mail1.tridentmicro.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
Dear Teresa,

in message 
<92F2591F460F684C9C309EB0D33256FA01B750B3@trid-mail1.tridentmicro.com> you 
wrote:
> 
> I have several questions and hope somebody could help me with the answers:
> 1. how to use gcc to compile the user mode program with larger stack size?

You don't. The Linux kernel will autyomagically grow the stack as needed.

> 2. Inside the user mode program, I have declared some gloabal data
> which is being put on the bss section and I would like to know whom
> initialize the bss section? How big is the bss section? Under what
> kind of situation, the bss section data could be corrupted?

The kernel resp. the C runtime environment will  initialize  the  BSS
for you. The BSS will be initialized with zero values.

The BSS section is as big as needed to put all  objects  of  matching
type into it (this is determined at link time).

The BSS may get corrupted in exactly the  same  situations  when  any
other memroy corruption can happen, i. e. typically writing through a
rogue  pointer,  writing  beyound  the valid index range of an array,
errors using malloc() and free(0, etc.

> 3. What's the difference to compile the program with -G  0  option?
> That  menas  I  don't  use  the  $gp register, will there be any side
> effect?

Quoting the GCC info pages:

`-G NUM'
     Put global and static objects less than or equal to NUM bytes into
     the small data or bss sections instead of the normal data or bss
     sections.  The default value of NUM is 8.  The `-msdata' option
     must be set to one of `sdata' or `use' for this option to have any
     effect.


Best regards,

Wolfgang Denk

-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd@denx.de
"I dislike companies that have a we-are-the-high-priests-of-hardware-
so-you'll-like-what-we-give-you attitude. I like commodity markets in
which iron-and-silicon hawkers know that they exist to  provide  fast
toys for software types like me to play with..."    - Eric S. Raymond

<Prev in Thread] Current Thread [Next in Thread>