Skip to content

linkable_symbol.py

ofrak.core.patch_maker.linkable_symbol

LinkableSymbol (LabeledAddress) dataclass

A 'symbol' in the binary that may be used for the purpose of linking when injecting a patch. It may be extracted from symbol information that was already in the binary, added manually, or inferred by some analysis.

get_stub_info(self)

Get the information about this LinkableSymbol needed to generate a stub

Source code in ofrak/core/patch_maker/linkable_symbol.py
def get_stub_info(self) -> LinkableSymbolStubInfo:
    """
    Get the information about this LinkableSymbol needed to generate a stub
    """
    if self.symbol_type is LinkableSymbolType.FUNC:
        return _make_rx_stub_info(self.name, self.virtual_address, self.mode)

    elif self.symbol_type is LinkableSymbolType.RO_DATA:
        return _make_r_stub_info(self.name, self.virtual_address)

    elif self.symbol_type is LinkableSymbolType.RW_DATA:
        return _make_rw_stub_info(self.name, self.virtual_address)

    else:
        raise NotImplementedError(f"No stub info factory for {self.symbol_type.name}")

LinkableSymbolStubInfo dataclass

Container holding the information needed to create a stub for a LinkableSymbol.

Attributes:

Name Type Description
asm_prefixes List[str]

The lines to prefix an assembly stub for this symbol, usually describing what type of symbol this is and optionally the mode

segments Tuple[ofrak_patch_maker.toolchain.model.Segment, ...]

Segments to extract from the stub object file.

LinkableSymbolType (Enum)

An enumeration.