mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-13 13:39:07 +08:00
GP-3194: The MachoLoader now correctly handles
DYLD_CHAINED_PTR_64_OFFSET fixups
This commit is contained in:
+13
-1
@@ -22,7 +22,7 @@ import ghidra.program.model.reloc.Relocation.Status;
|
||||
import ghidra.program.model.reloc.RelocationResult;
|
||||
|
||||
/**
|
||||
* @see <a href="https://opensource.apple.com/source/dyld/dyld-852.2/include/mach-o/fixup-chains.h.auto.html">mach-o/fixup-chains.h</a>
|
||||
* @see <a href="https://github.com/apple-oss-distributions/dyld/blob/main/include/mach-o/fixup-chains.h">mach-o/fixup-chains.h</a>
|
||||
*/
|
||||
public class DyldChainedPtr {
|
||||
|
||||
@@ -168,6 +168,18 @@ public class DyldChainedPtr {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isRelative(DyldChainType ptrFormat) {
|
||||
switch (ptrFormat) {
|
||||
case DYLD_CHAINED_PTR_64_OFFSET:
|
||||
case DYLD_CHAINED_PTR_ARM64E_KERNEL:
|
||||
case DYLD_CHAINED_PTR_ARM64E_USERLAND:
|
||||
case DYLD_CHAINED_PTR_ARM64E_USERLAND24:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isBound(DyldChainType ptrFormat, long chainValue) {
|
||||
|
||||
switch (ptrFormat) {
|
||||
|
||||
@@ -480,6 +480,8 @@ public class MachoProgramBuilder {
|
||||
}
|
||||
|
||||
protected boolean processExports(MachHeader header) throws Exception {
|
||||
monitor.setMessage("Processing exports...");
|
||||
|
||||
List<ExportEntry> exports = new ArrayList<>();
|
||||
|
||||
// Old way - export tree in DyldInfoCommand
|
||||
@@ -1794,7 +1796,9 @@ public class MachoProgramBuilder {
|
||||
}
|
||||
else {
|
||||
newChainValue = DyldChainedPtr.getTarget(pointerFormat, chainValue);
|
||||
newChainValue += imageBaseOffset;
|
||||
if (DyldChainedPtr.isRelative(pointerFormat)) {
|
||||
newChainValue += imageBaseOffset;
|
||||
}
|
||||
}
|
||||
|
||||
if (!start || !program.getRelocationTable().hasRelocation(chainLoc)) {
|
||||
|
||||
Reference in New Issue
Block a user