"Fossies" - the Fresh Open Source Software Archive

Member "radare2-4.0.0/doc/calling-conventions.md" (28 Oct 2019, 2441 Bytes) of package /linux/privat/radare2-4.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field.

Calling Conventions profiles

Radare2 uses calling conventions to help in identifying function formal arguments and return types. It is used also as guide for basic function prototype (WIP at the time of writing this wiki).

Profile grammar

Since the profiles are based on sdb database, Creating one is as simple as creating group of key=value pairs in text file. then parsing it into sdb data file.

Attribute list

Note that you will substitute x for the calling convention name you will use.

default.cc=x : used to set the default calling convention used for all functions in RAnal instance for which this key is set, string of this calling convention "x" will be returned for every call of R_API const char *r_anal_cc_default(RAnal *anal).

x=cc: used to initialize calling convention (think of it as their is calling convention called x).

cc.x.name=x: This one is a bit awkward, it is used internally to improve memory usage by reducing memory consumption No need to worry about it except for calling convention profile will probably break if this one doesn’t exist.

cc.x.arg1=reg, cc.x.arg2=reg: used to set the ith argument of this calling convention to register name, feel free to use whatever register name you want to as long as it is supported by the target architecture. Ex: cc.optlink.arg1=eax on x86 architecture.

cc.x.argn=stack: means that all the arguments (or the rest of them in case there was argi for any i as counting number) will be stored in stack from left to right. Ex cc.cdecl.argn=stack.

cc.x.argn=stack_rev: same as cc.x.argn=stack except for it means argument are passed right to left. Ex: cc.stdcall.argn=stack_rev

cc.x.ret=reg: used to set where the return value is stored for the given calling convention.

File Path

In order to integrate the calling convention profile you created with the r2 source, few set of conventions should be followed: