ELF Format note (9) -- st_value and st_shndx members of the Elf32_Sym structure, elf32_symst_value
Ilocker: Follow Android Security (novice) QQ: 2597294287
The structure of Elf32_Sym is mentioned in the previous note. In this note, write the st_value and st_shndx members.
For different types of object files, the meaning of st_value is slightly different:
· For the relocatable (. o) file, if the corresponding st_shndx value is SHN_COMMON, st_value stores the number of aligned bytes.
· For the relocatable (. o) file, if the symbol has been defined, st_value stores the offset of the symbol in its defined section (specified by st_shndx.
· For executable and shared object (. so) files, st_value stores a virtual address. Android linker adds st_value to the base address of the file loaded to the memory to get the definition address of the symbol.
St_shndx is the index (section number) of the section that defines the symbol in the section header table ). Several special values are listed here:
· SHN_UNDEF: It usually indicates that this symbol is not defined in this file (external symbol), and android linker will perform address relocation for this symbol.
· SHN_ABS: indicates that the symbol contains an absolute (absolute) value (often an address), which is not affected by relocation. For example:
Another example is the file name symbol:
· SHN_COMMON: indicates that this symbol is a common symbol. Generally, uninitialized global variables are symbols of this type. For more information about the common symbol, see the "common block" mechanism of the linker.