Skip to content

Commit

Permalink
Merge pull request capstone-engine#2019 from imbillow/tricore-fix-disp
Browse files Browse the repository at this point in the history
  • Loading branch information
kabeor authored May 16, 2023
2 parents 7a3dc32 + 681dd11 commit 798f814
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -755,15 +755,16 @@ if(CAPSTONE_BUILD_CSTOOL)
endif()

if(CAPSTONE_BUILD_CSTEST)
find_package(CMOCKA)
find_package(PkgConfig REQUIRED)
pkg_check_modules(CMOCKA REQUIRED IMPORTED_TARGET cmocka)

file(GLOB CSTEST_SRC suite/cstest/src/*.c)
add_executable(cstest ${CSTEST_SRC})
target_link_libraries(cstest PUBLIC capstone ${CMOCKA_LIBRARIES})
target_link_libraries(cstest PUBLIC capstone PkgConfig::CMOCKA)
target_include_directories(cstest PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
${PROJECT_SOURCE_DIR}/suite/cstest/include
${CMOCKA_INCLUDE_DIR}
${CMOCKA_INCLUDE_DIRS}
)

if(CAPSTONE_INSTALL)
Expand Down
24 changes: 4 additions & 20 deletions arch/TriCore/TriCoreInstPrinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,22 +285,6 @@ static void printOff18Imm(MCInst *MI, int OpNum, SStream *O)
printOperand(MI, OpNum, O);
}

static inline void fixup_tricore_disp(MCInst *MI, int OpNum, int32_t disp)
{
if (MI->csh->detail != CS_OPT_ON)
return;

cs_tricore *tricore = &MI->flat_insn->detail->tricore;
if (OpNum <= 0) {
fill_tricore_imm(MI, disp);
return;
}

if (tricore->operands[tricore->op_count - 1].type != TRICORE_OP_REG)
return;
fill_mem(tricore, tricore->operands[tricore->op_count - 1].reg, disp);
}

static void printDisp24Imm(MCInst *MI, int OpNum, SStream *O)
{
MCOperand *MO = MCInst_getOperand(MI, OpNum);
Expand All @@ -327,7 +311,7 @@ static void printDisp24Imm(MCInst *MI, int OpNum, SStream *O)
}

printUInt32(O, disp);
fixup_tricore_disp(MI, OpNum, disp);
fill_tricore_imm(MI, disp);
} else
printOperand(MI, OpNum, O);
}
Expand Down Expand Up @@ -372,7 +356,7 @@ static void printDisp15Imm(MCInst *MI, int OpNum, SStream *O)
}

printUInt32(O, disp);
fixup_tricore_disp(MI, OpNum, disp);
fill_tricore_imm(MI, disp);
} else
printOperand(MI, OpNum, O);
}
Expand All @@ -397,7 +381,7 @@ static void printDisp8Imm(MCInst *MI, int OpNum, SStream *O)
}

printUInt32(O, disp);
fixup_tricore_disp(MI, OpNum, disp);
fill_tricore_imm(MI, disp);
} else
printOperand(MI, OpNum, O);
}
Expand Down Expand Up @@ -442,7 +426,7 @@ static void printDisp4Imm(MCInst *MI, int OpNum, SStream *O)
}

printUInt32(O, disp);
fixup_tricore_disp(MI, OpNum, disp);
fill_tricore_imm(MI, disp);
} else
printOperand(MI, OpNum, O);
}
Expand Down

0 comments on commit 798f814

Please sign in to comment.