Interface ICodeObjectUnit
- All Superinterfaces:
IBinaryUnit,IEventSource,IUnit,IUnitCreator,IUserDataSupport
- All Known Subinterfaces:
IELFUnit,IPECOFFUnit,IS7Unit
- All Known Implementing Classes:
AbstractCodeObjectUnit
A common interface for object files that hold machine code such as ELF, PE, or Mach-O.
Code objects are used to store program information, data, and code, at various stages of the program's life - compilation, linkage, execution. Popular loaders include Linux ELF, Microsoft PE/COFF, and Apple Mach-O.
This interface provides a unified representation for such files. Clients (such as the official RCP client) should be aware of this interface and use it to display additional details about the unit - without the unit implementor having to generate documents (although documents may be generated to represent unit-specific bits of data).
All methods return values are "optional".
-
Method Summary
Modifier and TypeMethodDescriptionlongconvertFileOffsetToRelativeAddress(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.Collection<? extends ISymbolInformation> Retrieve the list of exported symbols.Collection<? extends ISymbolInformation> Retrieve the list of imported symbols.Retrieve basic information about the object file.Retrieve a raw mapping of the code object.getSection(int i) Retrieve a section by index.intRetrieve the number of sections.Collection<? extends ISegmentInformation> Retrieve the list of sections defined in the object file.Collection<? extends ISegmentInformation> getSections(int wflags, int bflags) Retrieve a list of sections.getSegment(int i) Retrieve a segment by index.intRetrieve the number of segments.Collection<? extends ISegmentInformation> Retrieve the list of segments defined in the object file.Collection<? extends ISegmentInformation> getSegments(int wflags, int bflags) Retrieve a list of segments.Collection<? extends ISymbolInformation> Retrieve the symbols defined in the object file.Collection<? extends ISymbolInformation> getSymbols(int mustHaveFlags, int mustNotHaveFlags) Retrieve symbols filtered by flags.Collection<? extends ISegmentInformation> Retrieve the list of sections that are not marked INVALID.Collection<? extends ISegmentInformation> Retrieve the list of segments that are not marked INVALID.booleanmap(IVirtualMemory mem, long wantedBase, boolean applyRelocations, ILinkInfoProvider linkInfoPrv) Map this object file onto virtual memory.Methods 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
-
Method Details
-
getLoaderInformation
ILoaderInformation getLoaderInformation()Retrieve basic information about the object file.- Returns:
- the object file information, never null
-
getSegments
Collection<? extends ISegmentInformation> getSegments()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.- Returns:
- the list of segments, or null if unsupported
-
getValidSegments
Collection<? extends ISegmentInformation> getValidSegments()Retrieve the list of segments that are not marked INVALID.- Returns:
- the valid segments, or null if unsupported
-
getSegments
Retrieve a list of segments.- Parameters:
wflags- must-have flagsbflags- must-not-have flags- Returns:
- the matching segments, or null if unsupported
-
getSegment
Retrieve a segment by index.- Parameters:
i- segment index- Returns:
- the segment
-
getSegmentCount
int getSegmentCount()Retrieve the number of segments.- Returns:
- segment count
-
getSections
Collection<? extends ISegmentInformation> getSections()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.- Returns:
- the list of sections, or null if unsupported
-
getValidSections
Collection<? extends ISegmentInformation> getValidSections()Retrieve the list of sections that are not marked INVALID.- Returns:
- the valid sections, or null if unsupported
-
getSections
Retrieve a list of sections.- Parameters:
wflags- must-have flagsbflags- must-not-have flags- Returns:
- the matching sections, or null if unsupported
-
getSection
Retrieve a section by index.- Parameters:
i- section index- Returns:
- the section
-
getSectionCount
int getSectionCount()Retrieve the number of sections.- Returns:
- section count
-
getSymbols
Collection<? extends ISymbolInformation> getSymbols()Retrieve the symbols defined in the object file.- Returns:
- the symbols, or null if unsupported
-
getSymbols
Retrieve symbols filtered by flags.- Parameters:
mustHaveFlags- mask of flags that must be presentmustNotHaveFlags- mask of flags that must be absent- Returns:
- the matching symbols, or null if unsupported
-
getImportedSymbols
Collection<? extends ISymbolInformation> getImportedSymbols()Retrieve the list of imported symbols.- Returns:
- the list (possibly empty) of imported symbols, or null if unsupported
-
getExportedSymbols
Collection<? extends ISymbolInformation> getExportedSymbols()Retrieve the list of exported symbols.- Returns:
- the list (possibly empty) of exported symbols, or null if unsupported
-
convertFileOffsetToRelativeAddress
long convertFileOffsetToRelativeAddress(long offset) Convert a file offset to a memory address, relative to the base.- 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
long convertRelativeAddressToFileOffset(long rel) Convert a memory address (relative to the base) to a file offset.- 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
IVirtualMemory getRawMemoryMappedImage()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.- 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
boolean map(IVirtualMemory mem, long wantedBase, boolean applyRelocations, ILinkInfoProvider linkInfoPrv) Map this object file onto virtual memory.- Parameters:
mem- memory image onto which the mapping should be donewantedBase- wanted base; set to -1L to request mapping at the normal baseapplyRelocations- true to apply relocations after mappinglinkInfoPrv- optional link information provider- Returns:
- success indicator
-