rgbds
rgbds copied to clipboard
Implement smart linking
Fixes #82.
- [ ] Add a mechanism so that RGBASM-elided references are still emitted
- [ ] Add more tests covering more edge cases
- [ ] Sections should not be purged if fully constrained
- [ ] Apply smart linking after linker script (avoids errors & interacts with above)
I don't think align should constrain a section. Consider:
SECTION "ReverseBits", ROM0
ReverseBits::
push hl
ld h, HIGH(ReversedBitTable)
ld l, a
ld a, [hl]
pop hl
ret
SECTION "ReversedBitTable", ROM0, ALIGN[8]
ReversedBitTable::
x = 0
REPT 256
; http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith32Bits
db LOW(((((x * $802) & $22110) | ((x * $8020) & $88440)) * $10101) >> 16)
x = x + 1
ENDR
If ReverseBits is never called, neither section is needed.
That's not necessarily the case for sections with other constraints, either.
Is there an example of when some content would need to be in a specific bank or at a specific address, but could also be excluded entirely?
Edit: "references to sections whose bank and/or address are fixed" can get evaluated early by rgbasm, making rgblink not see them as references; but just aligning a section can't do that AFAIK, so it wouldn't need to count.
Superseded by #1382.