473,725 Members | 2,424 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

text,data and bss

i just got to know there are three different sections in which we can
divide our program
*Text section
*Data section
*Bss

i think text section contain our code,data section include heap,stack
(?) etc.

Can any body throw light on Bss section...
Nov 16 '08 #1
27 13573
c.***********@g mail.com wrote:
i just got to know there are three different sections in which we can
divide our program
*Text section
*Data section
*Bss

i think text section contain our code,data section include heap,stack
(?) etc.

Can any body throw light on Bss section...
http://en.wikipedia.org/wiki/.bss

Bye, Jojo
Nov 16 '08 #2
On 16 Nov 2008 at 12:14, c.***********@g mail.com wrote:
i just got to know there are three different sections in which we can
divide our program
*Text section
*Data section
*Bss

i think text section contain our code,data section include heap,stack
(?) etc.
The heap and stack occupy the virtual memory locations above the text
and data segments. The heap will grow upwards, the stack downwards from
the highest memory address.

Here is a picture:

highest address
=========
| stack |
| vv |
| |
| |
| ^^ |
| heap |
=========
| bss |
=========
| data |
=========
| text |
=========
address 0
Can any body throw light on Bss section...
Variables that are initialized to 0 are placed in the BSS segment.
Static variables not initialized to 0, constants, strings, etc. are
placed in the data segment.

Nov 16 '08 #3

<c.***********@ gmail.comwrote in message
news:5c******** *************** ***********@o40 g2000prn.google groups.com...
>i just got to know there are three different sections in which we can
divide our program
*Text section
Executable code
*Data section
Static data (variables etc) initialised at compile time. Both of these use
up space in the executable.
*Bss
Static data (variables etc) uninitialised at compile time (or possibly,
initialised to zero). These take no data space in the executable. At runtime
you would hope these are initialised to zero.
i think text section contain our code,data section include heap,stack
(?) etc.
Heap and stack are assigned at runtime. They take up no space in the
executable although it may specify what size they should be, especially the
stack.

This is all in the context of a typical C implementation that uses
traditional compilation and linking and the concept of an executable file.
In theory C could be implemented entirely differently. Or even slightly
differently...

--
Bartc

Nov 16 '08 #4
"c.***********@ gmail.com" <c.***********@ gmail.comwrites :
i just got to know there are three different sections in which we can
divide our program
*Text section
*Data section
*Bss

i think text section contain our code,data section include heap,stack
(?) etc.

Can any body throw light on Bss section...
This question really has nothing to do with the C language. It's
entirely determined by your operating system, and can vary from one
system to another. The same C program compiled on different systems
might have different sections; a C program and a Fortran program
compiled on the same system will probably have the same sections with
the same meanings. The C language itself says nothing about text,
data, and bss sections.

So your question would be appropriate in a newsgroup that discusses
your operating system, perhaps comp.unix.progr ammer or
comp.os.ms-windows.program mer.win32. But you can probably answer it
more easily with a quick Google search.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Nov 16 '08 #5
On 16 Nov, 12:14, "c.lang.mys...@ gmail.com" <c.lang.mys...@ gmail.com>
wrote:
i just got to know there are three different sections in which we can
divide our program
*Text section
*Data section
*Bss

i think text section contain our code,data section include heap,stack
(?) etc.

Can any body throw light on Bss section...
Think of the work of the program loader. To load a program it has to
basically do the following.

1. Allocate memory for the program executable code and load the code
from the executable file into that space.
2. Allocate memory for a stack.
3. Allocate memory for program data - say 300 bytes are needed of
which 200 have initial values and 100 are not initialised. It loads
the first 200 bytes of initial values from the executable file. The
remaining 100 bytes have no initial values so they are not part of the
executable file but there still needs to be space allocated for them
when the program runs. The last 100 bytes is the bss section.

The need for both predefined data and uninitialised data can be seen
in the these two statements. Think of them as global or static.

