C# Class Reko.Core.Platform

Inheritance: IPlatform
ファイルを表示 Open project: uxmal/reko

Public Methods

Method Description
AdjustProcedureAddress ( Address addr ) : Address

Some architectures platforms (I'm looking at you ARM Thumb) will use addresses that are offset by 1. Most don't.

CreateAbsoluteMemoryMap ( ) : Reko.Core.SegmentMap

Creates an empty imagemap based on the absolute memory map. It is the caller's responsibility to fill in the MemoryArea properties of each resulting ImageSegment.

CreateImplicitArgumentRegisters ( ) : HashSet

Creates a set that represents those registers that are never used as arguments to a procedure.

Typically, the stack pointer register is one of these registers. Some architectures define global registers that are preserved across calls; these should also be present in this set.

CreateMetadata ( ) : Reko.Core.TypeLibrary
CreatePointerScanner ( Reko.Core.SegmentMap segmentMap, Reko.Core.ImageReader rdr, IEnumerable
address, PointerScannerFlags pointerScannerFlags ) : IEnumerable
CreateProcedureSerializer ( ISerializedTypeVisitor typeLoader, string defaultConvention ) : Reko.Core.Serialization.ProcedureSerializer

Creates a procedure serializer that understands the calling conventions used on this processor and environment

CreateTrashedRegisters ( ) : HashSet

Creates a set of registers that the "standard" ABI cannot guarantee will survive a call.

Reko will do its best to determine what registers are trashed by a procedure, but when indirect calls are involved we have to guess. If Reko's guess is incorrect, users can override it by proving oracular type information.

DataTypeFromImportName ( string importName ) : Tuple
DetermineCallingConvention ( FunctionType signature ) : string
EnsureTypeLibraries ( string envName ) : void

Utility function for subclasses that loads all type libraries and characteristics libraries defined in the Reko configuration file.

FindMainProcedure ( Program program, Address addrStart ) : Reko.Core.ImageSymbol
FindService ( RtlInstruction rtl, ProcessorState state ) : Reko.Core.SystemService
FindService ( int vector, ProcessorState state ) : Reko.Core.SystemService
FindService ( string name ) : Reko.Core.SystemService
FormatProcedureName ( Program program, Procedure proc ) : string

Formats a program/module and a procedure name together.

This is done in the Windows way {module}!{procname}. Other platforms may have other conventions. Please override this in the other platforms to give the correct output.

GetByteSizeFromCBasicType ( CBasicType cb ) : int
GetPrimitiveTypeName ( PrimitiveType pt, string language ) : string
GetTrampolineDestination ( Reko.Core.ImageReader imageReader, IRewriterHost host ) : Reko.Core.ProcedureBase

If the instructions located at the address the image reader is reading are a trampoline, returns the procedure where the destination is located, otherwise returns null.

InjectProcedureEntryStatements ( Procedure proc, Address addr, Reko.Core.CodeEmitter emitter ) : void
LoadUserOptions ( object>.Dictionary options ) : void

If the platform can be customized by user, load those customizations here.

LookupCharacteristicsByName ( string procName ) : Reko.Core.Serialization.ProcedureCharacteristics
LookupGlobalByName ( string moduleName, string globalName ) : Identifier
LookupGlobalByOrdinal ( string moduleName, int ordinal ) : Identifier
LookupProcedureByName ( string moduleName, string procName ) : Reko.Core.ExternalProcedure
LookupProcedureByOrdinal ( string moduleName, int ordinal ) : ExternalProcedure
MakeAddressFromConstant ( Constant c ) : Address
MakeAddressFromLinear ( ulong uAddr ) : Address

Given a linear address, converts it to an Address instance. By default, use the architecture pointer size for the address.

The method is virtual to allow a platform to override the pointer size. For instance although the PowerPC 64 has 64-bit addresses, the Playstation3 implementation uses 32-bit addresses.

SaveUserOptions ( ) : object>.Dictionary

If the platform can be customized by user, save those customizations here.

SignatureFromName ( string fnName ) : ExternalProcedure

Guess signature from the name of the procedure.

TryParseAddress ( string sAddress, Address &addr ) : bool

Protected Methods

Method Description
Platform ( IServiceProvider services, IProcessorArchitecture arch, string platformId ) : Reko.Core.CLanguage

Initializes a Platform instance

Method Details

AdjustProcedureAddress() public method

Some architectures platforms (I'm looking at you ARM Thumb) will use addresses that are offset by 1. Most don't.
public AdjustProcedureAddress ( Address addr ) : Address
addr Address
return Address

CreateAbsoluteMemoryMap() public method

Creates an empty imagemap based on the absolute memory map. It is the caller's responsibility to fill in the MemoryArea properties of each resulting ImageSegment.
public CreateAbsoluteMemoryMap ( ) : Reko.Core.SegmentMap
return Reko.Core.SegmentMap

CreateImplicitArgumentRegisters() public abstract method

Creates a set that represents those registers that are never used as arguments to a procedure.
Typically, the stack pointer register is one of these registers. Some architectures define global registers that are preserved across calls; these should also be present in this set.
public abstract CreateImplicitArgumentRegisters ( ) : HashSet
return HashSet

CreateMetadata() public method

public CreateMetadata ( ) : Reko.Core.TypeLibrary
return Reko.Core.TypeLibrary

CreatePointerScanner() public method

public CreatePointerScanner ( Reko.Core.SegmentMap segmentMap, Reko.Core.ImageReader rdr, IEnumerable
address, PointerScannerFlags pointerScannerFlags ) : IEnumerable
segmentMap Reko.Core.SegmentMap
rdr Reko.Core.ImageReader
address IEnumerable
pointerScannerFlags PointerScannerFlags
return IEnumerable

CreateProcedureSerializer() public abstract method

Creates a procedure serializer that understands the calling conventions used on this processor and environment
public abstract CreateProcedureSerializer ( ISerializedTypeVisitor typeLoader, string defaultConvention ) : Reko.Core.Serialization.ProcedureSerializer
typeLoader ISerializedTypeVisitor Used to resolve data types
defaultConvention string Default calling convention, if none specified.
return Reko.Core.Serialization.ProcedureSerializer

CreateTrashedRegisters() public abstract method

Creates a set of registers that the "standard" ABI cannot guarantee will survive a call.
Reko will do its best to determine what registers are trashed by a procedure, but when indirect calls are involved we have to guess. If Reko's guess is incorrect, users can override it by proving oracular type information.
public abstract CreateTrashedRegisters ( ) : HashSet
return HashSet

DataTypeFromImportName() public method

public DataTypeFromImportName ( string importName ) : Tuple
importName string
return Tuple

DetermineCallingConvention() public method

public DetermineCallingConvention ( FunctionType signature ) : string
signature FunctionType
return string

EnsureTypeLibraries() public method

Utility function for subclasses that loads all type libraries and characteristics libraries defined in the Reko configuration file.
public EnsureTypeLibraries ( string envName ) : void
envName string
return void

FindMainProcedure() public method

public FindMainProcedure ( Program program, Address addrStart ) : Reko.Core.ImageSymbol
program Program
addrStart Address
return Reko.Core.ImageSymbol

FindService() public method

public FindService ( RtlInstruction rtl, ProcessorState state ) : Reko.Core.SystemService
rtl RtlInstruction
state ProcessorState
return Reko.Core.SystemService

FindService() public abstract method

public abstract FindService ( int vector, ProcessorState state ) : Reko.Core.SystemService
vector int
state ProcessorState
return Reko.Core.SystemService

FindService() public method

public FindService ( string name ) : Reko.Core.SystemService
name string
return Reko.Core.SystemService

FormatProcedureName() public method

Formats a program/module and a procedure name together.
This is done in the Windows way {module}!{procname}. Other platforms may have other conventions. Please override this in the other platforms to give the correct output.
public FormatProcedureName ( Program program, Procedure proc ) : string
program Program
proc Procedure
return string

GetByteSizeFromCBasicType() public abstract method

public abstract GetByteSizeFromCBasicType ( CBasicType cb ) : int
cb CBasicType
return int

GetPrimitiveTypeName() public method

public GetPrimitiveTypeName ( PrimitiveType pt, string language ) : string
pt PrimitiveType
language string
return string

GetTrampolineDestination() public abstract method

If the instructions located at the address the image reader is reading are a trampoline, returns the procedure where the destination is located, otherwise returns null.
public abstract GetTrampolineDestination ( Reko.Core.ImageReader imageReader, IRewriterHost host ) : Reko.Core.ProcedureBase
imageReader Reko.Core.ImageReader
host IRewriterHost
return Reko.Core.ProcedureBase

InjectProcedureEntryStatements() public method

public InjectProcedureEntryStatements ( Procedure proc, Address addr, Reko.Core.CodeEmitter emitter ) : void
proc Procedure
addr Address
emitter Reko.Core.CodeEmitter
return void

LoadUserOptions() public method

If the platform can be customized by user, load those customizations here.
public LoadUserOptions ( object>.Dictionary options ) : void
options object>.Dictionary
return void

LookupCharacteristicsByName() public method

public LookupCharacteristicsByName ( string procName ) : Reko.Core.Serialization.ProcedureCharacteristics
procName string
return Reko.Core.Serialization.ProcedureCharacteristics

LookupGlobalByName() public method

public LookupGlobalByName ( string moduleName, string globalName ) : Identifier
moduleName string
globalName string
return Identifier

LookupGlobalByOrdinal() public method

public LookupGlobalByOrdinal ( string moduleName, int ordinal ) : Identifier
moduleName string
ordinal int
return Identifier

LookupProcedureByName() public abstract method

public abstract LookupProcedureByName ( string moduleName, string procName ) : Reko.Core.ExternalProcedure
moduleName string
procName string
return Reko.Core.ExternalProcedure

LookupProcedureByOrdinal() public method

public LookupProcedureByOrdinal ( string moduleName, int ordinal ) : ExternalProcedure
moduleName string
ordinal int
return ExternalProcedure

MakeAddressFromConstant() public method

public MakeAddressFromConstant ( Constant c ) : Address
c Constant
return Address

MakeAddressFromLinear() public method

Given a linear address, converts it to an Address instance. By default, use the architecture pointer size for the address.
The method is virtual to allow a platform to override the pointer size. For instance although the PowerPC 64 has 64-bit addresses, the Playstation3 implementation uses 32-bit addresses.
public MakeAddressFromLinear ( ulong uAddr ) : Address
uAddr ulong
return Address

Platform() protected method

Initializes a Platform instance
protected Platform ( IServiceProvider services, IProcessorArchitecture arch, string platformId ) : Reko.Core.CLanguage
services IServiceProvider
arch IProcessorArchitecture
platformId string
return Reko.Core.CLanguage

SaveUserOptions() public method

If the platform can be customized by user, save those customizations here.
public SaveUserOptions ( ) : object>.Dictionary
return object>.Dictionary

SignatureFromName() public method

Guess signature from the name of the procedure.
public SignatureFromName ( string fnName ) : ExternalProcedure
fnName string
return ExternalProcedure

TryParseAddress() public method

public TryParseAddress ( string sAddress, Address &addr ) : bool
sAddress string
addr Address
return bool