Linux Application Address layout

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.