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.Object
Builds up a Mach-OProgram
by parsing the Mach-O headers.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
BLOCK_SOURCE_NAME
protected FileBytes
fileBytes
protected Listing
listing
protected MessageLog
log
protected MachHeader
machoHeader
protected Memory
memory
protected TaskMonitor
monitor
protected Program
program
protected ByteProvider
provider
protected AddressSpace
space
-
Constructor Summary
Constructors Modifier Constructor Description protected
MachoProgramBuilder(Program program, ByteProvider provider, FileBytes fileBytes, MessageLog log, TaskMonitor monitor)
Creates a newMachoProgramBuilder
based on the given information.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
build()
static void
buildProgram(Program program, ByteProvider provider, FileBytes fileBytes, MessageLog log, TaskMonitor monitor)
Builds up a Mach-OProgram
.protected void
doRelocations()
protected void
loadExternalRelocations()
protected void
loadLocalRelocations()
protected void
loadSectionRelocations()
protected void
markupHeaders(MachHeader header, Address headerAddr)
protected void
markupSections()
protected void
processDyldInfo(boolean doClassic)
protected void
processMemoryBlocks(MachHeader header, java.lang.String source, boolean processSections, boolean allowZeroAddr)
Creates memory blocks for the given header.protected void
processProgramVars()
See crt.c from opensource.apple.comprotected void
renameObjMsgSendRtpSymbol()
protected Address
setupHeaderAddr(java.util.Collection<SegmentCommand> segments)
Sets up theMachHeader
in 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 newMachoProgramBuilder
based on the given information.- Parameters:
program
- TheProgram
to build up.provider
- TheByteProvider
that 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
- TheProgram
to build up.provider
- TheByteProvider
that 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 theMachHeader
in 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
- ACollection
ofMach-O segments
- Returns:
- The
Address
ofMachHeader
in 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()
-
-