Skip to content

Commit

Permalink
Avoid running spimdisasm on auto segments (#417)
Browse files Browse the repository at this point in the history
* Avoid running spimdisasm on auto segments

* version
  • Loading branch information
AngheloAlf authored Nov 18, 2024
1 parent fc8779a commit 7fae116
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### 0.28.2

* Avoid running spimdisasm on auto segments.
* Should improve runtime performance and avoid giving redundant filesplit suggestions.
* A zero-sized bin segment is considered a hard error.

### 0.28.1
Expand Down
3 changes: 3 additions & 0 deletions src/splat/segtypes/common/bss.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def disassemble_data(self, rom_bytes: bytes):
super().disassemble_data(rom_bytes)
return

if self.is_auto_segment:
return

if not isinstance(self.rom_start, int):
log.error(
f"Segment '{self.name}' (type '{self.type}') requires a rom_start. Got '{self.rom_start}'"
Expand Down
3 changes: 3 additions & 0 deletions src/splat/segtypes/common/c.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ def scan(self, rom_bytes: bytes):
self.scan_code(rom_bytes)

def split(self, rom_bytes: bytes):
if self.is_auto_segment:
return

if self.rom_start != self.rom_end:
asm_out_dir = options.opts.nonmatchings_path / self.dir
matching_asm_out_dir = options.opts.matchings_path / self.dir
Expand Down
4 changes: 4 additions & 0 deletions src/splat/segtypes/common/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def _generate_segment_from_all(
rep.sibling = base_seg
rep.parent = self
rep.is_generated = True
rep.is_auto_segment = True
if rep.special_vram_segment:
self.special_vram_segment = True
rep.bss_contains_common = self.bss_contains_common
Expand Down Expand Up @@ -181,7 +182,9 @@ def parse_subsegments(self, segment_yaml) -> List[Segment]:

segment_class = Segment.get_class_for_type(typ)

is_auto_segment = False
if start is None:
is_auto_segment = True
# Attempt to infer the start address
if i == 0:
# The start address of this segment is the start address of the group
Expand Down Expand Up @@ -222,6 +225,7 @@ def parse_subsegments(self, segment_yaml) -> List[Segment]:
segment: Segment = Segment.from_yaml(
segment_class, subsegment_yaml, start, end, self, vram
)
segment.is_auto_segment = is_auto_segment

if (
segment.vram_start is not None
Expand Down
3 changes: 3 additions & 0 deletions src/splat/segtypes/common/codesubsegment.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ def configure_disassembler_section(
def scan_code(self, rom_bytes, is_hasm=False):
self.is_hasm = is_hasm

if self.is_auto_segment:
return

if not isinstance(self.rom_start, int):
log.error(
f"Segment '{self.name}' (type '{self.type}') requires a rom_start. Got '{self.rom_start}'"
Expand Down
6 changes: 6 additions & 0 deletions src/splat/segtypes/common/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def scan(self, rom_bytes: bytes):
self.disassemble_data(rom_bytes)

def split(self, rom_bytes: bytes):
if self.is_auto_segment:
return

super().split(rom_bytes)

if self.type.startswith(".") and not options.opts.disassemble_all:
Expand Down Expand Up @@ -98,6 +101,9 @@ def configure_disassembler_section(
section.stringEncoding = self.str_encoding

def disassemble_data(self, rom_bytes):
if self.is_auto_segment:
return

if not isinstance(self.rom_start, int):
log.error(
f"Segment '{self.name}' (type '{self.type}') requires a rom_start. Got '{self.rom_start}'"
Expand Down
3 changes: 3 additions & 0 deletions src/splat/segtypes/common/gcc_except_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def configure_disassembler_section(
section.enableStringGuessing = False

def disassemble_data(self, rom_bytes):
if self.is_auto_segment:
return

if not isinstance(self.rom_start, int):
log.error(
f"Segment '{self.name}' (type '{self.type}') requires a rom_start. Got '{self.rom_start}'"
Expand Down
3 changes: 3 additions & 0 deletions src/splat/segtypes/common/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ def parse_subsegments(self, yaml) -> List[Segment]:

segment_class = Segment.get_class_for_type(typ)

is_auto_segment = False
if start is None:
is_auto_segment = True
# Attempt to infer the start address
if i == 0:
# The start address of this segment is the start address of the group
Expand Down Expand Up @@ -106,6 +108,7 @@ def parse_subsegments(self, yaml) -> List[Segment]:
)
if segment.special_vram_segment:
self.special_vram_segment = True
segment.is_auto_segment = is_auto_segment

ret.append(segment)
prev_start = start
Expand Down
3 changes: 3 additions & 0 deletions src/splat/segtypes/common/rodata.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ def configure_disassembler_section(
section.stringEncoding = self.str_encoding

def disassemble_data(self, rom_bytes):
if self.is_auto_segment:
return

if not isinstance(self.rom_start, int):
log.error(
f"Segment '{self.name}' (type '{self.type}') requires a rom_start. Got '{self.rom_start}'"
Expand Down
3 changes: 3 additions & 0 deletions src/splat/segtypes/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ def __init__(
# True if this segment was generated based on auto_link_sections
self.is_generated: bool = False

# Is an automatic segment, generated automatically or declared on the yaml by the user
self.is_auto_segment: bool = False

if self.rom_start is not None and self.rom_end is not None:
if self.rom_start > self.rom_end:
log.error(
Expand Down

0 comments on commit 7fae116

Please sign in to comment.