gpt4 book ai didi

c - .text section address range of position independent executable

转载 作者:太空狗 更新时间:2023-10-29 12:13:00 24 4
gpt4 key购买 nike

我想要一个与位置无关的可执行文件的 .text 部分的地址。使用 readelf -S:

Name              Type             Address           Offset
Size EntSize Flags Link Info Align
.text PROGBITS 0000000000002700 00002700
0000000000001672 0000000000000000 AX 0 0 16

我了解到它将在库加载到内存后的 0x2700 字节处开始。但是我怎样才能得到可执行文件的加载地址呢?有没有其他方法可以在运行时(从正在运行的程序)获取 .text 节地址范围?

最佳答案

Is there any other way to get the .text section address range during runtime (from the running program)?

是的:你需要使用 dl_iterate_phdr并使用 info->dlpi_addr 在运行时在内存中定位 PIE 二进制文件。对您的 callback 的第一次调用将针对主可执行文件。

关于c - .text section address range of position independent executable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35434257/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com