Compiled object file parsing


simple way to distinguish between .data and .bss section is the "bss" as is "better to save space (Better Save Space)" abbreviation.
.bss chunk store start (Block Storage Start)


Sandwiched between ELF header and section headers are festival. A typical ELF relocatable object file contains the following
several sections:
.text: compiled machine code program.

.rodata: read-only data, such as jump table format string and a switch statement printf statement.

.data: C Global and static variables initialized. C local variables at runtime is stored in the stack, neither appear in .data section,
it does not occur in the .bss section.

: bss: uninitialized global and static C variables, as well as all global or static variable initialized to zero. In the target
file, this section does not occupy real space, it is just a placeholder. Object File Format area has been initialized and uninitialized
variables for space efficiency: in the target file, uninitialized variables do not need to occupy any actual disk space. Run
time, the distribution of these variables in memory, initialized to zero.

.symtab: a symbol table, which is stored in the program defined and referenced information and functions of the global variables. Some programmers mistakenly
considered necessary by the -g option to compile a program in order to get the symbol table information. In fact, each of the relocatable object files
.symtab in both a symbol table (unless the programmer intended to be used to remove it STRIP command). However, the compiler symbol table different,
.symtab symbol table entry does not contain a local variable.

.rel.text: List .text section in a position, when the connector is this combination of target and other files,
modify these positions. In general, any command and external function calls or references to global variables need to be modified.
On the other hand, a local function call instructions, no changes need. Note that executable object file does not require the relocation information,
it is often omitted, unless the user explicitly indicating the connector comprises information.

.rel.data: relocation information for all global variables referenced module or defined. In general, any initialized
global variable, if its initial value is the address of the external address or a global variable defined functions, need to be modified.

.debug: a debug symbol table, local variables and whose entries are defined in the program type definitions, and procedures defined
global variables referenced, and the original C source file. Only when -g option to invoke the compiler driver will get
this table.

.line: mapping between the original line number of C source, and .text section machine instructions. Only when -g option to invoke the compiler driver
will get this table.

.strtab: a standard string, which includes .syntab and .debug section of the character table, and section name section head. String table
is the sequence of null-terminated string to.


 

Guess you like

Origin blog.csdn.net/baiyibin0530/article/details/92565397