4th Lesson-linux Application Address Layout

Source: Internet
Author: User

1. Applications are composed of code snippets, data segments, BSS segments, and heap space, stack space.
2. Layout method:
(1) Code snippets at the lowest address, usually starting from 0x8048000, this is the virtual address, every application is like this
(2) Data segment close to the code snippet
(3) on the top is the BSS section is actually a data segment
(4) on the top of the heap space, the heap space is growing upward
(5) is not generally the stack space, stack space is downward growth

2. View the address of each segment
(1) In the application, at the end of the add while loop, to prevent the end of the program we are too late to view
(2) Compile into executable program and run
(3) Use the #ps aux command to view the PID of your application
(4) Open another terminal and view the file information with the Cat command
such as #cat/proc/(PID of your program)/maps
(5) The code snippet is read-only and executable
(6) data segment is writable
(7) heap space is heaps. Stack space is stack
3. Data storage
(1) Global variables, whether initialized or uninitialized, and whether the static initialization is in the data segment
(2) Global constants (read-only variables) are stored in the code snippet
(3) Non-static local variables, whether initialized or uninitialized, are in the stack
(4) Static local variables, whether initialized or non-initialized, are in the data segment
(5) Local constants (read-only variables) in the stack
(6) The local variables allocated by malloc are in the heap.
(7) String constants, whether local or global, in the code snippet
4. About BSS Segments
(1) Use the Readelf tool to view.
(2) Viewing the properties of an executable program with file
(3) The executable application compiled under Linux is in elf format
(4) Readelf-s (executable program name)
(5) The BSS section holds uninitialized data (variables), as long as it is stored in the data segment (large concept) and is not initialized there.

4th Lesson-linux Application Address Layout

Related Article

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.