Skip to content

Commit

Permalink
Improve 'next' segment rom pos finding behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
ethteck committed Jan 8, 2024
1 parent 04e2942 commit ef21c40
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# splat Release Notes

### 0.21.2
* Fix bugs involving segments not having proper end rom positions if followed by segments with "auto" rom addresses; splat will now skip over these properly

### 0.21.1

* Fix duplicated symbol resolution in symbol_addrs.txt file.
Expand Down
12 changes: 8 additions & 4 deletions src/splat/scripts/split.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,14 @@ def initialize_segments(config_segments: Union[dict, list]) -> List[Segment]:

this_start = Segment.parse_segment_start(seg_yaml)

if i == len(config_segments) - 1 and Segment.parse_segment_file_path(seg_yaml):
next_start: Optional[int] = 0
else:
next_start = Segment.parse_segment_start(config_segments[i + 1])
j = i + 1
while j < len(config_segments):
next_start = Segment.parse_segment_start(config_segments[j])
if next_start is not None:
break
j += 1
if next_start is None:
log.error("Next segment address could not be found. Segments list must end with a rom end pos marker ([0x10000000])")

if segment_class.is_noload():
# Pretend bss's rom address is after the last actual rom segment
Expand Down
14 changes: 9 additions & 5 deletions src/splat/segtypes/common/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ def __init__(
self.subsegments: List[Segment] = self.parse_subsegments(yaml)

def get_next_seg_start(self, i, subsegment_yamls):
return (
self.rom_end
if i == len(subsegment_yamls) - 1
else Segment.parse_segment_start(subsegment_yamls[i + 1])
)
j = i + 1
while j < len(subsegment_yamls):
ret = Segment.parse_segment_start(subsegment_yamls[j])
if ret is not None:
return ret
j += 1

# Fallback
return self.rom_end

def parse_subsegments(self, yaml) -> List[Segment]:
ret: List[Segment] = []
Expand Down

0 comments on commit ef21c40

Please sign in to comment.