Target file Elf (executable linkable Format)
Executables: There are two main types, PE and ELF. The target file is the. o file, which is similar to the executable file structure, so we can think of them as a type of file, in fact, the library file is the. o file, which is sufficient to explain its relationship with the executable file.
Elf File type description Example
relocatable files primarily contain code and data, and static libraries can also be included in this category. Linux->.O Windos->.obj
Executable is an executable file with no extension /bin/bash file exe file
Shared destination file connector can be used, the implementation of the dynamic link library linux-& gt;. So file DLL
Core dump files can transfer information such as the address space of a process to a core dump file when the process is terminated core dump
Structure of the target file:
The target file typically holds information in segments or sections. In general, it consists of four parts.
Header file section, text segment, data segment, BSS segment, read-only data segment, comment information segment, stack segment.
Now, let's parse these sections individually:
Header file:
The header file of the target file contains, the system platform information, the hardware information, the environment information, the function pretext entrance and so on the most important time also contains a name "the paragraph table" the thing. Cong records the individual segment information in the destination file.
Text, Rel.text, data, BSS, Rodata, comment, Not-gnu-stack,shstrtab, symtab,strtab these pieces of information.
These things can be viewed through readelf-s xxx.o.
Text segment:
Is the section that holds the code, generally in the form of ASCII to store the code, using Gcc-s XXX.O can disassemble the code.
Data segment:
Storing data that has already been declared and initialized, a global static variable, a local static variable, and the data inside the function will not be here, usually generated on the function stack when the function is run. Global variable not initialized
or initialized to 0, it is no longer in the data segment.
BSS segment:
The uninitialized global static variables and local static variables are stored, and the uninitialized global variables are not stored in the BSS segment but are placed in the symbol table as a symbol.
Comment (note table):
Used to store the notes we wrote.
Stack segment:
Tip the stack of this executable file, in general, the stack should be reentrant,
Other Segments:
Debug debugging information, dynamic link information, hash hash table, line debug row number table and symbol table and so on.
Target file Elf