ELF Format notes (7) -- symbol table, elfformat

Source: Internet
Author: User

ELF Format notes (7) -- symbol table, elfformat

The most is the gentle bow, like a lotus flower is cool and cool shame, a sound of treasure, a sound of treasure, the sound of treasure with a sweet sorrow-Xu Zhimo

The symbol table contains the definition or reference information of the symbol. For the android so file, the. dynsym symbol table stores the Import and Export symbols of the library file.

Read the. dynsym dynamic symbol table of android liblog. so with readelf:

 

The Ndx (st_shndx) of the symbol _ cxa_finalize is UND, indicating that the symbol is not defined in this so and needs to be searched in the liblog. so dependency library. Which libraries does liblog. so depend on? It can be found in. dynamic.

 

The definition of the symbol _ cxa_finalize should be in libc. so.

The Ndx (st_shndx) of the symbol _ android_log_vprint is 8, indicating that the symbol is defined in this so, and the section defining the symbol has an index of 8 in the section header table. Take a look at section header table:

 

We can see that the symbol _ android_log_vprint is defined in. text section, which is also taken for granted. Therefore, _ android_log_vprint is an export symbol, which is called by programs that need to print logs.

Because the symbol _ android_log_vprint is defined in this so, the Value (st_value) is not 0. Android linker finds the address defined by the symbol in the memory by the st_value when performing symbol relocation. However, 0x00001539 is of course not the final memory address of the symbol. linker will add the base address of liblog. so in the memory, so st_value is equivalent to an address offset.

Looking back, the symbol table is actually a struct array, and each struct describes the information of a symbol. Struct is defined as follows:

 

St_value and st_shndx are described above.

St_name is the name of the symbol. Here, only an index value that references the string table is saved.

St_size is 0 for the import symbol because it does not know the size of the person's home. The size of the exported symbol is clearly indicated.

St_info contains information such as the symbol type and binding attribute, which will be detailed in subsequent notes.

St_other is retained and does not need to be concerned.

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.