ELF Format Note (eight)--type and attribute of the symbol (ST_INFO)

Source: Internet
Author: User

I am a cloud in the sky, the occasional projection in your wave heart, you do not have to be surprised, not to be happy, in a twinkling to eliminate the trace. You and I meet in the sea of the night, you have your, I have my, the direction, you remember good, best you forget, in the intersection of the light! --Xu Zhimo and occasional

Ilocker: Focus on Android Security (new entry, 0 Basics) qq:2597294287

As stated in the previous note, the St_info members of the ELF32_SYM structure contain information such as the type of the symbol and the binding property.

When the Android linker is relocated, if an undefined symbol is encountered, it will determine if the symbol is a weak reference symbol, and if not, an error is returned. The specific is judged by Elf32_st_bind macro:

The Elf32_st_bind macro is to extract bits from the st_info as a binding property:

Macro definitions for symbol binding properties:

    • Stb_local: local symbol, not visible outside this file.
    • Stb_global: Global symbols are visible in all object files to be linked together (global symbols can be referenced by other files).
    • Stb_weak: Weak symbols, similar to global symbols, but (defined) have lower precedence than global symbols.

If you have weak and global symbols with the same name, the definition of the global symbol takes precedence.

In the symbol table, usually the local symbol is in front, and the global and weak symbols are in the back row.

There is also a macro elf32_st_type, which is used to determine the type of symbol and also to extract bits as type information from St_info:

In the source code of Android linker, the macro is not used, and the type information of the symbol is not used.

Macro definitions for symbol type information:

    • Stt_notype: The symbol type is not specified.
    • Stt_object: Data objects, such as variables, arrays, and so on.
    • Stt_func: Function or other executable code.
    • Stt_section: Represents a section that is primarily used for relocation and typically has a stb_local property.
    • Stt_file: File symbol with stb_local attribute, St_shndx value is shn_abs. In the symbol table of the ELF file is located in front of the other stb_local symbols.

ELF Format Note (eight)--type and attribute of the symbol (ST_INFO)

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.