def get_base_segment_class(seg_type): platform = options.get_platform() try: segmodule = importlib.import_module( f"segtypes.{platform}.{seg_type}") except ModuleNotFoundError: return None return getattr( segmodule, f"{platform.upper()}Seg{seg_type[0].upper()}{seg_type[1:]}")
def get_base_segment_class(seg_type): platform = options.get_platform() is_platform_seg = False # heirarchy is platform -> common -> fail try: segmodule = importlib.import_module(f"segtypes.{platform}.{seg_type}") is_platform_seg = True except ModuleNotFoundError: try: segmodule = importlib.import_module(f"segtypes.common.{seg_type}") except ModuleNotFoundError: return None seg_prefix = platform.capitalize() if is_platform_seg else "Common" return getattr(segmodule, f"{seg_prefix}Seg{seg_type.capitalize()}")
def get_extension_segment_class(seg_type): platform = options.get_platform() ext_path = options.get_extensions_path() if not ext_path: log.error( f"could not load presumed extended segment type '{seg_type}' because no extensions path is configured" ) try: ext_spec = importlib.util.spec_from_file_location( f"{platform}.segtypes.{seg_type}", ext_path / f"{seg_type}.py") ext_mod = importlib.util.module_from_spec(ext_spec) ext_spec.loader.exec_module(ext_mod) except Exception as err: log.write(err, status="error") log.error( f"could not load segment type '{seg_type}'\n(hint: confirm your extension directory is configured correctly)" ) return getattr( ext_mod, f"{platform.upper()}Seg{seg_type[0].upper()}{seg_type[1:]}")
def configure_disassembler(): # Configure spimdisasm spimdisasm.common.GlobalConfig.PRODUCE_SYMBOLS_PLUS_OFFSET = True spimdisasm.common.GlobalConfig.TRUST_USER_FUNCTIONS = True spimdisasm.common.GlobalConfig.TRUST_JAL_FUNCTIONS = True spimdisasm.common.GlobalConfig.GLABEL_ASM_COUNT = False if options.rom_address_padding(): spimdisasm.common.GlobalConfig.ASM_COMMENT_OFFSET_WIDTH = 6 else: spimdisasm.common.GlobalConfig.ASM_COMMENT_OFFSET_WIDTH = 0 # spimdisasm is not performing any analyzis on non-text sections so enabling this options is pointless spimdisasm.common.GlobalConfig.AUTOGENERATED_NAMES_BASED_ON_SECTION_TYPE = False spimdisasm.common.GlobalConfig.AUTOGENERATED_NAMES_BASED_ON_DATA_TYPE = False spimdisasm.common.GlobalConfig.SYMBOL_FINDER_FILTERED_ADDRESSES_AS_HILO = False rabbitizer.config.regNames_userFpcCsr = False rabbitizer.config.regNames_vr4300Cop0NamedRegisters = False rabbitizer.config.misc_opcodeLJust = options.mnemonic_ljust() - 1 rabbitizer.config.regNames_gprAbiNames = rabbitizer.Abi.fromStr( options.get_mips_abi_gpr() ) rabbitizer.config.regNames_fprAbiNames = rabbitizer.Abi.fromStr( options.get_mips_abi_float_regs() ) if options.get_endianess() == "big": spimdisasm.common.GlobalConfig.ENDIAN = spimdisasm.common.InputEndian.BIG else: spimdisasm.common.GlobalConfig.ENDIAN = spimdisasm.common.InputEndian.LITTLE rabbitizer.config.pseudos_pseudoMove = False selectedCompiler = options.get_compiler() if selectedCompiler == compiler.SN64: rabbitizer.config.regNames_namedRegisters = False rabbitizer.config.toolchainTweaks_sn64DivFix = True rabbitizer.config.toolchainTweaks_treatJAsUnconditionalBranch = True spimdisasm.common.GlobalConfig.ASM_COMMENT = False spimdisasm.common.GlobalConfig.SYMBOL_FINDER_FILTERED_ADDRESSES_AS_HILO = False spimdisasm.common.GlobalConfig.COMPILER = spimdisasm.common.Compiler.SN64 elif selectedCompiler == compiler.GCC: rabbitizer.config.toolchainTweaks_treatJAsUnconditionalBranch = True spimdisasm.common.GlobalConfig.COMPILER = spimdisasm.common.Compiler.GCC elif selectedCompiler == compiler.IDO: spimdisasm.common.GlobalConfig.COMPILER = spimdisasm.common.Compiler.IDO spimdisasm.common.GlobalConfig.GP_VALUE = options.get_gp() spimdisasm.common.GlobalConfig.ASM_TEXT_LABEL = options.get_asm_function_macro() spimdisasm.common.GlobalConfig.ASM_DATA_LABEL = options.get_asm_data_macro() spimdisasm.common.GlobalConfig.ASM_TEXT_END_LABEL = options.get_asm_end_label() if spimdisasm.common.GlobalConfig.ASM_TEXT_LABEL == ".globl": spimdisasm.common.GlobalConfig.ASM_TEXT_ENT_LABEL = ".ent" spimdisasm.common.GlobalConfig.ASM_TEXT_FUNC_AS_LABEL = True spimdisasm.common.GlobalConfig.LINE_ENDS = options.c_newline() if options.get_platform() == "n64": symbols.spim_context.fillDefaultBannedSymbols()