[Top] [All Lists]

Re: question regarding bss section

To: "Teresa Tao" <TERESAT@TTI-DM.COM>
Subject: Re: question regarding bss section
From: Wolfgang Denk <>
Date: Mon, 27 Oct 2003 19:16:24 +0100
In-reply-to: Your message of "Mon, 27 Oct 2003 09:44:05 PST." <>
Original-recipient: rfc822;
Dear Teresa,

in message 
<> you 
> 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

Best regards,

Wolfgang Denk

Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email:
"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>