Ghidra is a software reverse engineering (SRE) framework
GT-3374_emteere code review changes
emteere267b6fdc1c63
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/data/CreateDataCmd.java b/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/data/CreateDataCmd.javaindex 4fec00418b..e433ec74c0 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/data/CreateDataCmd.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/data/CreateDataCmd.java@@ -45,6 +45,7 @@ public class CreateDataCmd implements Command {/*** Constructs a command for creating data at an address.* Simple pointer conversion will NOT be performed.+ * Existing Undefined data will always be cleared even when force is false.* @param addr the address at which to apply the datatype. Offcut data* address allowed, provided force==true.* @param force if true any existing conflicting data will be cleared@@ -75,7 +76,8 @@ public class CreateDataCmd implements Command {/*** Constructs a command for creating data at an address.* Simple pointer conversion will NOT be performed and existing- * data will not be cleared.+ * defined data will not be cleared, however existing Undefined data will+ * be cleared.* @param addr the address at which to apply the datatype.* @param dataType the datatype to be applied at the given address.*/@@ -86,7 +88,7 @@ public class CreateDataCmd implements Command {/*** This is the same as {@link #CreateDataCmd(Address, DataType)} except that* it allows the caller to control whether or not pointer conversion should be handled.- *+ * Existing Undefined data will always be cleared.* @param addr the address at which to apply the datatype.* @param dataType the datatype to be applied at the given address.* @param isCycle true indicates this is from a cycle group action.diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/exceptionhandlers/gcc/sections/DebugFrameSection.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/exceptionhandlers/gcc/sections/DebugFrameSection.javaindex 82335f41a3..990b8d9355 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/exceptionhandlers/gcc/sections/DebugFrameSection.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/exceptionhandlers/gcc/sections/DebugFrameSection.java@@ -100,6 +100,9 @@ public class DebugFrameSection extends AbstractFrameSection {}while (curAddress != null && curAddress.compareTo(curMemBlock.getEnd()) < 0) {+ if (monitor.isCancelled()) {+ return regions;+ }/* Get the Common Information Entry */Cie cie = getCie(curAddress);diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/exceptionhandlers/gcc/structures/ehFrame/FrameDescriptionEntry.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/exceptionhandlers/gcc/structures/ehFrame/FrameDescriptionEntry.javaindex 619bce2f2a..fb4b3ab504 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/exceptionhandlers/gcc/structures/ehFrame/FrameDescriptionEntry.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/exceptionhandlers/gcc/structures/ehFrame/FrameDescriptionEntry.java@@ -24,6 +24,7 @@ import ghidra.app.plugin.exceptionhandlers.gcc.datatype.UnsignedLeb128DataType;import ghidra.app.plugin.exceptionhandlers.gcc.sections.CieSource;import ghidra.app.plugin.exceptionhandlers.gcc.sections.DebugFrameSection;import ghidra.app.plugin.exceptionhandlers.gcc.structures.gccexcepttable.LSDATable;+import ghidra.app.util.opinion.ElfLoader;import ghidra.program.model.address.*;import ghidra.program.model.data.*;import ghidra.program.model.listing.*;@@ -268,7 +269,14 @@ public class FrameDescriptionEntry extends GccAnalysisClass {createAndCommentData(program, addr, encodedDt, comment, CodeUnit.EOL_COMMENT);if (pcBeginAddr.getOffset() != 0x0) {- pcBeginAddr = pcBeginAddr.add(program.getImageBase().getOffset());+ // if the program was moved from a preferred image base, need to adjust+ // the beginning of frame pointer+ Long oib = ElfLoader.getElfOriginalImageBase(program);+ if (oib != null) {+ long imageBaseOffset = program.getImageBase().getOffset() - oib;+ pcBeginAddr = pcBeginAddr.add(imageBaseOffset);+ }+program.getReferenceManager().addMemoryReference(addr, pcBeginAddr, RefType.DATA,SourceType.ANALYSIS, 0);}@@ -390,7 +398,7 @@ public class FrameDescriptionEntry extends GccAnalysisClass {CreateArrayCmd arrayCmd = null;// Create initial instructions array with remaining bytes.- int instructionLength = intLength - curSize;+ int instructionLength = intLength - curSize;ArrayDataType adt = new ArrayDataType(ByteDataType.dataType, instructionLength, BYTE_LEN);try {program.getListing().createData(addr, adt, adt.getLength());