如何在地址范围>中分配4 GiB [英] How to malloc in address range > 4 GiB

查看:51
本文介绍了如何在地址范围>中分配4 GiB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在X86_64 Linux上进行一些测试,并且我想知道如何make malloc() 分配大于 4 GiB 范围内的返回地址

I am trying to do some tests on X86_64 Linux, and I want to know how to make malloc() allocate return addresses in the range higher than 4 GiB

我是否必须使用单独的/自定义库覆盖malloc还是有其他简单的方法可以做到这一点?

Do I have to override malloc with a separate/custom library or is there any other simple way to do this?

谢谢.

----编辑----

----Edit----

我感兴趣的是作为( uintptr_t )的地址它的虚拟还是物理地址都没有关系,因为所有我要的是地址必须是大于4GiB的

What I am interested is in the address when taken as value (uintptr_t) and it does not matter whether its virtual or physical address, because, all that I want is the address must be a value greater than 4GiB

在Linux x86_64

I am using gcc (4.2.1) with -m64, on Linux x86_64

(希望我把问题弄清楚了)

(hope I made the question clear)

推荐答案

malloc()是错误的工具.您想要 mmap() /dev/zero (这就是 malloc()在现代 glibc ),IIRC.(在Unix上.我相信Win32也有类似的API,但我不能告诉你它是什么.)

malloc() is the wrong tool. You want to mmap() /dev/zero (which is what malloc() is doing behind the scenes in modern glibc), IIRC. (On Unix. I believe there is a similar API for Win32, but I couldn't tell you what it is.)

这篇关于如何在地址范围>中分配4 GiB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