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, buffer1
is uinitialized, so it will probably be allocated on BSS segment, which starts at the end of the data segment.
From bravegnu website:
buffer1
has memory reserved in the static(bss/data) memory section of the program. That's where all statics and globals exist.
It is a third memory segment, like the stack and the heap.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With