From 8d1e589ac7837a006f3e7b4ebaa10dc8a1938861 Mon Sep 17 00:00:00 2001 From: emteere <47253321+emteere@users.noreply.github.com> Date: Wed, 17 Apr 2019 13:24:52 -0400 Subject: [PATCH] GT-2730_emteere Fix for languages lacking a setting for the PC register in the .pspec file --- .../java/ghidra/app/cmd/function/CreateThunkFunctionCmd.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/CreateThunkFunctionCmd.java b/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/CreateThunkFunctionCmd.java index 9986088ee7..ed92fbfb7d 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/CreateThunkFunctionCmd.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/CreateThunkFunctionCmd.java @@ -679,8 +679,11 @@ public class CreateThunkFunctionCmd extends BackgroundCommand { flowType.equals(RefType.CALL_TERMINATOR)) && !flowType.isConditional()) { // program counter should be assumed to be used + // assume PC is used when considering registers that have been set Register PC = program.getLanguage().getProgramCounter(); - usedRegisters.add(new Varnode(PC.getAddress(), PC.getMinimumByteSize())); + if (PC != null) { + usedRegisters.add(new Varnode(PC.getAddress(), PC.getMinimumByteSize())); + } setRegisters.removeAll(usedRegisters); // check that the setRegisters are all hidden, meaning don't care.