-
-
Notifications
You must be signed in to change notification settings - Fork 175
Implement smart linking, take 3 #1382
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
base: master
Are you sure you want to change the base?
Conversation
4c242e1
to
7f81f1e
Compare
One of the test cases from #782 currently fails. Note that #782 failed it as well, so that's a TODO.
This is the asm: SECTION "root", ROM0[0]
dw WRAMLabel
; This section should be kept thanks to the reference from the WRAM section
SECTION "A", ROM0
Label:
db $01, $02
.end:
SECTION "wram", WRAM0
WRAMLabel:
ds Label.end - Label
SECTION "UnRef", ROM0
UnRef:
db UnRef |
f67797a
to
64cedb2
Compare
Not sure why that would be a valid test. There is no way to know where section |
RGBASM is able to compute the difference between these two labels itself, and so it does: the Yet, since section |
At a detailed source level, yes, it contains a reference. But at a practical level higher overview, it does not contain a reference. It only contains a reference to the size (which is constant, and thus can be pre-computed before linking) IMHO, it's one of those edge cases that does not require to work as there is no practical usage of this in any way. While fixing it is annoyingly needlessly complicated. |
Before this is merged, I should probably say that specifying the starting sections in the command line isn't the best idea. Of course, this doesn't mean that the command line flag cannot be used, but I'd expect to see a way to specify this in code — which would also function as an escape hatch for the above "should this section be included?" problem. |
IIRC we wanted the linker script to also support designating root sections. |
8fd60eb
to
656b87d
Compare
Proposal: add an (This would be a new expression type so the existing @ISSOtm @daid What do you think? Edit: Oh, y'all discussed the exemplifying test case already. I agree with ISSOtm that using |
fe2d958
to
e9af039
Compare
62da49f
to
e958055
Compare
aa7a745
to
6d6da0d
Compare
ca7ff98
to
b0771cb
Compare
e645325
to
785f338
Compare
785f338
to
4f95655
Compare
fccb25b
to
ca8bcc2
Compare
ca8bcc2
to
529086b
Compare
529086b
to
5a2f161
Compare
Instead of a The downside there would be the same as adding @ISSOtm What do you think? |
Also, this only implements the Do we want linkerscripts to be able to reference sections, e.g. as We could go further -- should .asm files be able to reference sections, e.g. as (Note that although we've been colloquially calling these manually-referenced sections "root" sections in issue+PR+Discord discussion, the man page and source code don't actually use that term. So we wouldn't want to add e.g. a |
The linker script can already reference existing sections, possibly as I'm not sure what the use case is for referencing sections without an actual reference (be it via a symbol, or via the section's name directly e.g. |
What do you mean? If I have a
The ASMotor's smart linking feature works by doing |
That sounds wrong: the behaviour I'd find intuitive is
This seems sufficient, as the roots of the Control Flow Graph (CFG, borrowed from compiler literature) are
...both of which are fully-constrained, and should reference the rest of the graph via symbols. |
I'm starting to think that registering that information separately, rather than trying to muck with expressions, is a simpler solution. Notably, it separates that concern from the already-complex expression systems (plural, because there's the “client” part in RGBASM, and the “server” part in RGBLINK); and we can then use a dedicated, more compact format in the object file (for example, adding a |
Fixes #82.
Replaces #654 and #782. Many thanks to @ISSOtm and @daid for getting smart linking to this point!
-s
referenced sections