Skip to content

Commit 90ba6c9

Browse files
authored
Fix make_full_disasm_for_code not extracting data-only TUs. (#508)
Allows to disassemble data-only sections by declaring an `auto` c subsegment with the same name Fixes #507
1 parent 9ef787e commit 90ba6c9

File tree

8 files changed

+31
-19
lines changed

8 files changed

+31
-19
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# splat Release Notes
22

3+
### 0.37.1
4+
5+
* Fix `make_full_disasm_for_code` not extracting data-only TUs.
6+
37
### 0.37.0
48

59
* Add define check to allow using `macro.inc` instead of `labels.inc` in `include_asm.h`.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The brackets corresponds to the optional dependencies to install while installin
2121
If you use a `requirements.txt` file in your repository, then you can add this library with the following line:
2222

2323
```txt
24-
splat64[mips]>=0.37.0,<1.0.0
24+
splat64[mips]>=0.37.1,<1.0.0
2525
```
2626

2727
### Optional dependencies

docs/Configuration.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,16 @@ Emit a full `.s` file for each `c`/`cpp` segment containing disassembly of .text
848848

849849
Can be used to generate "target" or "expected" objects for asm diffing.
850850

851+
To generate `.s` files for data-only TUs (or rodata/bss only, or any other combination that doesn't have a text section) a dummy `c` or `cpp` section with the same name as the data section must be defined in the yaml with an start value of `auto` instead of a number. For example:
852+
853+
```yaml
854+
- [auto, c, boot/rom_offsets]
855+
856+
# -- Other c or data subsegments --
857+
858+
- [0x00F340, .data, boot/rom_offsets]
859+
```
860+
851861
### global_vram_start and global_vram_end
852862

853863
Allow specifying that the global memory range may be larger than what was automatically detected.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "splat64"
33
# Should be synced with src/splat/__init__.py
4-
version = "0.37.0"
4+
version = "0.37.1"
55
description = "A binary splitting tool to assist with decompilation and modding projects"
66
readme = "README.md"
77
license = {file = "LICENSE"}

src/splat/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
__package_name__ = __name__
22

33
# Should be synced with pyproject.toml
4-
__version__ = "0.37.0"
4+
__version__ = "0.37.1"
55
__author__ = "ethteck"
66

77
from . import util as util

src/splat/segtypes/common/c.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ def scan(self, rom_bytes: bytes):
152152

153153
def split(self, rom_bytes: bytes):
154154
if self.is_auto_segment:
155+
if options.opts.make_full_disasm_for_code:
156+
self.split_as_asmtu_file(self.asm_out_path())
155157
return
156158

157159
if self.rom_start != self.rom_end:

src/splat/segtypes/common/codesubsegment.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -252,22 +252,21 @@ def split_as_asm_file(self, out_path: Optional[Path]):
252252
f.write(self.spim_section.disassemble())
253253

254254
# Same as above but write all sections from siblings
255-
def split_as_asmtu_file(self, out_path: Optional[Path]):
256-
if self.spim_section is None:
257-
return
258-
259-
if not out_path:
260-
return
261-
255+
def split_as_asmtu_file(self, out_path: Path):
262256
out_path.parent.mkdir(parents=True, exist_ok=True)
263257

264258
self.print_file_boundaries()
265259

266260
with open(out_path, "w", newline="\n") as f:
267-
# Write `.text` contents
268-
for line in self.get_asm_file_header():
269-
f.write(line + "\n")
270-
f.write(self.spim_section.disassemble())
261+
# self.spim_section would be None if the current section was
262+
# declared `auto` in the yaml.
263+
# This can be useful when there are TUs with only data/rodata/bss/etc
264+
# sections but not text section.
265+
if self.spim_section is not None:
266+
# Write `.text` contents
267+
for line in self.get_asm_file_header():
268+
f.write(line + "\n")
269+
f.write(self.spim_section.disassemble())
271270

272271
# Disassemble the siblings to this file by respecting the `section_order`
273272
for sect in self.section_order:
@@ -287,13 +286,13 @@ def split_as_asmtu_file(self, out_path: Optional[Path]):
287286
f.write(f"{sibling.get_section_asm_line()}\n\n")
288287
f.write(sibling.spim_section.disassemble())
289288

290-
# Another loop to check anything that somehow may not be present on the `section_order`
289+
# Another loop to check anything that somehow may not be present in the `section_order`
291290
for sect, sibling in self.siblings.items():
292291
if sect == self.get_linker_section_linksection():
293292
continue
294293

295294
if sect in self.section_order:
296-
# Already handled on the above loop
295+
# Already handled in the above loop
297296
continue
298297

299298
if (

src/splat/util/file_presets.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ def write_include_asm_h():
4242
return
4343

4444
directory = options.opts.generated_asm_macros_directory.as_posix()
45-
print()
46-
print(directory)
47-
print()
4845

4946
if options.opts.include_asm_macro_style == "maspsx_hack":
5047
include_asm_macro = """\

0 commit comments

Comments
 (0)