ELF Format note (8) -- symbol type and attribute (st_info), elfst_info

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.