Skip to content

vbcc_gnu_hybrid.py

ofrak_patch_maker.toolchain.vbcc_gnu_hybrid

VBCC_0_9_GNU_Hybrid_Toolchain (Abstract_GNU_Toolchain, ABC)

A hybrid toolchain using the VBCC compiler + GNU assembler and linker.

name property readonly

Returns:

Type Description

name property that matches the value used in toolchain.conf to access paths

compile(self, c_file, header_dirs, out_dir='.')

Modified version for vbcc hybrid functionality.

Source code in ofrak_patch_maker/toolchain/vbcc_gnu_hybrid.py
def compile(self, c_file: str, header_dirs: List[str], out_dir: str = ".") -> str:
    """
    Modified version for vbcc hybrid functionality.
    """

    out_file = join(out_dir, split(c_file)[-1] + ".asm")
    self._execute_tool(
        self._compiler_path,
        self._compiler_flags,
        [c_file] + ["-I" + x for x in header_dirs],
        # vbcc expects an equality statement for this flag...
        out_file="=" + out_file,
    )
    self._make_gas_compatible(out_file)
    return self.assemble(out_file, header_dirs, out_dir)

_get_assembler_target(self, processor) private

Red Balloon Security strongly recommends all users provide their specific hardware target for best results.

Parameters:

Name Type Description Default
processor ArchInfo required

Returns:

Type Description

a default assembler target for the provided processor unless one is provided in self._config.

Exceptions:

Type Description
PatchMakerException

if no target provided and program attributes do not correspond to a default value.

Source code in ofrak_patch_maker/toolchain/vbcc_gnu_hybrid.py
def _get_assembler_target(self, processor: ArchInfo):
    if processor.isa is not InstructionSet.M68K:
        raise ValueError(
            f"The GNU M68K toolchain does not support ISAs which are not M68K; "
            f"given ISA {processor.isa.name}"
        )
    if self._config.assembler_target:
        return self._config.assembler_target
    arch = processor.isa.value
    if processor.sub_isa is not None:
        arch = processor.sub_isa.value
    return arch