From 07c9fb3f456e5388412635dd26b408be4ae6ac1b Mon Sep 17 00:00:00 2001 From: ghidra007 Date: Mon, 13 Nov 2023 17:18:43 +0000 Subject: [PATCH] GP-4035 updated to not use address.subtract to determine inst offset, which could in some cases cause an overflow error. --- .../vt/gui/actions/AutoVersionTrackingTask.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/actions/AutoVersionTrackingTask.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/actions/AutoVersionTrackingTask.java index 5e0c8e74416..732b42e4563 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/actions/AutoVersionTrackingTask.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/gui/actions/AutoVersionTrackingTask.java @@ -1224,10 +1224,14 @@ private Map> mapFunctionScalarAndAddressOperands( if (map.keySet().isEmpty()) { continue; } - + // get offset from top of function to use in function to operandMap map - Long offset = - inst.getAddress().subtract(function.getEntryPoint().getOffset()).getOffset(); + // can be positive or negative offset (positive means instruction address is after + // the entry address, negative means instruction address is before entry address) + Long entryOffset = function.getEntryPoint().getOffset(); + Long instOffset = inst.getAddress().getOffset(); + Long offset = instOffset - entryOffset; + offsetToOperandsMap.put(offset, map); }