Section Info for Variables in C
1 | // int x[1000]; |
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.