public abstract class

AbstractCodeObjectUnit

extends AbstractBinaryUnit
implements ICodeObjectUnit
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

Class Overview

Convenient base class for code objects.

Summary

[Expand]
Inherited Fields
From class com.pnfsoftware.jeb.core.events.JebEventSource
Public Constructors
AbstractCodeObjectUnit(IInput input, String formatType, String name, IUnitProcessor unitProcessor, IUnitCreator parent, IPropertyDefinitionManager pdm)
Public Methods
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.
List<? extends ISymbolInformation> getExportedSymbols()
Retrieve the list of exported symbols.
List<? extends ISymbolInformation> getImportedSymbols()
Retrieve the list of imported symbols.
ILoaderInformation getLoaderInformation()
Retrieve basic information about the object file.
synchronized IVirtualMemory getRawMemoryMappedImage()
Retrieve a raw mapping of the code object.
ISegmentInformation getSection(int i)
int getSectionCount()
List<? extends ISegmentInformation> getSections()
Retrieve the list of sections defined in the object file.
List<? extends ISegmentInformation> getSections(int wflags, int bflags)
Retrieve a list of sections.
ISegmentInformation getSegment(int i)
int getSegmentCount()
List<? extends ISegmentInformation> getSegments(int wflags, int bflags)
Retrieve a list of segments.
List<? extends ISegmentInformation> getSegments()
Retrieve the list of segments defined in the object file.
int getSymbolCount()
Collection<? extends ISymbolInformation> getSymbols()
List<? extends ISymbolInformation> getSymbols(int mustHaveFlags, int mustNotHaveFlags)
List<? extends ISegmentInformation> getValidSections()
Retrieve the list of sections that are not marked INVALID.
List<? extends ISegmentInformation> getValidSegments()
Retrieve the list of segments that are not marked INVALID.
boolean map(IVirtualMemory mem, long wantedBase, boolean applyRelocations, ILinkInfoProvider linkInfoPrv)
Map this object file onto virtual memory.
Protected Methods
void addAllSections(Collection<? extends ISegmentInformation> sections)
void addAllSegments(Collection<? extends ISegmentInformation> segments)
void addAllSymbols(Collection<? extends ISymbolInformation> symbols)
void addSection(ISegmentInformation section)
void addSegment(ISegmentInformation segment)
boolean addSymbol(ISymbolInformation symbol)
abstract boolean applyRelocations(IVirtualMemory mem, long base, ILinkInfoProvider linkInfoPrv)
Relocate a mapped code object.
IVirtualMemory createSuitableMemory()
Create a virtual memory suitable to map this code object.
IInput getMappableInput()
Retrieve the input that is truly mappable.
void insertSection(int index, ISegmentInformation section)
void insertSegment(int index, ISegmentInformation segment)
boolean mapRawNoReloc(IVirtualMemory mem, long base)
Map the object's segments at the provided base without applying relocations.
void removeSection(int index)
void removeSegment(int index)
void setLoaderInformation(ILoaderInformation ldInfo)
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.
[Expand]
Inherited Methods
From class com.pnfsoftware.jeb.core.units.AbstractBinaryUnit
From class com.pnfsoftware.jeb.core.units.AbstractUnit
From class com.pnfsoftware.jeb.core.events.JebEventSource
From class java.lang.Object
From interface com.pnfsoftware.jeb.core.IUnitCreator
From interface com.pnfsoftware.jeb.core.IUserDataSupport
From interface com.pnfsoftware.jeb.core.units.IBinaryUnit
From interface com.pnfsoftware.jeb.core.units.IUnit
From interface com.pnfsoftware.jeb.core.units.codeobject.ICodeObjectUnit
From interface com.pnfsoftware.jeb.util.events.IEventSource

Public Constructors

public AbstractCodeObjectUnit (IInput input, String formatType, String name, IUnitProcessor unitProcessor, IUnitCreator parent, IPropertyDefinitionManager pdm)

Public Methods

public 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

public 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

public List<? extends ISymbolInformation> getExportedSymbols ()

Retrieve the list of exported symbols.

Returns
  • the list (possibly empty) of exported symbols, or null if unsupported

public List<? extends ISymbolInformation> getImportedSymbols ()

Retrieve the list of imported symbols.

Returns
  • the list (possibly empty) of imported symbols, or null if unsupported

public ILoaderInformation getLoaderInformation ()

Retrieve basic information about the object file.

Returns
  • the object file information, never null

public synchronized 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

public ISegmentInformation getSection (int i)

public int getSectionCount ()

public List<? 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

public List<? extends ISegmentInformation> getSections (int wflags, int bflags)

Retrieve a list of sections.

Parameters
wflags must-have flags
bflags must-not-have flags

public ISegmentInformation getSegment (int i)

public int getSegmentCount ()

public List<? extends ISegmentInformation> getSegments (int wflags, int bflags)

Retrieve a list of segments.

Parameters
wflags must-have flags
bflags must-not-have flags

public List<? 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

public int getSymbolCount ()

public Collection<? extends ISymbolInformation> getSymbols ()

public List<? extends ISymbolInformation> getSymbols (int mustHaveFlags, int mustNotHaveFlags)

public List<? extends ISegmentInformation> getValidSections ()

Retrieve the list of sections that are not marked INVALID.

public List<? extends ISegmentInformation> getValidSegments ()

Retrieve the list of segments that are not marked INVALID.

public 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 done
wantedBase wanted base; set to -1L to request mapping at the normal base
linkInfoPrv optional
Returns
  • success indicator

Protected Methods

protected 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.

Parameters
mem virtual memory
base mapping base address
linkInfoPrv optional

protected IVirtualMemory createSuitableMemory ()

Create a virtual memory suitable to map this code object.

protected IInput getMappableInput ()

Retrieve the input that is truly mappable. The default implementation simply returns 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.

protected void insertSection (int index, ISegmentInformation section)

protected void insertSegment (int index, ISegmentInformation segment)

protected boolean mapRawNoReloc (IVirtualMemory mem, long base)

Map the object's segments at the provided base without applying relocations.

Returns
  • the VM, null on error

protected void removeSection (int index)

protected void removeSegment (int index)

protected void setLoaderInformation (ILoaderInformation ldInfo)

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.