Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-2045 Coff header changes for harvard architecture and non microsoft COFF files

emteere42f28fd67bd0
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSectionHeader.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSectionHeader.java
index 2362bb862f..243f4153d1 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSectionHeader.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/coff/CoffSectionHeader.java
@@ -400,6 +400,10 @@ public class CoffSectionHeader implements StructConverter {
public static Address getAddress(Language language, long offset, CoffSectionHeader section) {
boolean isData = section == null || section.isData();
AddressSpace space = isData ? language.getDefaultDataSpace() : language.getDefaultSpace();
+ if (offset > space.getMaxAddress().getAddressableWordOffset()) {
+ // offset too big to fit, try the opposite space, so at least the blocks will load
+ space = !isData ? language.getDefaultDataSpace() : language.getDefaultSpace();
+ }
return space.getAddress(offset * getOffsetUnitSize(language, section));
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/CoffLoader.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/CoffLoader.java
index 98c01c0c43..f216d13284 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/CoffLoader.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/CoffLoader.java
@@ -131,7 +131,7 @@ public class CoffLoader extends AbstractLibrarySupportLoader {
List<QueryResult> results =
QueryOpinionService.query(getName(), header.getMachineName(), secondary);
for (QueryResult result : results) {
- loadSpecs.add(new LoadSpec(this, header.getImageBase(true), result));
+ loadSpecs.add(new LoadSpec(this, header.getImageBase(isMicrosoftFormat()), result));
}
if (loadSpecs.isEmpty()) {
loadSpecs.add(new LoadSpec(this, header.getImageBase(false), true));