This digest from: self-cultivation of programmers-linking, loading and library
The format of the destination file and the executable file is similar, and the contents of the dynamic-link library and the static-link library are very similar to the executable file. For dynamic-link and static-link libraries, the. dll and. lib files are under Windows, respectively, and. So asking prices and. A files under Linux.
For executables or target files, they all have file headers. The file header describes whether the file is an executable file or a linked file or a library file.
Reasons to fragment executable files:
① Protect code Snippets.
② because the CPU cache is limited, reducing the size of the buffer can increase or decrease the hit ratio.
⑤ can share code snippets.
There are two main types of data in the target file: code and data.
Elf Head |
Information in this document |
|
Section Head Table |
to describe the information for each segment, such as the name of the segment and the position and offset of the segment |
|
. Init |
|
|
. text |
Code snippet |
|
. rodata |
Read-only data area |
Read-only data, such as a string or const constant |
. Data |
Data segment |
Global variables and local static variables |
. BSS |
does not occupy space |
Uninitialized global variable and local static variable default value is 0 |
. symtab |
Symbol table |
|
. Debug |
Debugging information |
|
. Line |
|
|
. strtab |
String table |
|
Section Header table |
|
|
You can have custom segments in your executable, for example, you can use the tool objcopy to write binary files (a picture) into an executable file.
Linker&loader