Now I'm developing program like readelf
using pyelftools
libraries.
I want to print the table like below.
In here, Offset
field is stderr@GOT
address.
jiwon@jiwon$ readelf -a --wide libstdbuf.so
...
Relocation section '.rel.dyn' at offset 0x454 contains 12 entries:
Offset Info Type Sym. Value Symbol's Name
00001c50 00000206 R_386_GLOB_DAT 00000000 stderr@GLIBC_2.0
...
Assume that I have only GOT address(00001c50
) of unknown symbol.
My situation I want to make function like get_symname_by_GOTaddress
for resolution from 00001c50
to stderr@GLIBC_2.0
.
Question : However, I could not find any linkage information between GOT address
and symbol name
in binary. How can I get it?
Every entry in the
.rel.dyn
section has at least the following fields:So first scan the section until the address match an entry's
r_offset
field, then fieldr_info
contains (also) the index to the symbol table, which is composed according to this:So you can extract the
sym
index, then fetch the entry from the symbol table, which has the fieldst_name
, which is the index into the string table, which contains the symbol name in characters representation.Links for more information:
rel.dyn section description -> symbol table description -> string table description