1. Compile addr.c with gcc and output the addr executable file. GCC Addr.c-o ADDR2, run the compiled program 3, see the program after running the address of each segment, run the command PS aux, find out the process number of the addr process, as here./addr process number is 11149, then run command cat/proc/11149/maps To view the address space for the process. 08048000-08049000: Code snippet has Read permission 08049000-0804a000: Data segment has read and Write permissions 08bb7000-08bd8000: Heap space heapbfa0a000-bfa1f000: Stack space stack. 4, understand the ELF format, the Linux application is the ELF format by default, use the file command to view the format, such as executing the command "file addr". 5, the use of readelf command to view the various segments of the program information, the execution of the command "Readelf-s addr" Summary: The global initialization of the variable: the data segment is not initialized global variables; In the data segment BSS segment global static variable: In the data segment global constant: In the code snippet local variable: on the stack segment , the address grows to a low memory address. Local static variable: is located in the data segment. Space allocated through malloc: In the heap segment, address to high memory growth. Note The BSS segment is a sub-segment of the data segment.
Linux Application Address layout