Typical elf relocated target file

Source: Internet
Author: User

ClipElf HeaderAndSection header tableAre all sections. A typical elf relocated target file contains the following sections:

  • . Text: The machine code of the compiled program.
  • . Rodata: Read-only data, such as the format string in the printf statement and the jump table of the switch statement.
  • . Data: Initialized global C variable. Local C variables are stored in the stack at runtime, neither in. Data nor in. BSS.
  • . BSS: Uninitialized global C variable. In the target file, this section does not occupy the actual space. It is just a placeholder. Target file format DifferentiationInitializationAndNot initializedVariables are used for space efficiency: In the target file, uninitialized variables do not need to occupy any actual disk space.
  • . Symtab: A symbol table, which stores information about the defined and referenced functions and global variables in the program. Some programmers mistakenly think that a program must be compiled using the-G option to obtain the symbol table information. In fact, each relocated target file has a symbol table in. symtab. However, unlike the symbol table in the compiler, the. symtab symbol table does not contain local variables.
  • . Rel. Text: When the linked objects combines the target file with other files, many locations in. text must be modified. Generally, any command to call an external function or reference a global variable must be modified. On the other hand, commands that call local functions do not need to be modified. Note that the information in the executable target file does not need to be relocated. Therefore, it is generally omitted unless the user explicitly instructs the linker to include the information.
  • . Rel. Data: Information of any global variables defined or referenced by the module. Generally, the address of any initialized global variable whose initial value is a global variable or an external function must be modified.
  • . Debug: A debugging symbol table, some of which are local variables and Type Definitions defined in the program, and some of which are global variables defined and referenced in the program, some are original C source files. This table is obtained only when the driver is compiled by calling the-G option.
  • . Line: Ing between the line numbers in the original C source program and machine commands in the. text section. This table is obtained only when the driver is compiled by calling the-G option.
  • . Strtab: A string table, including the symbol table in the. symtab and. debug sections, and the section name in the section header. A string table is a string sequence ending with null.

Note: Why is uninitialized data called. BSS?

It is common to use. BSS to indicate uninitialized data. It started with the abbreviation of the "Block Storage Start (Block Storage Start)" command in IBM 704 assembly language (around 1957) and is still in use. One simple way to distinguish. Data from. BSS is to regard "BSS" as "better space savings (better save space )! .

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.