/* * Copyright 2002-2019 Intel Corporation. * * This software is provided to you as Sample Source Code as defined in the accompanying * End User License Agreement for the Intel(R) Software Development Products ("Agreement") * section 1.L. * * This software and the related documents are provided as is, with no express or implied * warranties, other than those that are expressly stated in the License. */ /*! @file * This tool verifies that IARG_MEMORYOP_EA of XLAT instruction has * the same value both when the XLAT has 0x67 prefix and when it doesn't. */ #include "pin.H" #include #define INVALID_EA ~static_cast(0) static BOOL xlat_analyzed_twice = FALSE; static ADDRINT last_xlat_ea = INVALID_EA; static VOID xlat_ins_analysis(ADDRINT ea) { if (last_xlat_ea == INVALID_EA) // first time analysis routine is called { last_xlat_ea = ea; return; } xlat_analyzed_twice = TRUE; if (ea != last_xlat_ea) { std::cerr << "XLAT IARG_MEMORYOP_EA values differ: 0x" << std::hex << last_xlat_ea << ", 0x" << ea << std::endl; PIN_ExitProcess(1); } } VOID Image(IMG img, VOID* v) { if (!IMG_IsMainExecutable(img)) return; for (SEC sec = IMG_SecHead(img); SEC_Valid(sec); sec = SEC_Next(sec)) { for (RTN rtn = SEC_RtnHead(sec); RTN_Valid(rtn); rtn = RTN_Next(rtn)) { RTN_Open(rtn); for (INS ins = RTN_InsHead(rtn); INS_Valid(ins); ins = INS_Next(ins)) { if (INS_Opcode(ins) == XED_ICLASS_XLAT) { for (UINT32 memOp = 0; memOp