覆盖全局变量的内存分配
我需要为每个全局对象分配一个唯一的虚拟页面。对于堆积的对象,我可以覆盖malloc/new
调用并使用mmap
适当。但是static struct {...} instance1;
之类的全局对象是由数据段中的编译器本身分配的。我该怎么做?
I need to assign a unique virtual page to each global object. For heap-allocated objects, I could override malloc/new
calls and use mmap
appropriately. But global objects like static struct {...} instance1;
are allocated memory by the compiler itself in the data segment. How could I accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将它们放在特定的部分中,并在链接脚本中分配虚拟地址。
一种更C ++ - ISH方法是使用新的位置来分配它们。
Put them in specific sections and assign them virtual addresses in the linker script.
A more c++-ish way would be to use placement new to allocate them.