From e01047372e5ddc9573c02a10c828c2ffc569f1d3 Mon Sep 17 00:00:00 2001 From: Yossi Itigin Date: Fri, 6 Aug 2021 01:56:53 +0300 Subject: [PATCH] UCM/BISTRO: Parse libcuda debug hooks --- src/ucm/bistro/bistro_x86_64.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ucm/bistro/bistro_x86_64.c b/src/ucm/bistro/bistro_x86_64.c index 5b0f7ace0f6..6dd6fc36d60 100644 --- a/src/ucm/bistro/bistro_x86_64.c +++ b/src/ucm/bistro/bistro_x86_64.c @@ -83,6 +83,9 @@ typedef struct { /* ModR/M encoding for EBP/BP/CH/MM5/XMM5, AH/SP/ESP/MM4/XMM4 */ #define UCM_BISTRO_X86_MODRM_BP_SP 0xE5 /* 11 100 101 */ +/* ModR/M encoding for CMP [RIP+x], Imm32 */ +#define UCM_BISTRO_X86_MODRM_CMP_RIP 0x3D /* 11 111 101 */ + /* * Find the minimal length of initial instructions in the function which can be @@ -144,6 +147,12 @@ static size_t ucm_bistro_detect_pic_prefix(const void *func, size_t min_length) ((opcode & UCM_BISTRO_X86_MOV_IR_MASK) == UCM_BISTRO_X86_MOV_IR)) { offset += sizeof(uint32_t); continue; + } else if ((rex == 0) && (opcode == UCM_BISTRO_X86_IMM_GRP1_EV_IZ)) { + modrm = *(uint8_t*)UCS_PTR_BYTE_OFFSET(func, offset++); + if (modrm == UCM_BISTRO_X86_MODRM_CMP_RIP) { + offset += sizeof(uint32_t) * 2; /* skip disp32 and imm32 */ + } + continue; } /* unsupported instruction - bail */