Skip to content

model.py

ofrak_patch_maker.toolchain.model

BinFileType (Enum)

Enums for file types

CStandardVersion (Enum)

An enumeration.

CompilerOptimizationLevel (Enum)

Some compilers implement different optimization options. This Enum enables us to handle those distinctly.

LinkerOptimizationLevel (Enum)

Todo

Experiment with this

Segment dataclass

Describes a program segment.

Attributes:

Name Type Description
segment_name str

e.g. .text

vm_address int

where the segment is located

offset int

offset from vm_address

is_entry bool

If the Segment contains the patch "entry point symbol"

length int

size of the segment in bytes

access_perms MemoryPermissions

rw, ro, rwx, etc.

ToolchainConfig dataclass

A dataclass that describes all of the parameters toolchains may be configured with.

As further Toolchain support is added, not all of these may be relevant to all toolchains.

It is expected the functionality described by the parameter will be achieved to the best effort.

Attributes:

Name Type Description
file_format BinFileType

Usually ELF

force_inlines bool

forces inlines when specified in the function signature

relocatable bool

Enables PC-relative data references, branches, etc. (via pic/pie)

no_std_lib bool

Excludes the host system root from include paths

no_jump_tables bool

Prevents the generation of jump tables

no_bss_section bool

Forces usage of .data/.rodata instead of .bss

compiler_optimization_level CompilerOptimizationLevel

NONE, SOME, SPACE, or FULL (implementation dependent)

compiler_target Optional[str]

Forces specific triple (CPU/ARCH) target-- should match file_format

assembler_target Optional[str]

Forces specific assembler CPU/ARCH target

create_map_files bool

Creates .map files from link step (Default: True)

debug_info bool

Should most closely mirror GNU -g functionality (Default: True)

check_overlap bool

Enables the Toolchain Linker to assert memory boundaries (Default: True)

userspace_dynamic_linker Optional[str]

Signals compilation for userspace and libc usage.

isysroot Optional[str]

Specifies the root directory for header files

c_standard Optional[ofrak_patch_maker.toolchain.model.CStandardVersion]

Specifies the version of C to use, e.g. C89, C99, etc

separate_data_sections Optional[bool]

Whether to put each data object in a separate section in .o file

hard_float Optional[bool]

Compile with support for hardware floating point operations (Default: False)