I am working on Linux X86_64.
I have a need to determine the address of a specific PLT entry in an ELF file given the name of the dynamic function that the entry represents. I can figure out the file offset from the address, but I need to be able to determine the address.
If I disassemble the ELF file using objdump -D -z elffile
I see that objdump uses symbolic names for each entry in the PLT. (Where does objdump obtain the relationship between these addresses and the symbol names?)
example:
0000000000000041a2b0 fileno@plt:
If I use objdump -T elffile | grep fileno
I get something like this:
0000000000000 DF *UND* 00000000000000000 GLIBC_2.2.5 fileno
What I need to be able to do from "C" is find the PLT entry in the ELF file for a specific dynamic function and obtain the address.
The background is that I am patching an existing ELF file and need to redirect a function call to a different dynamic function. I have manually patched an ELF file using addresses gathered from objdump disassembly and proven that this will work for my specific application, I just need to be able to do it from a program. I am hoping not to have to crawl through objdump disassembler code to figure out how it gets the PLT entry symbols and addresses.
movq someFunc@PLT, %rax
should do it, but that@PLT
reference seems to imply linker modifications that mess up themovq
, which seems to make thesesomeFunc@PLT
references only usable with the call instruction. – Interradial