float a = 53.0;
float b;

Variable a and others like it which have an initial value will be
assigned to the data section. Variable b and others which are not
initialised are assigned to bss. Since values in bss are not specified
the compiled code does not need to specify initial values for them,
they don't need to take up space in the executable file and the
program loader doesn't need to spend time loading them from disk.

--
HTH,
James
Nov 16 '08 #6
On 16 Nov, 12:18, "Joachim Schmitz" <nospam.j...@sc hmitz-digital.de>
wrote:
c.lang.mys...@g mail.com wrote:
i just got to know there are three different sections in which we can
divide our program
*Text section
*Data section
*Bss
i think text section contain our code,data section include heap,stack
(?) etc.
Can any body throw light on Bss section...

http://en.wikipedia.org/wiki/.bss
Is the current Wikipedia entry right? It says that bss contains
initially zero-filled values. Surely the bss holds _undefined_ data.
Maybe some operating systems zero-fill the space but that is OS-
dependent. Also, all-zero bit patterns do not necessarily signify
zeroes in all data types. For example, floating point zeroes are not
necessarily all-zeroes patterns.

Comments?

--
James
Nov 16 '08 #7
James Harris wrote:
On 16 Nov, 12:18, "Joachim Schmitz" <nospam.j...@sc hmitz-digital.de>
wrote:
>c.lang.mys...@ gmail.com wrote:
>>i just got to know there are three different sections in which we can
divide our program
*Text section
*Data section
*Bss
i think text section contain our code,data section include heap,stack
(?) etc.
Can any body throw light on Bss section...
http://en.wikipedia.org/wiki/.bss

Is the current Wikipedia entry right? It says that bss contains
initially zero-filled values. Surely the bss holds _undefined_ data.
Maybe some operating systems zero-fill the space but that is OS-
dependent.
The .bss section is officially "uninitialized" , but AFAIK all modern
OSes either create new user-space pages as zero-filled (for security
reasons) or require that the C compiler insert start-up code to
zero-fill the uninitialized space (e.g. with memset()). All global and
static C variables go there if they have an initial value of zero, so
someone must be responsible for making that true. If such a variable
had any other initial value, it would go in .data and be copied directly
from the object file to memory.

The entire purposes of .bss was to get zero-initialized variables out of
..data. In a sense, it's a compression scheme.
Also, all-zero bit patterns do not necessarily signify
zeroes in all data types. For example, floating point zeroes are not
necessarily all-zeroes patterns.
If that condition did not hold, the compiler would not be allowed to put
floating point variables in .bss. In practice, the all-zeros bit
pattern is often defined to mean zero for this and related reasons.

S
Nov 16 '08 #8
James Harris <ja************ @googlemail.com writes:
On 16 Nov, 12:18, "Joachim Schmitz" <nospam.j...@sc hmitz-digital.de>
wrote:
>c.lang.mys...@ gmail.com wrote:
i just got to know there are three different sections in which we can
divide our program
*Text section
*Data section
*Bss
i think text section contain our code,data section include heap,stack
(?) etc.
Can any body throw light on Bss section...

http://en.wikipedia.org/wiki/.bss

Is the current Wikipedia entry right? It says that bss contains
initially zero-filled values. Surely the bss holds _undefined_ data.
Maybe some operating systems zero-fill the space but that is OS-
dependent. Also, all-zero bit patterns do not necessarily signify
zeroes in all data types. For example, floating point zeroes are not
necessarily all-zeroes patterns.

