how to understand fields of Relocation section '.rela.plt'
Asked Answered
E

1

6

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?

Enure answered 23/2, 2018 at 6:6 Comment(0)
K
5
  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.

Kopp answered 23/2, 2018 at 7:21 Comment(2)
Thank you for your reply. I've updated my post with two new questions to your answer. Would you mind taking a look?Enure
I figured it out. .dynstr is not the same as .dynsym. your answers are correct! Thanks againEnure

© 2022 - 2024 — McMap. All rights reserved.