Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bss/sbss asm files not being generated #422

Merged
merged 4 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# splat Release Notes

### 0.29.0

* Fix bss/sbss asm files not being generated.
* Remove `...` as a valid rom start address for segments.

### 0.28.2

* New global option and per-segment option: `suggestion_rodata_section_start`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.28.2,<1.0.0
splat64[mips]>=0.29.0,<1.0.0
```

### Optional dependencies
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "splat64"
# Should be synced with src/splat/__init__.py
version = "0.28.2"
version = "0.29.0"
description = "A binary splitting tool to assist with decompilation and modding projects"
readme = "README.md"
license = {file = "LICENSE"}
Expand Down
2 changes: 1 addition & 1 deletion src/splat/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__package_name__ = __name__

# Should be synced with pyproject.toml
__version__ = "0.28.2"
__version__ = "0.29.0"
__author__ = "ethteck"

from . import util as util
Expand Down
6 changes: 4 additions & 2 deletions src/splat/scripts/split.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ def initialize_segments(config_segments: Union[dict, list]) -> List[Segment]:

segment_class = Segment.get_class_for_type(seg_type)

this_start = Segment.parse_segment_start(seg_yaml)
this_start, is_auto_segment = Segment.parse_segment_start(seg_yaml)

j = i + 1
while j < len(config_segments):
next_start = Segment.parse_segment_start(config_segments[j])
next_start, next_is_auto_segment = Segment.parse_segment_start(
config_segments[j]
)
if next_start is not None:
break
j += 1
Expand Down
8 changes: 4 additions & 4 deletions src/splat/segtypes/common/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,11 @@ def parse_subsegments(self, segment_yaml) -> List[Segment]:
continue

typ = Segment.parse_segment_type(subsegment_yaml)
start = Segment.parse_segment_start(subsegment_yaml)
start, is_auto_segment = Segment.parse_segment_start(subsegment_yaml)

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 All @@ -198,7 +196,9 @@ def parse_subsegments(self, segment_yaml) -> List[Segment]:
# Third, try to get the end address from the next segment with a start address
end: Optional[int] = None
if i < len(segment_yaml["subsegments"]) - 1:
end = Segment.parse_segment_start(segment_yaml["subsegments"][i + 1])
end, end_is_auto_segment = Segment.parse_segment_start(
segment_yaml["subsegments"][i + 1]
)
if start is not None and end is None:
est_size = segment_class.estimate_size(subsegment_yaml)
if est_size is not None:
Expand Down
12 changes: 6 additions & 6 deletions src/splat/segtypes/common/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ def __init__(

self.subsegments: List[Segment] = self.parse_subsegments(yaml)

def get_next_seg_start(self, i, subsegment_yamls):
def get_next_seg_start(self, i, subsegment_yamls) -> Optional[int]:
j = i + 1
while j < len(subsegment_yamls):
ret = Segment.parse_segment_start(subsegment_yamls[j])
ret, is_auto_segment = Segment.parse_segment_start(subsegment_yamls[j])
if ret is not None:
return ret
j += 1
Expand All @@ -55,13 +55,11 @@ def parse_subsegments(self, yaml) -> List[Segment]:
continue

typ = Segment.parse_segment_type(subsegment_yaml)
start = Segment.parse_segment_start(subsegment_yaml)
start, is_auto_segment = Segment.parse_segment_start(subsegment_yaml)

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 All @@ -75,7 +73,9 @@ def parse_subsegments(self, yaml) -> List[Segment]:
# Third, try to get the end address from the next segment with a start address
end: Optional[int] = None
if i < len(yaml["subsegments"]) - 1:
end = Segment.parse_segment_start(yaml["subsegments"][i + 1])
end, end_is_auto_segment = Segment.parse_segment_start(
yaml["subsegments"][i + 1]
)
if start is not None and end is None:
est_size = segment_class.estimate_size(subsegment_yaml)
if est_size is not None:
Expand Down
24 changes: 17 additions & 7 deletions src/splat/segtypes/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import importlib.util
from pathlib import Path

from typing import Dict, List, Optional, Set, Type, TYPE_CHECKING, Union
from typing import Dict, List, Optional, Set, Type, TYPE_CHECKING, Union, Tuple

from intervaltree import Interval, IntervalTree
from ..util import vram_classes
Expand Down Expand Up @@ -135,18 +135,28 @@ def get_extension_segment_class(seg_type):
)

@staticmethod
def parse_segment_start(segment: Union[dict, list]) -> Optional[int]:
def parse_segment_start(segment: Union[dict, list]) -> Tuple[Optional[int], bool]:
"""
Parses the rom start address of a given segment.

Returns a two-tuple containing:
- The rom start address of the segment, if any.
- `True` if the user explicitly specified `auto` as the start address.
Note this will be `False` if user specified an actual number or did not specify anything at all (in the dict notation).
Not specifying a explicit `start` is useful for `bss`/`sbss` segments, since they do not have a real rom address.
"""

if isinstance(segment, dict):
s = segment.get("start", "auto")
s = segment.get("start", None)
else:
s = segment[0]

if s is None:
return None, False
if s == "auto":
return None
elif s == "...":
return None
return None, True
else:
return int(s)
return int(s), False

@staticmethod
def parse_segment_type(segment: Union[dict, list]) -> str:
Expand Down