Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-2071: More Mach-O refactoring

Ryan Kurtzcb4b30994291
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/Section.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/Section.java
index 3d523ff733..52a30f5677 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/Section.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/Section.java
@@ -169,6 +169,10 @@ public class Section implements StructConverter {
}
public long getAddress() {
+ // Mask off possible chained fixup found in kernelcache section addresses
+ if ((addr & 0xfff000000000L) == 0xfff000000000L) {
+ return addr | 0xffff000000000000L;
+ }
return addr;
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/SegmentCommand.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/SegmentCommand.java
index 4579ab9e72..a5e5e98896 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/SegmentCommand.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/macho/commands/SegmentCommand.java
@@ -105,6 +105,10 @@ public class SegmentCommand extends LoadCommand {
}
public long getVMaddress() {
+ // Mask off possible chained fixup found in kernelcache segment addresses
+ if ((vmaddr & 0xfff000000000L) == 0xfff000000000L) {
+ return vmaddr | 0xffff000000000000L;
+ }
return vmaddr;
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MachoProgramBuilder.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MachoProgramBuilder.java
index d8c32cefff..693b791f23 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MachoProgramBuilder.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MachoProgramBuilder.java
@@ -334,12 +334,6 @@ public class MachoProgramBuilder {
long dataLength, String comment, String source, boolean r, boolean w, boolean x,
boolean zeroFill) throws Exception {
- // iOS 12 chained pointer address fixup (does not apply to x86)
- if (!program.getLanguageID().getIdAsString().startsWith("x86") &&
- (start.getOffset() & 0xfff000000000L) != 0) {
- start = space.getAddress(start.getOffset() | 0xffff000000000000L);
- }
-
// Get a list of all blocks that intersect with the block we wish to create. There may be
// more that one if the containing memory has both initialized and uninitialized pieces.
List<MemoryBlock> intersectingBlocks = new ArrayList<>();