From 5ceb8435fbb0bbb7c6936211e30116e1aef02cf9 Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Wed, 27 Mar 2024 08:51:57 -0300 Subject: [PATCH] Add `EEGCC` compiler option (#363) * Add EEGCC compiler option * some cleanup * version bump * `SYMBOL_ALIGNMENT_REQUIRES_ALIGNED_SECTION` * forgor this --- CHANGELOG.md | 6 ++++++ README.md | 2 +- pyproject.toml | 4 ++-- requirements.txt | 2 +- src/splat/__init__.py | 2 +- src/splat/disassembler/spimdisasm_disassembler.py | 4 +++- src/splat/platforms/ps2.py | 1 + src/splat/segtypes/common/c.py | 14 +++++++------- src/splat/util/compiler.py | 4 +++- 9 files changed, 25 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a2eeeb4..250b4bb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # splat Release Notes +### 0.23.1 + +* New `EEGCC` compiler option. + * Provide specific adjustments for the GCC compiler used for the PS2 platform. +* `spimdisasm` 1.24.2 or above is now required. + ### 0.23.0 * splat now checks if symbol names can be valid filepaths and produce an error if not. diff --git a/README.md b/README.md index d9cd2f93..9ccf4824 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ The brackets corresponds to the optional dependencies to install while installin If you use a `requirements.txt` file in your repository, then you can add this library with the following line: ```txt -splat64[mips]>=0.23.0,<1.0.0 +splat64[mips]>=0.23.1,<1.0.0 ``` ### Optional dependencies diff --git a/pyproject.toml b/pyproject.toml index e67a2d8a..441b5e22 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "splat64" # Should be synced with src/splat/__init__.py -version = "0.23.0" +version = "0.23.1" description = "A binary splitting tool to assist with decompilation and modding projects" readme = "README.md" license = {file = "LICENSE"} @@ -20,7 +20,7 @@ dependencies = [ [project.optional-dependencies] mips = [ - "spimdisasm>=1.23.0,<2.0.0", # This value should be keep in sync with the version listed on disassembler/spimdisasm_disassembler.py + "spimdisasm>=1.24.2,<2.0.0", # This value should be keep in sync with the version listed on disassembler/spimdisasm_disassembler.py "rabbitizer>=1.8.0,<2.0.0", "pygfxd", "n64img>=0.1.4", diff --git a/requirements.txt b/requirements.txt index e88d23c9..42d59f0f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ tqdm intervaltree colorama # This value should be keep in sync with the version listed on disassembler/spimdisasm_disassembler.py and pyproject.toml -spimdisasm>=1.23.0 +spimdisasm>=1.24.2 rabbitizer>=1.8.0 pygfxd n64img>=0.1.4 diff --git a/src/splat/__init__.py b/src/splat/__init__.py index 27c85e47..902ac341 100644 --- a/src/splat/__init__.py +++ b/src/splat/__init__.py @@ -3,7 +3,7 @@ __package_name__ = __name__ # Should be synced with pyproject.toml -__version__ = "0.23.0" +__version__ = "0.24.1" __author__ = "ethteck" from . import util as util diff --git a/src/splat/disassembler/spimdisasm_disassembler.py b/src/splat/disassembler/spimdisasm_disassembler.py index 42b28125..d75a622e 100644 --- a/src/splat/disassembler/spimdisasm_disassembler.py +++ b/src/splat/disassembler/spimdisasm_disassembler.py @@ -7,7 +7,7 @@ class SpimdisasmDisassembler(disassembler.Disassembler): # This value should be kept in sync with the version listed on requirements.txt and pyproject.toml - SPIMDISASM_MIN = (1, 23, 0) + SPIMDISASM_MIN = (1, 24, 2) def configure(self): # Configure spimdisasm @@ -71,6 +71,8 @@ def configure(self): spimdisasm.common.GlobalConfig.COMPILER = spimdisasm.common.Compiler.GCC elif selected_compiler == compiler.IDO: spimdisasm.common.GlobalConfig.COMPILER = spimdisasm.common.Compiler.IDO + elif selected_compiler == compiler.EEGCC: + spimdisasm.common.GlobalConfig.COMPILER = spimdisasm.common.Compiler.EEGCC spimdisasm.common.GlobalConfig.DETECT_REDUNDANT_FUNCTION_END = ( options.opts.detect_redundant_function_end diff --git a/src/splat/platforms/ps2.py b/src/splat/platforms/ps2.py index 11bd9c76..fbc0ffe7 100644 --- a/src/splat/platforms/ps2.py +++ b/src/splat/platforms/ps2.py @@ -8,3 +8,4 @@ def init(target_bytes: bytes): rabbitizer.config.toolchainTweaks_treatJAsUnconditionalBranch = False spimdisasm.common.GlobalConfig.ABI = spimdisasm.common.Abi.EABI64 + spimdisasm.common.GlobalConfig.SYMBOL_ALIGNMENT_REQUIRES_ALIGNED_SECTION = True diff --git a/src/splat/segtypes/common/c.py b/src/splat/segtypes/common/c.py index a1c3d289..dcfa99e5 100644 --- a/src/splat/segtypes/common/c.py +++ b/src/splat/segtypes/common/c.py @@ -7,7 +7,7 @@ import spimdisasm from ...util import log, options, symbols -from ...util.compiler import GCC, SN64, IDO +from ...util.compiler import IDO from ...util.symbols import Symbol from .codesubsegment import CommonSegCodeSubsegment @@ -105,19 +105,19 @@ def find_include_rodata(text: str): def get_global_asm_funcs(c_file: Path) -> Set[str]: with c_file.open() as f: text = CommonSegC.strip_c_comments(f.read()) - if options.opts.compiler in [GCC, SN64]: - return set(CommonSegC.find_include_asm(text)) - else: + if options.opts.compiler == IDO: return set(m.group(2) for m in C_GLOBAL_ASM_IDO_RE.finditer(text)) + else: + return set(CommonSegC.find_include_asm(text)) @staticmethod def get_global_asm_rodata_syms(c_file: Path) -> Set[str]: with c_file.open() as f: text = CommonSegC.strip_c_comments(f.read()) - if options.opts.compiler in [GCC, SN64]: - return set(CommonSegC.find_include_rodata(text)) - else: + if options.opts.compiler == IDO: return set(m.group(2) for m in C_GLOBAL_ASM_IDO_RE.finditer(text)) + else: + return set(CommonSegC.find_include_rodata(text)) @staticmethod def is_text() -> bool: diff --git a/src/splat/util/compiler.py b/src/splat/util/compiler.py index 3c67e598..970cf6c1 100644 --- a/src/splat/util/compiler.py +++ b/src/splat/util/compiler.py @@ -34,7 +34,9 @@ class Compiler: IDO = Compiler("IDO", include_macro_inc=False, asm_emit_size_directive=False) -compiler_for_name = {"GCC": GCC, "SN64": SN64, "IDO": IDO} +EEGCC = Compiler("EEGCC") + +compiler_for_name = {"GCC": GCC, "SN64": SN64, "IDO": IDO, "EEGCC": EEGCC} def for_name(name: str) -> Compiler: