Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement smart linking #654

Closed
wants to merge 2 commits into from
Closed

Implement smart linking #654

wants to merge 2 commits into from

Conversation

ISSOtm
Copy link
Member

@ISSOtm ISSOtm commented Dec 20, 2020

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)

Long-broken feature, fell into disrepair, got removed...
Now it's back! Though, it needs testing.
Fixes gbdev#82
@Rangi42
Copy link
Contributor

Rangi42 commented Dec 20, 2020

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.

@ISSOtm
Copy link
Member Author

ISSOtm commented Dec 20, 2020

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

@Rangi42
Copy link
Contributor

Rangi42 commented Dec 20, 2020

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.

@daid daid mentioned this pull request Mar 4, 2021
4 tasks
@Rangi42 Rangi42 added enhancement Typically new features; lesser priority than bugs rgblink This affects RGBLINK labels Mar 26, 2021
@Rangi42 Rangi42 added the WIP This PR is a work in progress label May 5, 2021
@Rangi42 Rangi42 mentioned this pull request Mar 27, 2024
4 tasks
@Rangi42
Copy link
Contributor

Rangi42 commented Mar 27, 2024

Superseded by #1382.

@Rangi42 Rangi42 closed this Mar 27, 2024
@ISSOtm ISSOtm deleted the smart branch August 30, 2024 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Typically new features; lesser priority than bugs rgblink This affects RGBLINK WIP This PR is a work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Smart linking
2 participants