Skip to content

Commit c799be5

Browse files
committed
Merge remote-tracking branch 'origin/GT-3374_emteere_GCCAnalysisIssues' into patch
2 parents f9dbbab + 267b6fd commit c799be5

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

Ghidra/Features/Base/src/main/java/ghidra/app/cmd/data/CreateDataCmd.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public class CreateDataCmd implements Command {
4545
/**
4646
* Constructs a command for creating data at an address.
4747
* Simple pointer conversion will NOT be performed.
48+
* Existing Undefined data will always be cleared even when force is false.
4849
* @param addr the address at which to apply the datatype. Offcut data
4950
* address allowed, provided force==true.
5051
* @param force if true any existing conflicting data will be cleared
@@ -75,7 +76,8 @@ public CreateDataCmd(Address addr, boolean force, boolean stackPointers, DataTyp
7576
/**
7677
* Constructs a command for creating data at an address.
7778
* Simple pointer conversion will NOT be performed and existing
78-
* data will not be cleared.
79+
* defined data will not be cleared, however existing Undefined data will
80+
* be cleared.
7981
* @param addr the address at which to apply the datatype.
8082
* @param dataType the datatype to be applied at the given address.
8183
*/
@@ -86,7 +88,7 @@ public CreateDataCmd(Address addr, DataType dataType) {
8688
/**
8789
* This is the same as {@link #CreateDataCmd(Address, DataType)} except that
8890
* it allows the caller to control whether or not pointer conversion should be handled.
89-
*
91+
* Existing Undefined data will always be cleared.
9092
* @param addr the address at which to apply the datatype.
9193
* @param dataType the datatype to be applied at the given address.
9294
* @param isCycle true indicates this is from a cycle group action.

Ghidra/Features/Base/src/main/java/ghidra/app/plugin/exceptionhandlers/gcc/sections/DebugFrameSection.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ private List<RegionDescriptor> analyzeSection(MemoryBlock curMemBlock)
100100
}
101101

102102
while (curAddress != null && curAddress.compareTo(curMemBlock.getEnd()) < 0) {
103+
if (monitor.isCancelled()) {
104+
return regions;
105+
}
103106

104107
/* Get the Common Information Entry */
105108
Cie cie = getCie(curAddress);

Ghidra/Features/Base/src/main/java/ghidra/app/plugin/exceptionhandlers/gcc/structures/ehFrame/FrameDescriptionEntry.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import ghidra.app.plugin.exceptionhandlers.gcc.sections.CieSource;
2525
import ghidra.app.plugin.exceptionhandlers.gcc.sections.DebugFrameSection;
2626
import ghidra.app.plugin.exceptionhandlers.gcc.structures.gccexcepttable.LSDATable;
27+
import ghidra.app.util.opinion.ElfLoader;
2728
import ghidra.program.model.address.*;
2829
import ghidra.program.model.data.*;
2930
import ghidra.program.model.listing.*;
@@ -268,7 +269,14 @@ private Address createPcBegin(Address addr, RegionDescriptor region)
268269

269270
createAndCommentData(program, addr, encodedDt, comment, CodeUnit.EOL_COMMENT);
270271
if (pcBeginAddr.getOffset() != 0x0) {
271-
pcBeginAddr = pcBeginAddr.add(program.getImageBase().getOffset());
272+
// if the program was moved from a preferred image base, need to adjust
273+
// the beginning of frame pointer
274+
Long oib = ElfLoader.getElfOriginalImageBase(program);
275+
if (oib != null) {
276+
long imageBaseOffset = program.getImageBase().getOffset() - oib;
277+
pcBeginAddr = pcBeginAddr.add(imageBaseOffset);
278+
}
279+
272280
program.getReferenceManager().addMemoryReference(addr, pcBeginAddr, RefType.DATA,
273281
SourceType.ANALYSIS, 0);
274282
}
@@ -390,7 +398,7 @@ private Address createCallFrameInstructions(Address addr) throws MemoryAccessExc
390398
CreateArrayCmd arrayCmd = null;
391399

392400
// Create initial instructions array with remaining bytes.
393-
int instructionLength = intLength - curSize;
401+
int instructionLength = intLength - curSize;
394402
ArrayDataType adt = new ArrayDataType(ByteDataType.dataType, instructionLength, BYTE_LEN);
395403
try {
396404
program.getListing().createData(addr, adt, adt.getLength());

0 commit comments

Comments
 (0)