+#include <stdio.h> +#include <errno.h> +#include <sys/mman.h> + uint64_t myAddress_ = (uint64_t)(buf)+536; + uint64_t start_address = (myAddress_ >> PAGE_SHIFT) << PAGE_SHIFT; + if (mprotect((void*)start_address, PAGE_SIZE, PROT_READ) == -1) { + fprintf(stderr,"liyl add line[%d] buf= %p err=%s",__LINE__,buf,strerror(errno)); + } #if 0 int retValue = posix_memalign(&protectBuf, pagesize, pagesize*1000*10); if(retValue != 0 ) { LOG(E, "protectBuf is posix_memalign failed (%d)",retValue); } if(mprotect(protectBuf, pagesize*1000*10, PROT_READ) == -1) { LOG(E, "mprotect 1 strerr = %s",strerror(errno)); 4_ } #else protectBuf = (char*)malloc(pagesize*1000*51); if(protectBuf == NULL) { return; } uint64_t myAddress = (uint64_t)(protectBuf); uint64_t start_Address = myAddress - (myAddress & (pagesize-1)); LOG(E, "protectBuf (%p) start_Address %p",protectBuf,(char*)start_Address); fprintf(stderr, "protectBuf (%p) start_Address %p",protectBuf,(char*)start_Address); if(mprotect((char*)start_Address, pagesize*1000*50, PROT_READ) == -1) { LOG(E, "mprotect 1 strerr = %s",strerror(errno)); } #endif