我尝试使用这样的mmap:
off_t offset = 0x123456789;
long pagesize = sysconf(_SC_PAGE_SIZE);
int pageoffset = offset % pagesize;
//Open file, get file descriptor
fd = open("./test", O_RDONLY);
map_main = mmap(NULL, 106 + pageoffset, PROT_READ | PROT_EXEC,
MAP_SHARED, fd, offset - pageoffset);
表现不尽如人意。
我是否正确,从特定位置读取文件? 参考:Segfault while using mmap in C for reading binary files