You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Segments.md
+33Lines changed: 33 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -583,3 +583,36 @@ Defaults to the global option.
583
583
vram: 0x80000460
584
584
suggestion_rodata_section_start: False
585
585
```
586
+
587
+
### `pair_segment`
588
+
589
+
Allows pairing sections of two different segments together.
590
+
591
+
The main purpose of this is to make the automatic rodata-to-function migration possible, since the default behavior only allows pairing different sections of the same name under the same segment only. This kind of ROM layout can be seen on some TLB games from N64 projects.
592
+
593
+
This value expects the name of the other segment that should be paired to the current one. Only one of the two to-be-paired segments should have this attribute.
594
+
595
+
**Example:**
596
+
597
+
```yaml
598
+
- name: init
599
+
type: code
600
+
start: 0x00001000
601
+
vram: 0x10001000
602
+
pair_segment: init_data # This is the name of the following segment.
603
+
subsegments:
604
+
# -- snip --
605
+
- [0x15550, c, libultra/audio/init_15550]
606
+
# -- snip --
607
+
608
+
- name: init_data
609
+
type: code
610
+
start: 0x000290D0
611
+
vram: 0x800290D0
612
+
bss_size: 0x16690
613
+
# Note there's no `pair_segment: init` on this segment.
# We found the other segment specified by `pair_segment`
134
+
135
+
ifother_seg.pair_segment_nameisnotNone:
136
+
log.error(
137
+
f"Both segments '{seg.name}' and '{other_seg.name}' have a `pair_segment` value, when only at most one of the cross-paired segments can have this attribute."
138
+
)
139
+
140
+
# Not user error, hopefully...
141
+
assert (
142
+
seg.paired_segmentisNone
143
+
), f"Somehow '{seg.name}' was already paired so something else? It is paired to '{seg.paired_segment.name}' instead of {other_seg.name}"
144
+
assert (
145
+
other_seg.paired_segmentisNone
146
+
), f"Somehow '{other_seg.name}' was already paired so something else? It is paired to '{other_seg.paired_segment.name}' instead of {seg.name}"
147
+
148
+
found=True
149
+
# Pair them
150
+
seg.paired_segment=other_seg
151
+
other_seg.paired_segment=seg
152
+
153
+
ifisinstance(seg, CommonSegGroup) andisinstance(
154
+
other_seg, CommonSegGroup
155
+
):
156
+
# Pair the subsegments
157
+
seg.pair_subsegments_to_other_segment(other_seg)
158
+
159
+
break
160
+
161
+
ifnotfound:
162
+
log.error(
163
+
f"Segment '{seg.pair_segment_name}' not found.\n It is referenced by segment '{seg.name}', because of the `pair_segment` attribute."
0 commit comments