Package ghidra.app.util.opinion
Class MachoProgramBuilder
- java.lang.Object
-
- ghidra.app.util.opinion.MachoProgramBuilder
-
- Direct Known Subclasses:
DyldCacheProgramBuilder,MachoPrelinkProgramBuilder
public class MachoProgramBuilder extends java.lang.ObjectBuilds up a Mach-OProgramby parsing the Mach-O headers.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringBLOCK_SOURCE_NAMEprotected FileBytesfileBytesprotected Listinglistingprotected MessageLoglogprotected MachHeadermachoHeaderprotected Memorymemoryprotected TaskMonitormonitorprotected Programprogramprotected ByteProviderproviderprotected AddressSpacespace
-
Constructor Summary
Constructors Modifier Constructor Description protectedMachoProgramBuilder(Program program, ByteProvider provider, FileBytes fileBytes, MessageLog log, TaskMonitor monitor)Creates a newMachoProgramBuilderbased on the given information.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbuild()static voidbuildProgram(Program program, ByteProvider provider, FileBytes fileBytes, MessageLog log, TaskMonitor monitor)Builds up a Mach-OProgram.protected voiddoRelocations()protected voidloadExternalRelocations()protected voidloadLocalRelocations()protected voidloadSectionRelocations()protected voidmarkupHeaders(MachHeader header, Address headerAddr)protected voidmarkupSections()protected voidprocessDyldInfo(boolean doClassic)protected voidprocessMemoryBlocks(MachHeader header, java.lang.String source, boolean processSections, boolean allowZeroAddr)Creates memory blocks for the given header.protected voidprocessProgramVars()See crt.c from opensource.apple.comprotected voidrenameObjMsgSendRtpSymbol()protected AddresssetupHeaderAddr(java.util.Collection<SegmentCommand> segments)Sets up theMachHeaderin memory and returns its address.
-
-
-
Field Detail
-
BLOCK_SOURCE_NAME
public static final java.lang.String BLOCK_SOURCE_NAME
- See Also:
- Constant Field Values
-
machoHeader
protected MachHeader machoHeader
-
program
protected Program program
-
provider
protected ByteProvider provider
-
fileBytes
protected FileBytes fileBytes
-
log
protected MessageLog log
-
monitor
protected TaskMonitor monitor
-
memory
protected Memory memory
-
listing
protected Listing listing
-
space
protected AddressSpace space
-
-
Constructor Detail
-
MachoProgramBuilder
protected MachoProgramBuilder(Program program, ByteProvider provider, FileBytes fileBytes, MessageLog log, TaskMonitor monitor)
Creates a newMachoProgramBuilderbased on the given information.- Parameters:
program- TheProgramto build up.provider- TheByteProviderthat contains the Mach-O's bytes.fileBytes- Where the Mach-O's bytes came from.log- The log.monitor- A cancelable task monitor.
-
-
Method Detail
-
buildProgram
public static void buildProgram(Program program, ByteProvider provider, FileBytes fileBytes, MessageLog log, TaskMonitor monitor) throws java.lang.Exception
Builds up a Mach-OProgram.- Parameters:
program- TheProgramto build up.provider- TheByteProviderthat contains the Mach-O's bytes.fileBytes- Where the Mach-O's bytes came from.log- The log.monitor- A cancelable task monitor.- Throws:
java.lang.Exception- if a problem occurs.
-
build
protected void build() throws java.lang.Exception- Throws:
java.lang.Exception
-
doRelocations
protected void doRelocations() throws java.lang.Exception- Throws:
java.lang.Exception
-
processMemoryBlocks
protected void processMemoryBlocks(MachHeader header, java.lang.String source, boolean processSections, boolean allowZeroAddr) throws java.lang.Exception
Creates memory blocks for the given header.- Parameters:
header- The Mach-O header to process for memory block creation.source- A name that represents where the memory blocks came from.processSections- True to split segments into their sections.allowZeroAddr- True if memory blocks at address 0 should be processed; otherwise, false.- Throws:
java.lang.Exception- If there was a problem processing the memory blocks.
-
renameObjMsgSendRtpSymbol
protected void renameObjMsgSendRtpSymbol() throws DuplicateNameException, InvalidInputException
-
processDyldInfo
protected void processDyldInfo(boolean doClassic)
-
markupHeaders
protected void markupHeaders(MachHeader header, Address headerAddr) throws java.lang.Exception
- Throws:
java.lang.Exception
-
setupHeaderAddr
protected Address setupHeaderAddr(java.util.Collection<SegmentCommand> segments) throws AddressOverflowException
Sets up theMachHeaderin memory and returns its address. If the header was not intended to reside in memory (like for Mach-O object files}, then this method will create an area in the "OTHER" address space for the header to live in.- Parameters:
segments- ACollectionofMach-O segments- Returns:
- The
AddressofMachHeaderin memory - Throws:
AddressOverflowException
-
markupSections
protected void markupSections() throws java.lang.Exception- Throws:
java.lang.Exception
-
processProgramVars
protected void processProgramVars()
See crt.c from opensource.apple.com
-
loadSectionRelocations
protected void loadSectionRelocations()
-
loadExternalRelocations
protected void loadExternalRelocations()
-
loadLocalRelocations
protected void loadLocalRelocations()
-
-