//* Investigating program segments *

#include <stdio.h> #include <stdlib.h> int bss_var; // Uninitialized global variable int data_var = 1; // Initialized global variable const int const_var = 2; // Initialized global const variable int main(int argc, char **argv) { void *stack_var; // Local variable on the stack stack_var = malloc(8); // use it to prevent optimizing it out printf("Hello, World! Main text section is executing at %p\n", main); printf("Hello, World!\n" "This address (%p) is in our text section\n", main); /* stack section contains local data */ printf("This address (%p) is in our stack section\n", &stack_var); /* heap section contains data allocated dynamically*/ printf("This address (%p) is in our heap section\n", stack_var); /* bss section contains uninitialized data */ printf("This address (%p) is in our bss section\n", &bss_var); /* data section contains initializated data */ printf("This address (%p) is in our data section\n", &data_var); /* ???? section contains const initializated data */ printf("This address (%p) is in our const data section\n", &const_var); while(1) ; return(0); }