Assign section locations to all UNIONs/FRAGMENTs

Fixes the test case from #800

The `out.gb` output was corrected, since the two "test"
fragments have a different order in ROM than in SRAM.
It is effectively:

; ROM0[$0000], fragments ordered by size
    jr Label
    dw Label
    db 0

; SRAM[$a000], fragments ordered by .o order
    ds 1  ; db 0
    ds 2  ; jr Label
Label:    ; $a003
    ds 2  ; dw Label
This commit is contained in:
Rangi
2021-03-28 15:21:17 -04:00
parent 7461170956
commit 7e7f92f18c
3 changed files with 8 additions and 2 deletions

View File

@@ -112,6 +112,13 @@ static inline void assignSection(struct Section *section,
section->org = location->address;
section->bank = location->bank;
// Propagate the assigned location to all UNIONs/FRAGMENTs
// so `jr` patches in them will have the correct offset
for (struct Section *next = section->nextu; next != NULL; next = next->nextu) {
next->org = section->org;
next->bank = section->bank;
}
nbSectionsToAssign--;
out_AddSection(section);