Read the plt section of the virtual address of the binary and print ELF function

I want to read the .plt section of the ELF binary and get all the virtual addresses of external functions.

Disassembly of section .plt:

0000000000400400 <puts@plt-0x10>:
  400400:       ff 35 02 0c 20 00       pushq  0x200c02(%rip)        # 601008 <_GLOBAL_OFFSET_TABLE_+0x8>
  400406:       ff 25 04 0c 20 00       jmpq   *0x200c04(%rip)        # 601010 <_GLOBAL_OFFSET_TABLE_+0x10>
  40040c:       0f 1f 40 00             nopl   0x0(%rax)

0000000000400410 <puts@plt>:
  400410:       ff 25 02 0c 20 00       jmpq   *0x200c02(%rip)        # 601018 <_GLOBAL_OFFSET_TABLE_+0x18>
  400416:       68 00 00 00 00          pushq  $0x0
  40041b:       e9 e0 ff ff ff          jmpq   400400 <_init+0x20>

0000000000400420 <__libc_start_main@plt>:
  400420:       ff 25 fa 0b 20 00       jmpq   *0x200bfa(%rip)        # 601020 <_GLOBAL_OFFSET_TABLE_+0x20>
  400426:       68 01 00 00 00          pushq  $0x1
  40042b:       e9 d0 ff ff ff          jmpq   400400 <_init+0x20>

0000000000400430 <__gmon_start__@plt>:
  400430:       ff 25 f2 0b 20 00       jmpq   *0x200bf2(%rip)        # 601028 <_GLOBAL_OFFSET_TABLE_+0x28>
  400436:       68 02 00 00 00          pushq  $0x2
  40043b:       e9 c0 ff ff ff          jmpq   400400 <_init+0x20>

For example, 0x400410and the name of the function puts@plt, etc. I tried to read the REL_PLTELF binary section . But I get the address 0x601108for the PLT record 0x400410, which is in the global offset table. How can I get the virtual addresses of plt records?

EDIT . It turned out that I was reading a section got.plt. How can I read only a section .pltusing readelf?

+4
source share
1 answer

Uhmm, , , ... ASLR - , SO , ( - Lazy ) GOT . ( GOT) , . ld - ,

0

All Articles