-
Notifications
You must be signed in to change notification settings - Fork 3k
Remove deprecated --legacyalign from ARMC6 link #10373
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
Conversation
Going to be a sequence of scatter file adjustments here - breaking them up into 1 commit per vendor - seem commit messages for notes. |
@@ -19,8 +19,7 @@ LR_IROM1 0x00000000 0x40000 { ; load region size_region | |||
.ANY (+RO) | |||
} | |||
|
|||
; [RAM] Vector table dynamic copy: 79 vectors * 4 bytes = (0x140) - alignment | |||
RW_IRAM1 (0x20000000+0x140) (0x8000-0x140-Stack_Size) { ; RW data | |||
RW_IRAM1 (0x20000000) (0x8000-Stack_Size) { ; RW data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is vector size removed from start of RAM?
In order to remove --legacyalign every section should be 8-byte aligned and for that I updated the linker scripts (most) to have vectors and all other sections to be 8-byte aligned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explanation is in commit message: 3fea439
Not sure why Maxim is being unusual here - alternatively we could change their code to work like all the other targets.
But I do actually prefer Maxim's approach. It seems a lot simpler - just put the vectors in the normal RAM with an align directive.
Only reason I can see for the special linker map handling is that maybe it avoids stupid padding? The vectors do have a high alignment requirement (512-byte or more), so putting them at the front avoids a linker being dumb and sticking them in the middle with a huge padding block in front of them.
But are any of the linkers really that dumb?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @ARMmbed/team-maximintegrated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe that commit message isn't clear enough.
Because the Maxim build puts its vectors in main RAM, the main RAM needs to be 512-byte aligned, if you want to turn --legacyalign
off.
Taking that unused vector space out makes the main RAM 512-byte aligned.
The vector space is not there in the IAR and GCC maps.
/* [RAM] Vector table dynamic copy: 79 vectors * 4 bytes = 316 bytes (0x13C) */ | ||
define symbol __NVIC_start__ = 0x00000000; | ||
define symbol __NVIC_end__ = 0x00000140; /* to be aligned on 8 bytes */ | ||
/* [RAM] */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vector size was 79*4=0x13C (not aligned to 8-byte)
Was updated to be 8-byte aligned as 0x140. I am not sure why are we removing vector region from RAM ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to remove --legacyalign we need all regions to be 8-byte aligned in linker script.
Please explain why vector region is removed form RAM? OK i see it explained in commit message, but I don;t think it should be part of this PR. It will be good to have it as a separate PR for Maxim
@deepikabhavnani Having a seperate commit, while still being related to the PR, is acceptable. @ARMmbed/mbed-os-maintainers Thoughts? |
@cmnor - both commits are completely different its two different topics touching linker files. |
@deepikabhavnani Ah! So it is. @kjbracey-arm Please either split those commits into their own PR, or make them more relevant to this PR. |
Having made the Maxim changes I'm now getting "Region table handler '__scatterload_copy' needed by entry for RW_IRAM1 was not found." on its build, and I can't figure out why. More work required. |
Test run: FAILEDSummary: 1 of 7 test jobs failed Failed test jobs:
|
The Maxim approach looks neat, but it doesn't actually work well. It ends up wasting RAM and ROM space because of the large alignment requirement, and the block just gets blopped in the middle of all the static data, with up to 512 bytes of padding. So I'm going to change the Maxim devices to put the vectors explicitly at the RAM start like other targets. @ARMmbed/team-maximintegrated ? |
Putting the vectors in the main RAM region with 512-byte alignment causes a number of issues - linker tends to put padding in, and not fill the gap nicely. The ARM toolchain actually still had space reserved for the vectors anyway, and this triggered alignment problems when legacyalign was turned off - the unused vector space meant the main RAM wasn't 512-byte aligned. This commit removes the vector table array from main RAM, and positions the vectors at RAM start, like other targets. This avoids any excess padding. Sizes in the pre-existing ARM maps were in some cases not correct - either missing the 16 entries for the built-in exceptions, or having a slightly the wrong number of interrupts (cross-referencing against MXC_IRQ_COUNT - 32600/32610 = 79, 32620/32625 = 81, 32620C/32630 = 84). For MAX32625NEXPAQ builds, move the RAM split base to align it to 512 bytes - this is the alignment requirement for the vectors at the start. squash! Maxim: ARM alignment, remove unneeded vector space squash! Maxim: Position vectors manually, like other targets
Make sure the default handlers branch to themselves, rather than branching to the non-weak definition. Should have no effect, but avoids build warnings.
717ee98
to
0699512
Compare
@kjbracey-arm Please avoid changing partner code without getting their review and approval. Please engage with partners via @ARmmbed/Team-[Partner] or with the TAM group to discuss proposals, get feedback, or alert them to a change that affects their targets. |
@maclobdell will do, I'll tag them the remaining teams now |
@ARMmbed/team-maximintegrated @ARMmbed/team-st-mcd Please review |
cc @bentcooke - please help with the review |
@maclobdell @bentcooke any update on this? Code freeze for 5.13 is one week today... |
@ARMmbed/team-st-mcd Can you please review? |
I started CI while finalizing reviews |
Test run: FAILEDSummary: 1 of 7 test jobs failed Failed test jobs:
|
@kjbracey-arm The build errors are related - usb tests fail to link with an error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change includes many other changes which appear not to be related to the simple removal of the legacyalign flag. These should be in a separate PR in my view.
@mark-edgeworth Removing the linker option causes a failure to build for some targets. The other changes are necessary to meet the following requirement of the Mbed OS workflow
Source: https://os.mbed.com/docs/mbed-os/v5.12/contributing/workflow.html |
There wasn't a proper solution. It appeared to be a linker bug triggered by certain layouts with large alignment. I avoided it by backing away from the "put vectors in general RAM" approach for Maxim. I'll look at the new failure to see what I can figure out. If it is a linker bug, we might be stuck for a while. I think this may have to miss 5.13 - I don't think I'll have time to investigate that in time with the other stuff I've got open, and removal of this flag isn't urgent. PR was initially prompted by some suspicion that other weird behaviour may be linked to it, but that issue has been resolved. |
The other changes must be made before the flag can be turned off. I guess it could be split into a first PR that makes everything aligned, and a second PR that turns off the flag. But GitHub really doesn't know how to handle dependent PRs nicely. You'd have one PR with 4 commits and another with the same 4 commits and 1 more. Each commit within this dependent series is fairly neatly self-contained - selecting the individual commits to review in the GitHub UI is probably clearer than a trying to look at separate PRs. |
Removed 5.13 label for now |
It make sense to have it in one PR, if it's all related (change + fix). |
@kjbracey-arm should we continue with this one for 5.14? |
This one's fallen to the bottom of my priority queue, so not sure when I'll be getting back around to it. I don't believe the flag is currently having any ill effects, so maybe park it altogether for now. |
Let's close it for now. |
Description
This previously had to be reinstated to avoid failures on certain platforms due to their linker map not having sufficient alignment.
We now have the test infrastructure in place to attempt to remove it and find failures.
Pull request type
Reviewers
@deepikabhavnani, @JanneKiiskila