1
2
3
4
5
6
7
8
// int x[1000];
// int x[1000] = {1};
int main()
{
// int x[1000];
// int x[1000] = {1};
return 0;
}

Using size, one can obtain sizes for text, data, and bss sections, respectively. By toggling the comments in the code snippet above, we can verify the following points:

  • uninitialized global variables are placed in bss, which doesn’t contribute to the size a.out
  • initialized global variables are placed in data, and will result in increasing of the file size of a.out
  • local variables, initialized and uninitialized, are not saved in a.out; instead, they are allocated and initialized during runtime.

A few more commands working with object and elf files: nm, objdump, and readelf.