1

Wikipedia mentions that .bss section occupies no actual space in the object file, and I indeed find a .bss entry with size 0 in the objdump information. So the question is what's the necessity of such an empty section existing in an object file?

Why can't .bss only being added in the executable file rather in both the .o and a.out file, just as .rel only appears in the object files.

Update: I think I misunderstood the process of relocating. I first thought the executable files are generated by the linker from scratch and it turns to be wrong after I saw the comment of Downvoters.

pedim
  • 69
  • 2
  • 5
  • 1
    I don't really understand your question. The sections in an executable are the ones from the object files the executable is composed of, so, how else should an executable contain a section if not by defining it in an object file? – cadaniluk Jul 14 '16 at 07:04

1 Answers1

0

Suppose in your code you have declared a global variable int arr[1000000] . If this information is not in object file then it can't get into executable also. And it does not make sense to increase the size of an object file to hold an information which is nothing but garbage. Same hold for an executable image. It will increase the flash memory requirement and serve no purpose. It is better that this area must be allocated while loading image in RAM.

Ashwani
  • 104
  • 5