Learn about Dynamic Links (5)-Dynamic symbol tables and dynamic symbols

Source: Internet
Author: User

Learn about Dynamic Links (5)-Dynamic symbol tables and dynamic symbols

The dynamic symbol table (. dynsym) is used to save the Import and Export symbols related to the dynamic link, excluding the symbols in the module. The. symtab saves all the symbols, including those in. dynsym.

The symbols in the dynamic symbol table are saved in the dynamic symbol string table. dynstr.

Use readelf to view the. dynsym table, for example, readelf -- dyn-syms libstdc ++. so.

 

As you can see, the. dynsym table contains 39 items. _ Cxa_atexit is an import symbol, while _ cxa_guard_acquire is an export symbol. Search for the source code of the android libstdc ++ library and find the definition of the export function:

 

The book says that many dynamic link modules are available at the same time. dynsym and. two symtab tables, but I checked several system shared libraries in android: libc. so ,. liblog. so, libm. so, libstdc ++. so, only. dynsym. In fact, according to my understanding, there is only. dynsym in the so library, which is used for symbol search and address relocation during dynamic link .. The internal symbol in symtab is useless at this time, so there is no need to exist. symtab.

 

Search for symbols in the symbol table before moving symbols to android linker. To speed up searching, the hash table corresponding to the symbol table is saved in. hash.

 

The 1st line code of the soinfo_elf_lookup function gets the address of the symbol table in the so library in the memory. In the soinfo_link_image function, the address of the symbol table has been read from. dynamic and saved in si-> symtab before the relocation operation. Both the string table and the symbol hash table are read and saved to the soinfo structure.

 

The address saved by si-> symtab is the virtual address after. dynsym in the so library is loaded to the memory. For details about the dynamic section. dynamic and the android linker source code parsing, you will continue to take notes later.

Learning Materials: programmer self-cultivation-links, loading and libraries

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.