Class AbstractCodeObjectUnit
java.lang.Object
com.pnfsoftware.jeb.core.events.JebEventSource
com.pnfsoftware.jeb.core.units.AbstractUnit
com.pnfsoftware.jeb.core.units.AbstractBinaryUnit
com.pnfsoftware.jeb.core.units.codeobject.AbstractCodeObjectUnit
- All Implemented Interfaces:
IUnitCreator
,IUserDataSupport
,ICodeObjectUnit
,IBinaryUnit
,IUnit
,IEventSource
@Ser
public abstract class AbstractCodeObjectUnit
extends AbstractBinaryUnit
implements ICodeObjectUnit
Convenient base class for code objects.
-
Field Summary
Fields inherited from class com.pnfsoftware.jeb.core.events.JebEventSource
onEventCallCount
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractCodeObjectUnit
(IInput input, String formatType, String name, IUnitProcessor unitProcessor, IUnitCreator parent, IPropertyDefinitionManager pdm) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addAllSections
(Collection<? extends ISegmentInformation> sections) protected void
addAllSegments
(Collection<? extends ISegmentInformation> segments) protected void
addAllSymbols
(Collection<? extends ISymbolInformation> symbols) protected void
addSection
(ISegmentInformation section) protected void
addSegment
(ISegmentInformation segment) protected boolean
addSymbol
(ISymbolInformation symbol) protected abstract boolean
applyRelocations
(IVirtualMemory mem, long base, ILinkInfoProvider linkInfoPrv) Relocate a mapped code object.long
convertFileOffsetToRelativeAddress
(long offset) Convert a file offset to a memory address, relative to the base.long
convertRelativeAddressToFileOffset
(long rel) Convert a memory address (relative to the base) to a file offset.protected IVirtualMemory
Create a virtual memory suitable to map this code object.List<? extends ISymbolInformation>
Retrieve the list of exported symbols.List<? extends ISymbolInformation>
Retrieve the list of imported symbols.Retrieve basic information about the object file.protected IInput
Retrieve the input that is truly mappable.Retrieve a raw mapping of the code object.getSection
(int i) int
List<? extends ISegmentInformation>
Retrieve the list of sections defined in the object file.List<? extends ISegmentInformation>
getSections
(int wflags, int bflags) Retrieve a list of sections.getSegment
(int i) int
List<? extends ISegmentInformation>
Retrieve the list of segments defined in the object file.List<? extends ISegmentInformation>
getSegments
(int wflags, int bflags) Retrieve a list of segments.int
Collection<? extends ISymbolInformation>
List<? extends ISymbolInformation>
getSymbols
(int mustHaveFlags, int mustNotHaveFlags) List<? extends ISegmentInformation>
Retrieve the list of sections that are not marked INVALID.List<? extends ISegmentInformation>
Retrieve the list of segments that are not marked INVALID.protected void
insertSection
(int index, ISegmentInformation section) protected void
insertSegment
(int index, ISegmentInformation segment) boolean
map
(IVirtualMemory mem, long wantedBase, boolean applyRelocations, ILinkInfoProvider linkInfoPrv) Map this object file onto virtual memory.protected boolean
mapRawNoReloc
(IVirtualMemory mem, long base) Map the object's segments at the provided base without applying relocations.protected void
removeSection
(int index) protected void
removeSegment
(int index) protected void
protected abstract boolean
Indicate whether the loader should allocate the full image range when preparing to load and map a code object file to memory.Methods inherited from class com.pnfsoftware.jeb.core.units.AbstractBinaryUnit
getInput, getMimeType, setInput, setMimeType
Methods inherited from class com.pnfsoftware.jeb.core.units.AbstractUnit
addChild, addChild, addChild, addNotification, canBePersisted, clearAllData, dispose, finalize, generateQuickState, getAllData, getChildren, getContributions, getCreationTimestamp, getData, getDescription, getFormatter, getFormatType, getIconData, getInterpreters, getLock, getName, getNotes, getNotificationManager, getParent, getPropertyDefinitionManager, getPropertyManager, getRealName, getStatus, getUid, getUnitProcessor, hasChildren, initializePropertyObjects, internalSwapChildren, isDeserialized, isDisposed, isProcessed, isStale, isTransientChild, logError, logException, logInfo, logTrace, logWarn, onPropertyChange, postDeserialization, process, processInternal, removeChild, removeChild, setChild, setChild, setData, setName, setNotes, setParent, setProcessed, setProcessed, setRealName, setStatus, setStatus, setUnitProcessor, toString
Methods inherited from class com.pnfsoftware.jeb.core.events.JebEventSource
addListener, countListeners, getListeners, getParentSource, insertListener, notifyListeners, notifyListeners, notifyListeners, removeListener, setParentSource
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.pnfsoftware.jeb.core.units.IBinaryUnit
getInput, getMimeType
Methods inherited from interface com.pnfsoftware.jeb.util.events.IEventSource
addListener, countListeners, getListeners, getParentSource, insertListener, notifyListeners, removeListener, setParentSource
Methods inherited from interface com.pnfsoftware.jeb.core.units.IUnit
addChild, addChild, canBePersisted, dispose, generateQuickState, getChildren, getContributions, getCreationTimestamp, getDescription, getExtraInputs, getFormatter, getFormatType, getIconData, getInterpreters, getLock, getName, getNotes, getNotificationManager, getParent, getParentArtifact, getParentProject, getPropertyDefinitionManager, getPropertyManager, getRealName, getStatus, getUid, getUnitProcessor, initializePropertyObjects, isDisposed, isProcessed, isStale, isTransientChild, notifyGenericChange, postDeserialization, process, removeChild, setName, setNotes, setParent, setRealName, setUnitProcessor
Methods inherited from interface com.pnfsoftware.jeb.core.IUserDataSupport
clearAllData, getAllData, getData, setData
-
Constructor Details
-
AbstractCodeObjectUnit
public AbstractCodeObjectUnit(IInput input, String formatType, String name, IUnitProcessor unitProcessor, IUnitCreator parent, IPropertyDefinitionManager pdm)
-
-
Method Details
-
getLoaderInformation
Description copied from interface:ICodeObjectUnit
Retrieve basic information about the object file.- Specified by:
getLoaderInformation
in interfaceICodeObjectUnit
- Returns:
- the object file information, never null
-
setLoaderInformation
-
getSegments
Description copied from interface:ICodeObjectUnit
Retrieve the list of segments defined in the object file. Typically, segments are mapped to memory by a code object loader. Segments and sections may overlap.- Specified by:
getSegments
in interfaceICodeObjectUnit
- Returns:
- the list of segments, or null if unsupported
-
getValidSegments
Description copied from interface:ICodeObjectUnit
Retrieve the list of segments that are not marked INVALID.- Specified by:
getValidSegments
in interfaceICodeObjectUnit
- Returns:
-
getSegments
Description copied from interface:ICodeObjectUnit
Retrieve a list of segments.- Specified by:
getSegments
in interfaceICodeObjectUnit
- Parameters:
wflags
- must-have flagsbflags
- must-not-have flags- Returns:
-
getSegment
- Specified by:
getSegment
in interfaceICodeObjectUnit
- Returns:
-
getSegmentCount
public int getSegmentCount()- Specified by:
getSegmentCount
in interfaceICodeObjectUnit
- Returns:
-
addSegment
-
insertSegment
-
addAllSegments
-
removeSegment
protected void removeSegment(int index) -
getSections
Description copied from interface:ICodeObjectUnit
Retrieve the list of sections defined in the object file. Typically, sections are used to point to areas of interest. Sections and segments may overlap.- Specified by:
getSections
in interfaceICodeObjectUnit
- Returns:
- the list of sections, or null if unsupported
-
getValidSections
Description copied from interface:ICodeObjectUnit
Retrieve the list of sections that are not marked INVALID.- Specified by:
getValidSections
in interfaceICodeObjectUnit
- Returns:
-
getSections
Description copied from interface:ICodeObjectUnit
Retrieve a list of sections.- Specified by:
getSections
in interfaceICodeObjectUnit
- Parameters:
wflags
- must-have flagsbflags
- must-not-have flags- Returns:
-
getSection
- Specified by:
getSection
in interfaceICodeObjectUnit
- Returns:
-
getSectionCount
public int getSectionCount()- Specified by:
getSectionCount
in interfaceICodeObjectUnit
- Returns:
-
addSection
-
insertSection
-
addAllSections
-
removeSection
protected void removeSection(int index) -
getSymbols
- Specified by:
getSymbols
in interfaceICodeObjectUnit
- Returns:
-
getSymbolCount
public int getSymbolCount() -
addSymbol
-
addAllSymbols
-
getImportedSymbols
Description copied from interface:ICodeObjectUnit
Retrieve the list of imported symbols.- Specified by:
getImportedSymbols
in interfaceICodeObjectUnit
- Returns:
- the list (possibly empty) of imported symbols, or null if unsupported
-
getExportedSymbols
Description copied from interface:ICodeObjectUnit
Retrieve the list of exported symbols.- Specified by:
getExportedSymbols
in interfaceICodeObjectUnit
- Returns:
- the list (possibly empty) of exported symbols, or null if unsupported
-
getSymbols
- Specified by:
getSymbols
in interfaceICodeObjectUnit
- Returns:
-
convertFileOffsetToRelativeAddress
public long convertFileOffsetToRelativeAddress(long offset) Description copied from interface:ICodeObjectUnit
Convert a file offset to a memory address, relative to the base.- Specified by:
convertFileOffsetToRelativeAddress
in interfaceICodeObjectUnit
- Parameters:
offset
- a file offset- Returns:
- a base-relative memory address, or -1 if unsupported or if the offset does not map to anywhere in memory
-
convertRelativeAddressToFileOffset
public long convertRelativeAddressToFileOffset(long rel) Description copied from interface:ICodeObjectUnit
Convert a memory address (relative to the base) to a file offset.- Specified by:
convertRelativeAddressToFileOffset
in interfaceICodeObjectUnit
- Parameters:
rel
- the base-relative memory address- Returns:
- a file offset, or -1 if unsupported or if the address does not map to anywhere in the file
-
getRawMemoryMappedImage
Description copied from interface:ICodeObjectUnit
Retrieve a raw mapping of the code object. No relocations are applied. Do not attempt to modify the returned VM object; it should be considered read-only.- Specified by:
getRawMemoryMappedImage
in interfaceICodeObjectUnit
- Returns:
- the virtual memory containing the mapped, unresolved code object; null on error or if the code object unit decided to not map the object file
-
map
public boolean map(IVirtualMemory mem, long wantedBase, boolean applyRelocations, ILinkInfoProvider linkInfoPrv) Description copied from interface:ICodeObjectUnit
Map this object file onto virtual memory.- Specified by:
map
in interfaceICodeObjectUnit
- Parameters:
mem
- memory image onto which the mapping should be donewantedBase
- wanted base; set to -1L to request mapping at the normal baselinkInfoPrv
- optional- Returns:
- success indicator
-
createSuitableMemory
Create a virtual memory suitable to map this code object.- Returns:
-
mapRawNoReloc
Map the object's segments at the provided base without applying relocations.- Parameters:
mem
-base
-- Returns:
- the VM, null on error
-
getMappableInput
Retrieve the input that is truly mappable. The default implementation simply returnsAbstractBinaryUnit.getInput()
, as is expected in most cases (eg, ELF, PE). For formats requiring pre-processing of the input data, such as IHEX or other ascii-encoded code objects, this method should be overridden.- Returns:
-
shouldAllocateFullImage
protected abstract boolean shouldAllocateFullImage()Indicate whether the loader should allocate the full image range when preparing to load and map a code object file to memory.Typically, the answer is yes for PE-like files, no for ELF-like files.
- Returns:
-
applyRelocations
protected abstract boolean applyRelocations(IVirtualMemory mem, long base, ILinkInfoProvider linkInfoPrv) Relocate a mapped code object.- Parameters:
mem
- virtual memorybase
- mapping base addresslinkInfoPrv
- optional- Returns:
-