ELF Format notes (5) -- Special Section, elfsection
The linker links some independent object files and library files to form executable files. In this process, the linker needs to solve some symbolic references and command relocation.
In addition, there is a dynamic link process. For example, some symbols are defined in a so file and need to be searched and relocated by the dynamic linker during the loading process. To do this, the dynamic linker needs some information, which is stored in some special sections, such as. dynamic.
Section and segment are for the Link View and execution view respectively. The translation of various materials is chaotic and will be understood slowly.
There are also some sections that support debugging functions, such as. debug and. line. The following is a table describing the Special section:
. Bss: stores uninitialized data, such as uninitialized global variables. Because it is not initialized, it is not necessary to take up any space in the file to record its initial value (so the type is SHT_NOBITS ). When the program starts running, the system clears the memory area mapped to. bss.
. Comment: Save version control information.
. Data/. data1: Save the initialized data. They occupy storage space in files, which is different from. bss.
. Debug: Save debugging information.
. Dynamic: Save the dynamic link information.
. Dynstr: String required to save the dynamic link. For example, each symbol in the symbol table has a st_name (symbol name), which points to the index of the string table. This string table may be saved in. dynstr.
. Dynsym: Save the table of symbols to be dynamically connected.
. Fini/. init: respectively Save the commands to be executed during process exit and initialization .. The init command will be executed before the program entry point (main.
. Got: Save the global offset table ).
In Android, GOT is divided into two parts:. got and. got. plt. The. got table is used to save the address referenced by the global variable, and. got. plt is used to save the address referenced by the function.
. Hash: stores the symbol hash table, which is used to quickly find the symbols in the corresponding symbol table.
. Interp: Save the path name of the ELF interpreter (such as the dynamic linker in Android.
. Line: Save the line number information for debugging.
. Note: Save some comments.
. Plt: procedure linkage table ). Each externally defined function has a corresponding item in PLT, which is used to locate the external function address.
. Relname/. relaname: Save the relocation table. For example,. rel. dyn and. rel. plt.
. Rodata/. rodata1: Save read-only data in the program.
. Shstrtab: Save a string table. These strings are the names of sections.
. Strtab: stores string tables, similar to. dynstr, But. dynstr stores the names of symbols that require dynamic links.
. Symtab: Save the symbol table (non-dynamic link ).
. Text: Save executable command code.
These section names prefixed with "." are retained by the system. An application can construct its own segment, but it is better not to name the section segment that has been defined by the system or start with "." to avoid potential conflicts.