简体   繁体   中英

how to understand fields of Relocation section '.rela.plt'

I'm trying to understand the dynamic linking of shared libraries on Linux. Given the following dump of Relocation section '.rela.plt':

     Offset          Info           Type           Sym. Value    Sym. Name + Addend
     000000373f68  0f8300000007 R_X86_64_JUMP_SLO 0000000000000000 _ZN8CashFlowmIERK7Paym + 0
     000000373f70  0f9800000007 R_X86_64_JUMP_SLO 0000000000000000 _Z8printCapPK3CapP8_IO + 0
     000000373f78  0f9900000007 R_X86_64_JUMP_SLO 0000000000000000 _ZN13SharedBaggage16ge + 0
     000000373f80  0f9c00000007 R_X86_64_JUMP_SLO 0000000000000000 _Z11usdCurrencyv + 0

I have the following questions:

  1. As far as I know, the lowest 3 bytes of r_info are used as an unsigned index into to the .dynsym section to point to the symbol. So, how to explain the following Relocation section entries which all have 0000007 as index into .dynsym section?

  2. Would anyone tell me what "Sym. Value" is? is it the real value (which means address) of the symbol? If so, how come they are all zeros?

  1. No. In Elf32 files, the high 3 bytes of r_info are the symbol index and the low byte is the relocation type. In Elf64 files, r_info is split as two 32-bit parts. The values 0f83 , etc. in the high parts are the symbol indices.

  2. The symbol values shown are not part of the relocation table but come from the dynamic symbol table referenced by the relocation. There will only be a symbol value if the symbol is actually defined in this module (shared library). If it's undefined and relying on a definition from another module, you'll just see zero.

  3. If I understand what you're asking, how resolution is done is an implementation detail, and probably outside the scope of an SO question. You should probably re-ask with specific questions about parts you don't understand for a particular implementation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM