Fix bug when calling xsavec instruction
There is an existing patch for the xsave instruction, but I came across an executable that fails with an xsavec instruction.
This fixes that.
@@ -193,9 +193,9 @@ static inline void mmap_close(MMAPFILE fd) {
close(fd);
}
static void *mmap_map(MMAPFILE fd, size_t size, size_t offset = 0) {
- USIZE thesize=0;
- OS_FileSizeFD(fd,&thesize);
- if(static_cast<size_t>(thesize) < offset+size)
+ struct stat st;
+ fstat(fd, &st);
+ if(static_cast<size_t>(st.st_size) < offset+size)
ftruncate(fd, offset+size);
void *ret = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset);
@@ -442,7 +442,7 @@ public:
#ifndef TARGET_WINDOWS
void fork_before(THREADID tid) {
PIN_GetLock(&lock, 0);
- // sync(); // commented out to be compatible with later PIN versions. Seems to work...
+ sync();
// TODO: Close all files, reopen later
// I think this is only required for the current tid's data structure.
}
@@ -651,6 +651,12 @@ VOID Instruction(INS ins, VOID *v) {
return;
}
+ if(INS_Mnemonic(ins) == "XSAVEC") {
+ // Avoids "Cannot use IARG_MEMORYWRITE_SIZE on non-standard memory access of instruction at 0xfoo: xsavec ptr [rsp]"
+ // TODO: Bitch at the PIN folks.
+ return;
+ }
+
for(UINT32 i = 0; i < memOps; i++) {
if(!filtered && INS_MemoryOperandIsRead(ins, i)) {
INS_InsertPredicatedCall(
