如果我将页面映射为只写:
int* mem_location = (int*)mmap(nullptr, getpagesize(),
PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
cout << "Read @" << mem_location << ". This should segfault: "
<< *mem_location << endl;
cout << "doesn't though??" << endl;
为什么阅读时没有段错误?
最佳答案
参见man page:
您不应该依赖此行为。
关于c++ - 页面映射写只允许读取,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22840898/