ELF Format note (8) -- symbol type and attribute (st_info), elfst_info
I am a cloud in the sky, occasionally projected in your heart, you do not have to look different, do not have to rejoice, in a twinkling of an eye wiped out. You and I meet in the sea of the night, you have your, I have my, direction; you remember, it is best you forget, in this fair the light of each other! -- Xu Zhimo accidental
Ilocker: Follow Android Security (New entry, 0 basics) QQ: 2597294287
As mentioned in the previous note, the st_info Member of the Elf32_Sym structure contains information such as the symbol type and binding attribute.
When the android linker is relocated, if an undefined symbol is encountered, it determines whether the symbol is a weak reference symbol. If not, an error is returned. It is determined by the ELF32_ST_BIND macro:
The ELF32_ST_BIND macro extracts some bits from st_info as the binding property:
Macro definition of the symbol binding attribute:
- STB_LOCAL: The local symbol, which is invisible outside this file.
- STB_GLOBAL: global symbol, which is visible in all object files to be linked together (the Global symbol can be referenced by other files ).
- STB_WEAK: weak symbol, similar to a global symbol, but the (defined) priority is lower than the global symbol.
If there are weak and global symbols with the same name, the definition of global symbols is preferred.
In the symbol table, the local symbols are usually placed first, and the global and weak symbols are placed behind.
There is also a macro ELF32_ST_TYPE used to determine the type of the symbol. It also extracts some bits from st_info as the type information:
In the source code of android linker, this macro is not used, and the type information of the symbol is not used.
Macro definition of symbol type information:
- STT_NOTYPE: The symbol type is not specified.
- STT_OBJECT: data objects, such as variables and arrays.
- STT_FUNC: function or other executable code.
- STT_SECTION: indicates a section, which is mainly used for relocation and usually has the STB_LOCAL attribute.
- STT_FILE: The file symbol with the STB_LOCAL attribute. The value of st_shndx is SHN_ABS. The symbol table in the ELF file is located before the other STB_LOCAL symbols.