Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6197807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:53:15+00:00 2026-05-24T03:53:15+00:00

We say that global variables and static variables are always initialized to 0. Then

  • 0

We say that global variables and static variables are always initialized to 0. Then my question is, why do we have separate sections in a binary for initialized and uninitialized data.

I wrote the following code –

int i;
int j=0;
static int k;
static int l=0;

int main()
{
  static int m=0;
  static int n;
    printf("%d, %d\n",i,j);
    printf("%d, %d\n",k,l);
    printf("%d, %d\n",m,n);
    return 0;
}

And the output was –

0, 0
0, 0
0, 0

I checked output of objdump of bss section and only this section contained the variables. But as per the link –

http://www.cprogramming.com/tutorial/virtual_memory_and_heaps.html

Typically, in each process, the virtual memory available to that
process is called its address space. Each process’s address space is
typically organized in 6 sections that are illustrated in the next
picture: environment section – used to store environment variables and
command line arguments; the stack, used to store memory for function
arguments, return values, and automatic variables; the heap (free
store) used for dynamic allocation, two data sections (for initialized
and uninitialized static and global variables) and a text section
where the actual code is kept.

So, I am just confused. If we have two data sections why is all the data placed in .bss section. And also I wanna understand what does .data contain.

Can someone please help me on this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:53:16+00:00Added an answer on May 24, 2026 at 3:53 am

    The .data section is typically reserved for variables with values known at compile time or larger blocks of constant memory such as strings that are known at compile time and static array blocks. Also the .bss section stores unintialized or zero valued variables because storing zero’es in the .data section wouldn’t make much sense.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've read that JavaScript does not really have static variables(when i say static, I
Say that I have a data model called Widget . If I pick one
Say that i have a generic dictionary with data like this (I hope the
Let's say that I have a global variable defined in App.xaml.cs as follows: public
Say i have a variable in a general Global.as file like this: public static
I have some global variables (classes) that as I understand have created before main()
Say that I have an immutable Point class with x and y parameters, and
Say that you have a loop and depending on the outcome of the loop
Say that a method only reads data from a database and does not write
Say that I have an article with multiple pages. Each page has a short

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.