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

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.