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

人盡茶涼 提交于 2021-01-01 04:43:52

问题


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:


  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.



来源:https://stackoverflow.com/questions/48942103/how-to-understand-fields-of-relocation-section-rela-plt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!