mirror of
https://github.com/zeldaret/af.git
synced 2026-09-27 05:55:46 -04:00
ce93cd0262
* git subrepo pull --force tools/asm-processor
subrepo:
subdir: "tools/asm-processor"
merged: "6dd4d3a"
upstream:
origin: "git@github.com:simonlindholm/asm-processor.git"
branch: "main"
commit: "6dd4d3a"
git-subrepo:
version: "0.4.3"
origin: "https://github.com/ingydotnet/git-subrepo.git"
commit: "2f68596"
* git subrepo pull lib/ultralib --force
subrepo:
subdir: "lib/ultralib"
merged: "0417857"
upstream:
origin: "git@github.com:decompals/ultralib.git"
branch: "main"
commit: "0417857"
git-subrepo:
version: "0.4.3"
origin: "https://github.com/ingydotnet/git-subrepo.git"
commit: "2f68596"
* git subrepo pull tools/asm-differ --force
subrepo:
subdir: "tools/asm-differ"
merged: "6d3e4c4"
upstream:
origin: "git@github.com:simonlindholm/asm-differ.git"
branch: "main"
commit: "6d3e4c4"
git-subrepo:
version: "0.4.3"
origin: "https://github.com/ingydotnet/git-subrepo.git"
commit: "2f68596"
* git subrepo pull tools/splat --force
subrepo:
subdir: "tools/splat"
merged: "406b646"
upstream:
origin: "git@github.com:ethteck/splat.git"
branch: "master"
commit: "406b646"
git-subrepo:
version: "0.4.3"
origin: "https://github.com/ingydotnet/git-subrepo.git"
commit: "2f68596"
* Revert "git subrepo pull lib/ultralib --force"
This reverts commit da9fca47be.
* git subrepo pull tools/splat
subrepo:
subdir: "tools/splat"
merged: "7869ef2"
upstream:
origin: "git@github.com:ethteck/splat.git"
branch: "master"
commit: "7869ef2"
git-subrepo:
version: "0.4.3"
origin: "https://github.com/ingydotnet/git-subrepo.git"
commit: "2f68596"
* Disable asm size directive
284 lines
6.4 KiB
Python
284 lines
6.4 KiB
Python
import spimdisasm
|
|
from util import symbols
|
|
from typing import Optional, Set, Tuple
|
|
from segtypes.segment import Segment
|
|
from util import log, options, symbols
|
|
|
|
|
|
from abc import ABC, abstractmethod
|
|
from typing import Callable
|
|
|
|
|
|
class DisassemblerSection(ABC):
|
|
@abstractmethod
|
|
def disassemble(self):
|
|
raise NotImplementedError("disassemble")
|
|
|
|
@abstractmethod
|
|
def analyze(self):
|
|
raise NotImplementedError("analyze")
|
|
|
|
@abstractmethod
|
|
def set_comment_offset(self, rom_start: int):
|
|
raise NotImplementedError("set_comment_offset")
|
|
|
|
@abstractmethod
|
|
def make_bss_section(
|
|
self,
|
|
rom_start,
|
|
rom_end,
|
|
vram_start,
|
|
bss_end,
|
|
name,
|
|
segment_rom_start,
|
|
exclusive_ram_id,
|
|
):
|
|
raise NotImplementedError("make_bss_section")
|
|
|
|
@abstractmethod
|
|
def make_data_section(
|
|
self,
|
|
rom_start,
|
|
rom_end,
|
|
vram_start,
|
|
name,
|
|
rom_bytes,
|
|
segment_rom_start,
|
|
exclusive_ram_id,
|
|
):
|
|
raise NotImplementedError("make_data_section")
|
|
|
|
@abstractmethod
|
|
def get_section(self):
|
|
raise NotImplementedError("get_section")
|
|
|
|
@abstractmethod
|
|
def make_rodata_section(
|
|
self,
|
|
rom_start,
|
|
rom_end,
|
|
vram_start,
|
|
name,
|
|
rom_bytes,
|
|
segment_rom_start,
|
|
exclusive_ram_id,
|
|
):
|
|
raise NotImplementedError("make_rodata_section")
|
|
|
|
@abstractmethod
|
|
def make_text_section(
|
|
self,
|
|
rom_start,
|
|
rom_end,
|
|
vram_start,
|
|
name,
|
|
rom_bytes,
|
|
segment_rom_start,
|
|
exclusive_ram_id,
|
|
):
|
|
raise NotImplementedError("make_text_section")
|
|
|
|
|
|
class SpimdisasmDisassemberSection(DisassemblerSection):
|
|
def __init__(self):
|
|
self.spim_section: Optional[spimdisasm.mips.sections.SectionBase] = None
|
|
|
|
def disassemble(self) -> str:
|
|
assert self.spim_section is not None
|
|
return self.spim_section.disassemble()
|
|
|
|
def analyze(self):
|
|
assert self.spim_section is not None
|
|
self.spim_section.analyze()
|
|
|
|
def set_comment_offset(self, rom_start: int):
|
|
assert self.spim_section is not None
|
|
self.spim_section.setCommentOffset(rom_start)
|
|
|
|
def make_bss_section(
|
|
self,
|
|
rom_start: int,
|
|
rom_end: int,
|
|
vram_start: int,
|
|
bss_end: int,
|
|
name: str,
|
|
segment_rom_start: int,
|
|
exclusive_ram_id,
|
|
):
|
|
self.spim_section = spimdisasm.mips.sections.SectionBss(
|
|
symbols.spim_context,
|
|
rom_start,
|
|
rom_end,
|
|
vram_start,
|
|
bss_end,
|
|
name,
|
|
segment_rom_start,
|
|
exclusive_ram_id,
|
|
)
|
|
|
|
def make_data_section(
|
|
self,
|
|
rom_start: int,
|
|
rom_end: int,
|
|
vram_start: int,
|
|
name: str,
|
|
rom_bytes: bytes,
|
|
segment_rom_start: int,
|
|
exclusive_ram_id,
|
|
):
|
|
self.spim_section = spimdisasm.mips.sections.SectionData(
|
|
symbols.spim_context,
|
|
rom_start,
|
|
rom_end,
|
|
vram_start,
|
|
name,
|
|
rom_bytes,
|
|
segment_rom_start,
|
|
exclusive_ram_id,
|
|
)
|
|
|
|
def get_section(self) -> Optional[spimdisasm.mips.sections.SectionBase]:
|
|
return self.spim_section
|
|
|
|
def make_rodata_section(
|
|
self,
|
|
rom_start: int,
|
|
rom_end: int,
|
|
vram_start: int,
|
|
name: str,
|
|
rom_bytes: bytes,
|
|
segment_rom_start: int,
|
|
exclusive_ram_id,
|
|
):
|
|
self.spim_section = spimdisasm.mips.sections.SectionRodata(
|
|
symbols.spim_context,
|
|
rom_start,
|
|
rom_end,
|
|
vram_start,
|
|
name,
|
|
rom_bytes,
|
|
segment_rom_start,
|
|
exclusive_ram_id,
|
|
)
|
|
|
|
def make_text_section(
|
|
self,
|
|
rom_start: int,
|
|
rom_end: int,
|
|
vram_start: int,
|
|
name: str,
|
|
rom_bytes: bytes,
|
|
segment_rom_start: int,
|
|
exclusive_ram_id,
|
|
):
|
|
self.spim_section = spimdisasm.mips.sections.SectionText(
|
|
symbols.spim_context,
|
|
rom_start,
|
|
rom_end,
|
|
vram_start,
|
|
name,
|
|
rom_bytes,
|
|
segment_rom_start,
|
|
exclusive_ram_id,
|
|
)
|
|
|
|
|
|
def make_disassembler_section() -> Optional[SpimdisasmDisassemberSection]:
|
|
if options.opts.platform in ["n64", "psx", "ps2"]:
|
|
return SpimdisasmDisassemberSection()
|
|
|
|
raise NotImplementedError("No disassembler section for requested platform")
|
|
return None
|
|
|
|
|
|
def make_text_section(
|
|
rom_start: int,
|
|
rom_end: int,
|
|
vram_start: int,
|
|
name: str,
|
|
rom_bytes: bytes,
|
|
segment_rom_start: int,
|
|
exclusive_ram_id,
|
|
) -> DisassemblerSection:
|
|
section = make_disassembler_section()
|
|
assert section is not None
|
|
section.make_text_section(
|
|
rom_start,
|
|
rom_end,
|
|
vram_start,
|
|
name,
|
|
rom_bytes,
|
|
segment_rom_start,
|
|
exclusive_ram_id,
|
|
)
|
|
return section
|
|
|
|
|
|
def make_data_section(
|
|
rom_start: int,
|
|
rom_end: int,
|
|
vram_start: int,
|
|
name: str,
|
|
rom_bytes: bytes,
|
|
segment_rom_start: int,
|
|
exclusive_ram_id,
|
|
) -> DisassemblerSection:
|
|
section = make_disassembler_section()
|
|
assert section is not None
|
|
section.make_data_section(
|
|
rom_start,
|
|
rom_end,
|
|
vram_start,
|
|
name,
|
|
rom_bytes,
|
|
segment_rom_start,
|
|
exclusive_ram_id,
|
|
)
|
|
return section
|
|
|
|
|
|
def make_rodata_section(
|
|
rom_start: int,
|
|
rom_end: int,
|
|
vram_start: int,
|
|
name: str,
|
|
rom_bytes: bytes,
|
|
segment_rom_start: int,
|
|
exclusive_ram_id,
|
|
) -> DisassemblerSection:
|
|
section = make_disassembler_section()
|
|
assert section is not None
|
|
section.make_rodata_section(
|
|
rom_start,
|
|
rom_end,
|
|
vram_start,
|
|
name,
|
|
rom_bytes,
|
|
segment_rom_start,
|
|
exclusive_ram_id,
|
|
)
|
|
return section
|
|
|
|
|
|
def make_bss_section(
|
|
rom_start: int,
|
|
rom_end: int,
|
|
vram_start: int,
|
|
bss_end: int,
|
|
name: str,
|
|
segment_rom_start: int,
|
|
exclusive_ram_id,
|
|
) -> DisassemblerSection:
|
|
section = make_disassembler_section()
|
|
assert section is not None
|
|
section.make_bss_section(
|
|
rom_start,
|
|
rom_end,
|
|
vram_start,
|
|
bss_end,
|
|
name,
|
|
segment_rom_start,
|
|
exclusive_ram_id,
|
|
)
|
|
return section
|