c - Read plt section of ELF binary and print function virtual address -


i want read .plt section of elf binary , 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, 0x400410 , function name puts@plt , on. i've tried read rel_plt section of elf binary. address 0x601108 plt entry 0x400410 global offset table. how can virtual addresses of plt entries?

edit: turned out i'm reading got.plt section. how can read .plt section using readelf?

uhmm, if i've understood question correctly can't.... aslr - adress space layout randomization, every gets loaded random address, , during load-time or run-time (dependant on symbol's binding - lazy or not ) got changed actual virtual address of loaded external symbol, when calling external function jumping pre defined offset (into got) , call function out of address stored within offset. goal of ld or os loader change address address should jump during runtime


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -