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 voidaddAllSections(Collection<? extends ISegmentInformation> sections) protected voidaddAllSegments(Collection<? extends ISegmentInformation> segments) protected voidaddAllSymbols(Collection<? extends ISymbolInformation> symbols) protected voidaddSection(ISegmentInformation section) protected voidaddSegment(ISegmentInformation segment) protected booleanaddSymbol(ISymbolInformation symbol) protected abstract booleanapplyRelocations(IVirtualMemory mem, long base, ILinkInfoProvider linkInfoPrv) Relocate a mapped code object.longconvertFileOffsetToRelativeAddress(long offset) Convert a file offset to a memory address, relative to the base.longconvertRelativeAddressToFileOffset(long rel) Convert a memory address (relative to the base) to a file offset.protected IVirtualMemoryCreate 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 IInputRetrieve the input that is truly mappable.Retrieve a raw mapping of the code object.getSection(int i) intList<? 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) intList<? 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.intCollection<? 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 voidinsertSection(int index, ISegmentInformation section) protected voidinsertSegment(int index, ISegmentInformation segment) booleanmap(IVirtualMemory mem, long wantedBase, boolean applyRelocations, ILinkInfoProvider linkInfoPrv) Map this object file onto virtual memory.protected booleanmapRawNoReloc(IVirtualMemory mem, long base) Map the object's segments at the provided base without applying relocations.protected voidremoveSection(int index) protected voidremoveSegment(int index) protected voidprotected abstract booleanIndicate 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, setMimeTypeMethods 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, toStringMethods inherited from class com.pnfsoftware.jeb.core.events.JebEventSource
addListener, countListeners, getListeners, getParentSource, insertListener, notifyListeners, notifyListeners, notifyListeners, removeListener, setParentSourceMethods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.pnfsoftware.jeb.core.units.IBinaryUnit
getInput, getMimeTypeMethods inherited from interface com.pnfsoftware.jeb.util.events.IEventSource
addListener, countListeners, getListeners, getParentSource, insertListener, notifyListeners, removeListener, setParentSourceMethods inherited from interface com.pnfsoftware.jeb.core.units.IUnit
addChild, addChild, canBePersisted, dispose, execprvfunc, 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, setUnitProcessorMethods 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:ICodeObjectUnitRetrieve basic information about the object file.- Specified by:
getLoaderInformationin interfaceICodeObjectUnit- Returns:
- the object file information, never null
-
setLoaderInformation
-
getSegments
Description copied from interface:ICodeObjectUnitRetrieve 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:
getSegmentsin interfaceICodeObjectUnit- Returns:
- the list of segments, or null if unsupported
-
getValidSegments
Description copied from interface:ICodeObjectUnitRetrieve the list of segments that are not marked INVALID.- Specified by:
getValidSegmentsin interfaceICodeObjectUnit- Returns:
-
getSegments
Description copied from interface:ICodeObjectUnitRetrieve a list of segments.- Specified by:
getSegmentsin interfaceICodeObjectUnit- Parameters:
wflags- must-have flagsbflags- must-not-have flags- Returns:
-
getSegment
- Specified by:
getSegmentin interfaceICodeObjectUnit- Returns:
-
getSegmentCount
public int getSegmentCount()- Specified by:
getSegmentCountin interfaceICodeObjectUnit- Returns:
-
addSegment
-
insertSegment
-
addAllSegments
-
removeSegment
protected void removeSegment(int index) -
getSections
Description copied from interface:ICodeObjectUnitRetrieve 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:
getSectionsin interfaceICodeObjectUnit- Returns:
- the list of sections, or null if unsupported
-
getValidSections
Description copied from interface:ICodeObjectUnitRetrieve the list of sections that are not marked INVALID.- Specified by:
getValidSectionsin interfaceICodeObjectUnit- Returns:
-
getSections
Description copied from interface:ICodeObjectUnitRetrieve a list of sections.- Specified by:
getSectionsin interfaceICodeObjectUnit- Parameters:
wflags- must-have flagsbflags- must-not-have flags- Returns:
-
getSection
- Specified by:
getSectionin interfaceICodeObjectUnit- Returns:
-
getSectionCount
public int getSectionCount()- Specified by:
getSectionCountin interfaceICodeObjectUnit- Returns:
-
addSection
-
insertSection
-
addAllSections
-
removeSection
protected void removeSection(int index) -
getSymbols
- Specified by:
getSymbolsin interfaceICodeObjectUnit- Returns:
-
getSymbolCount
public int getSymbolCount() -
addSymbol
-
addAllSymbols
-
getImportedSymbols
Description copied from interface:ICodeObjectUnitRetrieve the list of imported symbols.- Specified by:
getImportedSymbolsin interfaceICodeObjectUnit- Returns:
- the list (possibly empty) of imported symbols, or null if unsupported
-
getExportedSymbols
Description copied from interface:ICodeObjectUnitRetrieve the list of exported symbols.- Specified by:
getExportedSymbolsin interfaceICodeObjectUnit- Returns:
- the list (possibly empty) of exported symbols, or null if unsupported
-
getSymbols
- Specified by:
getSymbolsin interfaceICodeObjectUnit- Returns:
-
convertFileOffsetToRelativeAddress
public long convertFileOffsetToRelativeAddress(long offset) Description copied from interface:ICodeObjectUnitConvert a file offset to a memory address, relative to the base.- Specified by:
convertFileOffsetToRelativeAddressin 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:ICodeObjectUnitConvert a memory address (relative to the base) to a file offset.- Specified by:
convertRelativeAddressToFileOffsetin 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:ICodeObjectUnitRetrieve 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:
getRawMemoryMappedImagein 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:ICodeObjectUnitMap this object file onto virtual memory.- Specified by:
mapin 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:
-