我试图访问"rendezvous结构“(struct r_debug *),以便找到进程的链接映射。但我总是碰上无效的护身符我真的搞不懂到底是怎么回事。
下面是我继续努力寻找它的方法:
1. Get the AT_PHDR value from the auxiliary vector
2. Go through the program headers until I find the PT_DYNAMIC segment
3. Try to access the vaddr of that segment (PT_DYNAMIC) to get the dynamic tags
4. Iterate through the dynamic tags until I find DT_DEBUG. If I get here I should be done问题是我无法通过步骤3,因为PT_DYNAMIC段的vaddr总是指向无效地址。
我做错什么了?我需要找到船舱的搬迁处吗?我看过LLDB的消息来源,但我不知道他们是怎么得到地址的。
更新:@Employed俄语是对的,我在看一个与位置无关的可执行文件。他计算搬迁的办法效果很好。
发布于 2019-04-12 04:11:50
我做错什么了?
最有可能的情况是,您正在查看位置无关的可执行文件。如果您的readelf -Wl a.out如下所示:
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
PHDR 0x000040 0x0000000000000040 0x0000000000000040 0x0001f8 0x0001f8 R 0x8
INTERP 0x000238 0x0000000000000238 0x0000000000000238 0x00001c 0x00001c R 0x1
[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x016d28 0x016d28 R E 0x200000
LOAD 0x017250 0x0000000000217250 0x0000000000217250 0x0010d0 0x001290 RW 0x200000
DYNAMIC 0x017df8 0x0000000000217df8 0x0000000000217df8 0x0001e0 0x0001e0 RW 0x8然后,您需要通过可执行的重新定位地址(关键是第一个Phdr_pt_load.p_vaddr == 0)来调整Phdr_pt_load.p_vaddr == 0。
您可以发现这个重定位地址是aux向量中的AT_PHDR值与Phdr_pt_phdr.p_vaddr之间的增量。
(在上面,我使用Phdr_xxx作为Phdr[j]和.p_type == xxx的缩写)。
这样做的方式也要复杂得多:动态数组的地址可以作为_DYNAMIC[]使用。见this answer。
https://stackoverflow.com/questions/55643058
复制相似问题