com.pnfsoftware.jeb.core.units.code.asm.type.ICallingConvention |
Known Indirect Subclasses |
A calling convention object. Calling convention objects are immutable.
Notes:
IRegisterBank
implementations
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | FLAG_COMPOSITE_INPUT_ON_STACK | The flag indicates that all composite arguments (arrays, structures, unions) must go on the stack, regardless of registers declared to be holding storage items, if any. | |||||||||
int | FLAG_FIRST_ARG_IS_THIS_POINTER | The first argument must be a pointer to the object. | |||||||||
int | FLAG_FLOAT_INPUT_ON_STACK | The flag indicates that all float arguments must go on the stack, regardless of registers declared to be holding storage items, if any. | |||||||||
int | FLAG_FORBID_PARAMS_2SLOTSUP | 2+ slots (aka, multi-slot) parameters are disallowed. | |||||||||
int | FLAG_FORBID_PARAMS_3SLOTSUP | 3+ slots parameters are disallowed. | |||||||||
int | FLAG_IPRD | The flag indicates that the calling convention uses an implicit pointer as first parameter when the function prototype specifies that a "large" composite data type (some fundamental types, all aggregate types) is to be returned. | |||||||||
int | FLAG_LINK_AFTER_INPUT | This flag indicates that the return-address value is located after the input argument on the stack. | |||||||||
int | FLAG_OUTPUT_AFTER_INPUT | The flag indicates that output values are located on the pre-allocated stack slots located after the input values (whose count may not be known). | |||||||||
int | FLAG_OUTPUT_PUSHED | This flag indicates that the return values are to be pushed on the stack after return. | |||||||||
int | FLAG_PARALLEL_INPUT_REGISTER_STACKS | The indices in the lists of registers used to pass integral arguments and floating-point arguments grow together, in a parallel fashion. | |||||||||
int | FLAG_SKIP_PASSED_INPUT_REGISTERS | This flag indicates that candidate input registers that were passed over in favor of stack storage because they were not suitable for an argument at position N, will not be reused for an argument at a later position (>=N+1) even if that argument would be suitable for storage in an unused input register. | |||||||||
int | FLAG_STACK_CLEANED_BY_CALLEE | The flag indicates that the stack is cleaned by the callee (which is not the norm; if the flag is not set, it should be assumed the stack is cleaned by the caller). |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
abstract int |
determineSlotcountAlignment(int requestedSlotcount)
Determine the slotcount alignment requirement of a non-
composite type. | ||||||||||
abstract String | format(int type) | ||||||||||
abstract List<String> |
getAlternateNames()
Get a list of alternate names for this calling convention.
| ||||||||||
abstract List<CompilerType> |
getCompilerTypes()
Get the list of compiler types this calling convention may work with.
| ||||||||||
abstract int | getFlags() | ||||||||||
abstract ICallingConvention |
getIPRDConvention()
Retrieve the optional calling convention, derived from this convention, used to return large
composite prototypes.
| ||||||||||
abstract StorageEntry | getIPRDInputPtrEntry() | ||||||||||
abstract int | getIPRDMinimumSlotCount() | ||||||||||
abstract StorageEntry | getIPRDOutputPtrEntry() | ||||||||||
abstract long |
getIdentifierKey()
Get an internally-generated identifier for this calling convention object.
| ||||||||||
abstract int |
getInputSlotCountHint()
Return the number of slots that are reserved for parameters.
| ||||||||||
abstract IStorageEntryGenerator |
getInputsGenerator()
Create a storage-location generator for the inputs provided to a routine using this calling
convention.
| ||||||||||
abstract String |
getName()
Get the common name of this calling convention.
| ||||||||||
abstract List<String> |
getNames()
Retrieve all names for this calling convention (principal and alternates).
| ||||||||||
abstract String | getNotes() | ||||||||||
abstract StorageEntry |
getOutput(TypeLayoutInfo ti, int inputStackSlotCount)
Convenience method to retrieve the storage location of the single return value for this
calling convention.
| ||||||||||
abstract int |
getOutputSlotCountHint()
Return the number of slots that are reserved for return values.
| ||||||||||
abstract IStorageEntryGenerator |
getOutputsGenerator(int inputStackSlotCount)
Create a storage-location generator for the outputs provided to a routine using this calling
convention.
| ||||||||||
abstract List<ProcessorType> |
getProcessorTypes()
Get the list of processor types this calling convention may work with.
| ||||||||||
abstract Collection<Long> |
getPureSpoiledRegisters()
Get the list of registers that are spoiled by a callee, in the strictest sense, i.e.
| ||||||||||
abstract StorageEntry | getReturnAddressSlot(Integer inputStackSlotCount) | ||||||||||
abstract StorageEntry | getReturnAddressSlot() | ||||||||||
abstract Map<Integer, Integer> |
getSlotcountAlignmentMap()
Alignment specifications for non-
composite types. | ||||||||||
abstract Collection<Long> |
getSpoiledRegisters()
Get the list of all registers that may be modified and/or spoiled by a callee, in the most
general sense.
| ||||||||||
abstract List<SubsystemType> |
getSubsystemTypes()
Get the list of subsystem types this calling convention may work with.
| ||||||||||
abstract boolean | hasFlag(int f) | ||||||||||
abstract boolean |
isCompatibleWith(ProcessorType wantedProcessor, SubsystemType wantedSubsystem, CompilerType wantedCompiler)
Determine whether this calling convention is compatible with the provided triple (processor, subsystem, compiler).
| ||||||||||
abstract boolean |
isStackCleanedByCallee()
Determine whether routine parameters pushed on stack before a routine call are cleaned by the
callee.
| ||||||||||
abstract boolean |
isStackCleanedByCaller()
Determine whether routine parameters pushed on stack before a routine call are cleaned by the
caller.
| ||||||||||
abstract boolean | isUnknown() |
The flag indicates that all composite arguments (arrays, structures, unions) must go on the stack, regardless of registers declared to be holding storage items, if any. (I.e., input registers will be used for integral types, at least, not composite types.)
The first argument must be a pointer to the object. Typically, this flag is used by MSVC's
__thiscall
convention. Generally, it enforces the fact that the first parameter of a
prototype must be a single-slot element (and more specifically, a pointer
-type element.
The flag indicates that all float arguments must go on the stack, regardless of registers declared to be holding storage items, if any. (I.e., input registers will be used for integral types, at least, not FP types.)
2+ slots (aka, multi-slot) parameters are disallowed. All inputs must fit on a single slot. Typically, such conventions require composite types to be passed by implicit reference.
3+ slots parameters are disallowed. All inputs must fit on a 1 or 2 slots. Typically, such conventions require larger composite types to be passed by implicit reference.
The flag indicates that the calling convention uses an implicit pointer as first parameter when the function prototype specifies that a "large" composite data type (some fundamental types, all aggregate types) is to be returned. The return value is a pointer to that data. "IPRD" means Implicit Pointer to Return Data.
Example: this method, in x86:
struct S1 { int a, b, c; }; struct S1 __cdecl func(struct S1 x) { x.c += 1; return x; }The explicit prototype and code:
struct S1* __cdecl_iprd func(struct S1* prd, struct S1 x) { x.c += 1; copy(prd, &x); return prd; }
This flag indicates that the return-address value is located after the input argument on the stack.
Example:
| ... | return addr | argN | (...) v arg1 +----------- <---- SP at routine entryIMPORTANT: this flag requires that all calling convention elements (inputs, outputs, return address) be located on the stack.
The flag indicates that output values are located on the pre-allocated stack slots located after the input values (whose count may not be known).
Example, when calling a function (int,int)->(int)
v ... +----------- (SP1) | ? retval1 (slot) | arg2 | arg1 v return addr +----------- <---- SP at routine entryIf
FLAG_STACK_CLEANED_BY_CALLEE
is also set, the input values as well as the output
values are 'cleared', i.e. the stack pointer would be expected to have the value SP1 when
execution resumes to the return address.
IMPORTANT: this flag requires that all calling convention elements (inputs, outputs, return address) be located on the stack.
This flag indicates that the return values are to be pushed on the stack after return. If it
is combined with FLAG_STACK_CLEANED_BY_CALLEE
, the input arguments are assumed to be
cleaned before pushing the output.
Example, when calling a function (int,int)->(int):
v ... +----------- (SP1) | retaddr | arg2 v arg1 +----------- <---- SP at routine entryAfter execution:
v ... +----------- (SP1) | retval +----------- <---- SP at return PCIMPORTANT: this flag requires that all calling convention elements (inputs, outputs, return address) be located on the stack.
The indices in the lists of registers used to pass integral arguments and floating-point arguments grow together, in a parallel fashion.
Example when calling a method: void f(int a, float b, int c, float d)
With the standard x86_64 Windows calling convention, arguments...
- a would go in rcx - b would go in xmm1 (FP reg at index 1) - c would go in r8 (GP reg at index 2) - d would go in xmm3 (GP reg at index 3)
Here is an example of what happens when the general and FP register stacks used for arguments passing grow separately, as is the case for Linux x64, with the standard amd64 System V convention:
- a would go in rdi - b would go in xmm0 (NOT xmm1) - c would go in rsi (NOT rdx) - d would go in xmm1 (NOT xmm3)
This flag indicates that candidate input registers that were passed over in favor of stack storage because they were not suitable for an argument at position N, will not be reused for an argument at a later position (>=N+1) even if that argument would be suitable for storage in an unused input register.
An example of that is the x86 fastcall
convention on Linux. The first two small
integer integer parameters go in ecx
and edx
; others go on the stack. For a
prototype like (int32 a, int64 b, int32 c)
, a
goes in ecx
, b
on the stack, and c
on the stack as well (even though it could fit in edx
;
note: x86 __fastcall
on Windows does not skip over passed input registers; in this
example, c
would go in edx
.}
The flag indicates that the stack is cleaned by the callee (which is not the norm; if the flag is not set, it should be assumed the stack is cleaned by the caller).
Note that a return-address value located on the stack is always pop'ed, regardless of the presence of this flag.
Determine the slotcount alignment requirement of a non-composite
type.
type | 0: short-form (i.e., #toString()), 1: user-friendly long-form, 2: parseable yaml form |
---|
Get a list of alternate names for this calling convention.
Get the list of compiler types this calling convention may work with.
Retrieve the optional calling convention, derived from this convention, used to return large
composite prototypes. This only applies if the flag FLAG_IPRD
was set.
Get an internally-generated identifier for this calling convention object. The id is generated using:
Return the number of slots that are reserved for parameters. Note that this is just a hint on how many parameters are used.
Create a storage-location generator for the inputs provided to a routine using this calling convention. convention.
Get the common name of this calling convention.
Retrieve all names for this calling convention (principal and alternates).
Convenience method to retrieve the storage location of the single return value for this calling convention. Most calling conventions allow the return of a single value.
ti | storage type |
---|---|
inputStackSlotCount | the number of stack slots used to provide input parameters (some calling conventions require that to calculate proper positioning for output values) |
Return the number of slots that are reserved for return values. Note that this is just a hint on how many return values are defined.
Create a storage-location generator for the outputs provided to a routine using this calling convention.
inputStackSlotCount | optional value indicating how many stack slots were used to
provide parameters (this value is the calling convention has the flags
FLAG_OUTPUT_AFTER_INPUT or FLAG_OUTPUT_PUSHED ) |
---|
Get the list of processor types this calling convention may work with.
Get the list of registers that are spoiled by a callee, in the strictest sense, i.e. their value may or may not be modified, but it is meaningless and should not be interpreted by the caller upon return. That set would NOT include return registers.
Alignment specifications for non-composite
types.
Get the list of all registers that may be modified and/or spoiled by a callee, in the most general sense. That set would include any type of return registers.
Get the list of subsystem types this calling convention may work with.
Determine whether this calling convention is compatible with the provided triple (processor, subsystem, compiler).
wantedProcessor | mandatory (pass UNKNOWN if not known) |
---|---|
wantedSubsystem | mandatory (pass UNKNOWN if not known) |
wantedCompiler | mandatory (pass UNKNOWN if not known) |
Determine whether routine parameters pushed on stack before a routine call are cleaned by the callee.
Determine whether routine parameters pushed on stack before a routine call are cleaned by the caller.