在Linux用户空间进程中,vsyscall页面的地址是什么?
我想获取 vsyscall 页面的地址供我自己使用。我这里只有两个想法:改变编译器以在将这些信息提供给 __start 后将其存储在某个已知位置,或者读取 /proc/[pid]/maps。我真的不想读取 /proc/ 因为这很慢并且没有必要。我也不想进行编译器修改。有人有替代方案吗?有什么我应该知道的符号吗?
此时我很想将此功能填充到我作为这项工作的一部分开发的模块中的 ioctl 调用中!
I would like to acquire the address of the vsyscall page for my own uses. I only have two ideas here: alter the compiler to store this information in some known location after it is given to __start, or read /proc/[pid]/maps. I really don't want to read /proc/ as that is slow and shouldn't be necessary. I also don't want to make compiler modifications. Does anyone have an alternative? Is there a symbol I should know about?
Its at the point I'm tempted to stuff this functionality into an ioctl call in a module I've developed as part of this work!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个黑暗中的刺探:
如果您可以确定进程堆栈从哪个地址开始,那么您可能会找到提供给
__start
的参数。然后,您可以通过设置为距初始堆栈指针相应偏移量的适当类型的指针来访问参数。根据文章如何在 Linux 上执行 main(),作者:Hyouck "Hawk" Kim< /a>,
__start
的前几条指令将在调用__libc_start_main
之前以确定性的方式写入初始参数。显然,任何类似的方法都是特定于平台的,并且如果
__start
的实现发生更改,就会不稳定。Here is a stab in the dark:
If you can determine at what address the process stack began, then you can possibly find the parameters which were provided to
__start
. You might then access the parameters via pointers of the appropriate type set to the corresponding offsets from the initial stack pointer.According to the article How main() is executed on Linux , by Hyouck "Hawk" Kim, the first few instructions of
__start
will write the initial arguments in a deterministic way before calling__libc_start_main
.Obviously any approach like this is platform-specific and subject to instability if the implementation of
__start
were changed.