Comments?
I don't know about the first part, but since bss is entirely
system-specific (even though it's used on multiple systems), it's
entirely possible that all systems that use bss have null pointers and
floating-point zeros represented as all-bits-zero.

Alternatively, a C implementation on a system where null pointers
and/or floating-point zeros have some other representation would have
to be careful about how it uses bss.

Which emphasizes the point that this is not a question about the C
language.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Nov 16 '08 #9
On November 16, 2008 11:56, in comp.lang.c, Stephen Sprunk
(st*****@sprunk .org) wrote:
[snip]
The entire purposes of .bss was to get zero-initialized variables out of
.data. In a sense, it's a compression scheme.
IIRC, the entire purpose of .bss was to get /uninitialized/ variables out
of .data. To quote "A tour through the Unix C compiler" (D. M. Ritchie,
Bell Laboratories, circa 1979)
"BSS means that subsequent information is to be compiled as uninitialized
static data"

[snip]
--
Lew Pitcher

Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/ | GPG public key available by request
---------- Slackware - Because I know what I'm doing. ------
Nov 16 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
6833
by: Stephen Saunders | last post by:
Hey Folks, This one currently has me stumped. I have to check for the existence of a carriage return (Enter key, hex 0D) in text data. First I tried: 'Check comment to not contain the CR (13) character For i = 1 To Len(txtComment.Text) On Error GoTo BogusComment2 If Mid(txtComment.Text, i, 1) = CStr(13) Then MsgBox "Comment cannot contain the enter character"
2
1780
by: leegold2 | last post by:
General DB questions, Why do we use null values? Why is it better than an empty field? What would be a real life situation were nulls are important to have? If I have a paragraph of text in a field of data type: TEXT. Can I search in this field? Maybe i mean, could i use SELECT on a table and get rows on the basis of a string or substring in the TEXT field? Thanks,
5
8593
by: adrian | last post by:
hi all this is my first post to this group, so pls bear with me while i try to make some sense. i am trying to create a sproc which uses dynamic sql to target a particuar table eg. '.' and perform some actions. i am using @tableID as a passes parameter for the sproc.
1
1790
by: Ola Theander | last post by:
Dear subscribers I'm currently creating a small application that will run at the end of a web installation to configure a SQL Server. For this task I have a SQL batch file in the same format as SQL Query Analyzer uses. I would prefer not to merge the content of this file into the source code of configuration application but instead keep the SQL commands in a text file included in the executable, pretty much like resource data, for...
9
2358
by: Susan Bricker | last post by:
Greetings. I am having trouble populating text data that represents data in my table. Here's the setup: There is a People Table (name, address, phone, ...) peopleID = autonumber key There is a Judge Table (information about judges) judgeID = autonumber key
6
4779
by: smilly | last post by:
This field is bound to a image data type in SQL server that is used to house big amounts of text how can I output the text data because right now I am getting System.Byte
5
1744
by: sirimanna | last post by:
hello, i'm new to VB...i like to know how to open some text data save in c: in to text box.. i know to save cord's to save data in text box in to c:..but i don't know how to get back that save text data in c: in to vbtext box thank u.
0
1311
by: Jack | last post by:
Hi, I do a webrequest and it returns some text data in a stream. I want to put this tyext data into a string. I've got it working just fine, but I have to put the text data into into a fixed-size buffer BEFORE I put it into a string (ConstBufferByteSize=1000000). This fixed size buffer wastes space. Is it possible to somehow assign it straight to a string, or somehow do this 'dynamically' ?
6
5244
by: aagarwal8 | last post by:
Hi, I am trying to write the contents of a textbox to a file in binary format. My code looks like this... private void btnWriteToFile_Click(object sender, EventArgs e) { FileStream fs = File.Open(@"D:\test.dat", FileMode.OpenOrCreate, FileAccess.Write); BinaryWriter bw = new BinaryWriter(fs);
9
5374
by: sillyr | last post by:
Hi - I use Access 2007. I have a two data fields that I would like to add together in a query and then have the query sum the data for the entire table. The problem is that one of the data fields has a data type of number and the other data field has a data type of text. The data filed with the text data type is a combo box with two fields on of which is a number and t he other is text. I tried to use the functions Val and Cint, but am not...
0
8882
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8749
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9250
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9165
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8080
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6699
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4777
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3216
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2153
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.