I am trying to understand how the linking works. I have a simple C++ code
#include "a.h"
int Other() {
return 1;
}
int SomeFunction() {
Other();
Other();
Other();
return 0;
}
which generates the following Relocation table.
$ readelf -r a.o
Relocation section '.rela.text' at offset 0x240 contains 3 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000000018 000900000004 R_X86_64_PLT32 0000000000000000 _Z5Otherv - 4
00000000001d 000900000004 R_X86_64_PLT32 0000000000000000 _Z5Otherv - 4
000000000022 000900000004 R_X86_64_PLT32 0000000000000000 _Z5Otherv - 4
Relocation section '.rela.eh_frame' at offset 0x288 contains 2 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000000020 000200000002 R_X86_64_PC32 0000000000000000 .text + 0
000000000040 000200000002 R_X86_64_PC32 0000000000000000 .text + f
It looks like the callsites of Other() functions are all marked as R_X86_64_PLT32 type. When I check the definition of R_X86_64_PLT32, it says L + A - P, where L represents the place (section offset or address) of the Procedure Linkage Table entry for a symbol, A represents the addend used to compute the value of the relocatable field and P represents the place (section offset or address) of the storage unit being relocated (computed using r_offset).
I am not sure what it mean by the place of the PLT for a symbol. My questions are
What would be the value of L, A, P for that case?
From my understanding, PLTs are used by dynamic objects. Why Other() is marked as PLT32 even when this is just a static function.
How to find the PLT of the ELF file and how to find Other() in it?