diff --git a/CHANGELOG.md b/CHANGELOG.md index 4225c35f..2fe6680d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/src/splat/scripts/split.py b/src/splat/scripts/split.py index 84179a76..c4af4dc1 100644 --- a/src/splat/scripts/split.py +++ b/src/splat/scripts/split.py @@ -56,10 +56,16 @@ 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 diff --git a/src/splat/segtypes/common/group.py b/src/splat/segtypes/common/group.py index 5e5b3d2a..7bfd2a46 100644 --- a/src/splat/segtypes/common/group.py +++ b/src/splat/segtypes/common/group.py @@ -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] = []