Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22035

Why .bss size decrease when adding an initialized static variable?

$
0
0

I understand that the default alignment of .bss is 8 bytes for GCC as mentioned in this question Why the int type takes up 8 bytes in BSS section but 4 bytes in DATA section

So with this program:

int main(){

    return 0;
}

I have something like this:

   text    data     bss     dec     hex filename
   1418     544       8    1970     7b2 test

When I add an static variable with initialization to increase .data (and it does):

static int var = 255;

int main(){

    return 0;
}

I see that the size of .bss also decrease 4 bytes:

  text     data     bss     dec     hex filename
  1418      548       4    1970     7b2 test

Please tell my why ?


Viewing all articles
Browse latest Browse all 22035

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>