![](/img/trans.png)
[英]In ELF or DWARF, how can I get .PLT section values? — Trying to get the address of a function on where an instrumentation tool is in
[英]Read plt section of ELF binary and print function virtual address
我想读取ELF二进制文件的.plt部分并获取外部函数的所有虚拟地址。
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>
例如, 0x400410
和函数名称puts@plt
等等。 我试图读取ELF二进制文件的REL_PLT
部分。 但是我从PLT条目0x400410
获得地址0x601108
,该条目来自全局偏移表。 如何获取plt条目的虚拟地址?
编辑 :原来我正在阅读got.plt
部分。 如何使用readelf读取.plt
部分?
嗯,如果我已经理解你的问题是正确的那么你就不能...... ASLR - 地址空间布局随机化,每个SO都被加载到一些随机地址,并在加载时或运行时(取决于符号的绑定 - 懒惰与否)GOT被更改为加载的外部符号的实际虚拟地址。当调用一些外部函数时,您基本上跳转到某个预先定义的偏移量(进入GOT)并从该地址调用该函数将存储在该偏移量内。 ld或OS加载程序的目标是将该地址更改为您应在运行时跳转到的地址
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.