Based on the middle of the Linux Program learning summary Detailed _linux

Source: Internet
Author: User
The Linux program has continued to touch some of the land, the appropriate summary today, the time is hasty, summary of the relatively fragmented.
Linux segment:
Text: The machine code of the compiled program.
. Rodata: Read-only data. A format string in printf, or a jump table for a switch statement.
Data: A global variable that has been initialized.
BSS: A global variable that is not initialized.
Symtab: Symbol table.
Attention:
1, if you define a global variable, int i = 0, it is initialized to 0, but it is not in the data section, but in the BSS section. Because the compiler might do some optimizations, if initialized to 0, it would equate it with an uninitialized variable. This may require him to initialize all uninitialized global variables (BSS segments) to 0. -but this might be related to the compiler.
2, for static global variables, it has a property in the symbol table that indicates that he is local, not global. The symbol for local is not allowed to be referenced by other files.
3, static defined local variables, the compiler will take it as a static global variable to deal with. It appears in the symbol table (local variables are not present). The only difference is that it gets rid of its name in the symbol table, and generally adds a suffix: ". 1788". Use this method to prevent duplicate names of other global variables. It can also prevent calls to it.
4, paragraph is aligned. If you define a char character, you will find that it will sometimes add four bytes, and then define that the paragraph is no longer increased.
5. The tools for viewing the program segment include: Readelf,objdump (plus-T to see which segment the variable belongs to), size (you can see the sizes of each segment). )
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.