* question regarding bss section
@ 2003-10-27 17:44 ` Teresa Tao
0 siblings, 0 replies; 8+ messages in thread
From: Teresa Tao @ 2003-10-27 17:44 UTC (permalink / raw)
To: linux-mips
Hi there,
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?
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?
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?
Thanks in advance!
Teresa
^ permalink raw reply [flat|nested] 8+ messages in thread
* question regarding bss section
@ 2003-10-27 17:44 ` Teresa Tao
0 siblings, 0 replies; 8+ messages in thread
From: Teresa Tao @ 2003-10-27 17:44 UTC (permalink / raw)
To: linux-mips
Hi there,
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?
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?
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?
Thanks in advance!
Teresa
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: question regarding bss section
2003-10-27 17:44 ` Teresa Tao
(?)
@ 2003-10-27 18:09 ` Ralf Baechle
2003-10-27 18:17 ` Wolfgang Denk
-1 siblings, 1 reply; 8+ messages in thread
From: Ralf Baechle @ 2003-10-27 18:09 UTC (permalink / raw)
To: Teresa Tao; +Cc: linux-mips
On Mon, Oct 27, 2003 at 09:44:05AM -0800, Teresa Tao 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?
Not at all. Stack size is a resource limit which is set with can be
manipulated with setrlimit(2) or in bash with the ulimit command. It
defaults to 8MB.
For pthread applications the stack size is a thead attribute, seem libc
manual.
> 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?
.bss is uninitialized. Initialized data can't be in .bss.
> How big is the bss section? Under what kind of situation,
As big as needed for everything in it.
> the bss section data could be corrupted?
There's millions of ways of writing broken code.
> 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?
-G 0 is the default for userspace. Iow. passing the option changed nothing.
Ralf
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: question regarding bss section
2003-10-27 17:44 ` Teresa Tao
(?)
(?)
@ 2003-10-27 18:16 ` Wolfgang Denk
-1 siblings, 0 replies; 8+ messages in thread
From: Wolfgang Denk @ 2003-10-27 18:16 UTC (permalink / raw)
To: Teresa Tao; +Cc: linux-mips
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: question regarding bss section
2003-10-27 18:09 ` Ralf Baechle
@ 2003-10-27 18:17 ` Wolfgang Denk
2003-10-27 19:08 ` Ralf Baechle
0 siblings, 1 reply; 8+ messages in thread
From: Wolfgang Denk @ 2003-10-27 18:17 UTC (permalink / raw)
To: Ralf Baechle; +Cc: Teresa Tao, linux-mips
In message <20031027180957.GA25797@linux-mips.org> you wrote:
>
> .bss is uninitialized. Initialized data can't be in .bss.
No. BSS is initialized as zero.
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
Life is a game. Money is how we keep score. - Ted Turner
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: question regarding bss section
2003-10-27 18:17 ` Wolfgang Denk
@ 2003-10-27 19:08 ` Ralf Baechle
2003-10-27 19:49 ` Wolfgang Denk
0 siblings, 1 reply; 8+ messages in thread
From: Ralf Baechle @ 2003-10-27 19:08 UTC (permalink / raw)
To: Wolfgang Denk; +Cc: Teresa Tao, linux-mips
On Mon, Oct 27, 2003 at 07:17:12PM +0100, Wolfgang Denk wrote:
> > .bss is uninitialized. Initialized data can't be in .bss.
>
> No. BSS is initialized as zero.
RTFM. It's unitialized because not contained in the binaries.
Ralf
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: question regarding bss section
2003-10-27 19:08 ` Ralf Baechle
@ 2003-10-27 19:49 ` Wolfgang Denk
2003-10-27 23:01 ` Ralf Baechle
0 siblings, 1 reply; 8+ messages in thread
From: Wolfgang Denk @ 2003-10-27 19:49 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips
In message <20031027190829.GB24946@linux-mips.org> you wrote:
>
> > > .bss is uninitialized. Initialized data can't be in .bss.
> >
> > No. BSS is initialized as zero.
>
> RTFM. It's unitialized because not contained in the binaries.
When an application runs it will see the BSS space as initialized as
zero.
In most implementations of ANSI C that I am aware of (including GCC /
glibc), the BSS segment will be used for uninitialized variables with
"static" storage class. Also, I've seen some compilers to put
variables eplicitly initialized to zero into the BSS segment, too. To
quote the C FAQ:
Uninitialized variables with "static" duration (that is, those
declared outside of functions, and those declared with the
storage class static), are guaranteed to start out as zero, as if
the programmer had typed "= 0". Therefore, such variables
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
Quantum particles: The dreams that stuff is made of.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: question regarding bss section
2003-10-27 19:49 ` Wolfgang Denk
@ 2003-10-27 23:01 ` Ralf Baechle
0 siblings, 0 replies; 8+ messages in thread
From: Ralf Baechle @ 2003-10-27 23:01 UTC (permalink / raw)
To: Wolfgang Denk; +Cc: linux-mips
On Mon, Oct 27, 2003 at 08:49:15PM +0100, Wolfgang Denk wrote:
> In most implementations of ANSI C that I am aware of (including GCC /
> glibc), the BSS segment will be used for uninitialized variables with
> "static" storage class. Also, I've seen some compilers to put
> variables eplicitly initialized to zero into the BSS segment, too. To
> quote the C FAQ:
>
> Uninitialized variables with "static" duration (that is, those
> declared outside of functions, and those declared with the
> storage class static), are guaranteed to start out as zero, as if
> the programmer had typed "= 0". Therefore, such variables
C doesn't know about .bss at all - no single mentioning in the ISO C
standard. But .bss is a section name used in the ELF binary format which
most Linux systems are using. The gABI says defines .bss:
.bss This section holds uninitialized data that contribute to the
program s memory image. By definition, the system initializes
the data with zeros when the program begins to run. The section
occupies no file space, as indicated by the section type,
SHT_NOBITS.
Certainly the term ``uninitialized'' isn't as precise as desirable but
that's the wording used in the relevant standard.
Ralf
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2003-10-27 23:01 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-27 17:44 question regarding bss section Teresa Tao
2003-10-27 17:44 ` Teresa Tao
2003-10-27 18:09 ` Ralf Baechle
2003-10-27 18:17 ` Wolfgang Denk
2003-10-27 19:08 ` Ralf Baechle
2003-10-27 19:49 ` Wolfgang Denk
2003-10-27 23:01 ` Ralf Baechle
2003-10-27 18:16 ` Wolfgang Denk
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.