Bss and data section

OP #1171252
Rate this post
useful
not useful
Hi everyone,

I compile a small C programm to test if initialized data will be put in
data section and non initialized data in bss section.

int a=5;

int b;
int c;
int d;

int titi()
{

int i;
int f=8;

    for(i=0;i<10;i++)
    {
        a=a++;
    }
b=a;
}

And I'm surprised to see that initialized datas were put in data section
after the compilation step (I can see it in toto.s) but even after
linking, there is still no bss section.
I'm using gcc and I notice that with

arm-elf-objdump -h toto.elf

I can see there is a .bss section and a .stack section but I can't see
it with

arm-elf-objdump -D toto.elf

I see only .text and .data section. Maybe is it because there is no
assembler inside it but I remember that with -D i was able to see .data
section even there is nothing inside it.

With nm toto.elf

I can see that there is symbol b,c,d with B letter so it seems these
value are inside BSS section.

Thanks for your help
Guest #1171253
Rate this post
useful
not useful
The .bss section of an object file contains no valid data, so it isn't
meaningful to disassemble this section. Think of the .bss section entry
as a information for the linker "object abc in object file xyz needs klm
bytes memory" only.

You can use objdump with option -h (aka --section-header or --header) to
display summary information from the section headers of the object file.
http://www.delorie.com/gnu/docs/binutils/binutils_6.html

Reply

Please log in before posting.

or

Log in with Google account

Registration is free and takes only a minute.

Register now