rgbds icon indicating copy to clipboard operation
rgbds copied to clipboard

Implement smart linking

Open ISSOtm opened this issue 4 years ago • 3 comments

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)

ISSOtm avatar Dec 20 '20 01:12 ISSOtm

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.

Rangi42 avatar Dec 20 '20 01:12 Rangi42

That's not necessarily the case for sections with other constraints, either.

ISSOtm avatar Dec 20 '20 16:12 ISSOtm

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.

Rangi42 avatar Dec 20 '20 17:12 Rangi42

Superseded by #1382.

Rangi42 avatar Mar 27 '24 19:03 Rangi42