Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-4457: The dyld_shared_cache loader no longer throws an exception when importing newer versions that use dyld_cache_slide_info5

Ryan Kurtz2aea20140632
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheHeader.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheHeader.java
index 561cba617c..41812a6a49 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheHeader.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheHeader.java
@@ -408,7 +408,9 @@ public class DyldCacheHeader implements StructConverter {
DyldCacheSlideInfoCommon slideInfo = DyldCacheSlideInfoCommon.parseSlideInfo(reader,
info.getSlideInfoFileOffset(), info.getAddress(), info.getSize(),
info.getFileOffset(), log, monitor);
- slideInfoList.add(slideInfo);
+ if (slideInfo != null) {
+ slideInfoList.add(slideInfo);
+ }
}
}
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheSlideInfo4.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheSlideInfo4.java
index 675ca117f7..457188e667 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheSlideInfo4.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheSlideInfo4.java
@@ -113,7 +113,7 @@ public class DyldCacheSlideInfo4 extends DyldCacheSlideInfoCommon {
}
/**
- * Create a new {@link DyldCacheSlideInfo3}.
+ * Create a new {@link DyldCacheSlideInfo4}.
*
* @param reader A {@link BinaryReader} positioned at the start of a DYLD slide info 3
* @param mappingAddress The base address of where the slide fixups will take place
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheSlideInfoCommon.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheSlideInfoCommon.java
index 588d31c4f1..0cc1ee42d6 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheSlideInfoCommon.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/dyld/DyldCacheSlideInfoCommon.java
@@ -67,9 +67,11 @@ public abstract class DyldCacheSlideInfoCommon implements StructConverter {
monitor.setMessage("Parsing DYLD slide info...");
monitor.initialize(1);
+ String errorMessage = "Failed to parse dyld_cache_slide_info";
try {
reader.setPointerIndex(slideInfoOffset);
int version = reader.readInt(reader.getPointerIndex());
+ errorMessage += version;
DyldCacheSlideInfoCommon returnedSlideInfo = switch (version) {
case 1 -> new DyldCacheSlideInfo1(reader, mappingAddress, mappingSize,
mappingFileOffset);
@@ -79,15 +81,14 @@ public abstract class DyldCacheSlideInfoCommon implements StructConverter {
mappingFileOffset);
case 4 -> new DyldCacheSlideInfo4(reader, mappingAddress, mappingSize,
mappingFileOffset);
- default -> throw new IOException("Unrecognized slide info version: " + version);
+ default -> throw new IOException(); // will be caught and version will be added to message
};
monitor.incrementProgress(1);
returnedSlideInfo.slideInfoOffset = slideInfoOffset;
return returnedSlideInfo;
}
catch (IOException e) {
- log.appendMsg(DyldCacheSlideInfoCommon.class.getSimpleName(),
- "Failed to parse dyld_cache_slide_info.");
+ log.appendMsg(DyldCacheSlideInfoCommon.class.getSimpleName(), errorMessage);
return null;
}
}