lets say I have a file test.c that contains:
char buffer1[1024];
int somefunction()
{
char buffer2[1024];
// do stuff
}
now I know buffer2 is allocated on the stack on the frame belonging to somefunction calls, but where is buffer1 allocated ?
These variables are typically on BSS (variables which don’t have explicit initialization in the source code, so they get the value 0 by default) or data segment (initialized datas). Here,
buffer1is uinitialized, so it will probably be allocated on BSS segment, which starts at the end of the data segment.From bravegnu website: