-
Notifications
You must be signed in to change notification settings - Fork 7.7k
arm: linker.ld: move bss section to ram end #21747
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
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.
Please provide an explanation as to why this is necessary in the commit message.
agreed. What problem are you trying to address @lgl88911 ? |
@stephanosio @ioannisg Thanks for your review
|
While I can confirm that behaviour, something is wrong here ...
CONFIG_XIP=y
CONFIG_XIP=n
https://gist.github.com/stephanosio/a7f5cd34c7480bacb5254d4760b54805
EDIT: This is the correct behaviour because the LMA for the non-XIP image is the same as the VMA. |
To be exact, it is not that the This in itself is not a bug (it does not break anything), but rather an inefficiency that comes with using the raw binary format. |
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.
I am not against this change because it does help reduce the output 'bin' file size, which can be useful if you must use the 'bin' image (e.g. booting from a 'bin' file in an SD card).
However, this seems to be breaking some existing platforms and they will need to be fixed before this PR can be approved.
Thanks for your check. Yes, I hope load bin from SD card to sdram, Decreasing bin size can help improve download and load speeds。 What kind of problems this change will affect those existing platforms? |
I know "EXISTING PLATFORMS" problem is : |
@stephanosio Shippable check pass, Could you help review again,Thanks |
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.
So, in summary, we cannot have the bss
section as the last RAM section when USERSPACE
is enabled; I wonder why that is.
IMO, we should figure out why the userspace tests fault when the bss
section is placed as the last section in the RAM and provide a more fundamental fix, unless there is a technical reason as to why that is not possible and/or feasible.
I don't have time to look into it right now; if it does not get resolved in time, I will eventually come back to it.
5bd7a02
to
324f1bd
Compare
When bss moves to the end, the bss section will be after the kobject_data section. |
The relevant linker snippet is include/linker/kobject.ld. I don't have a good suggestion to fix this at the moment. The problem is that the size of this area is a linear function of the number of kernel objects in the binary, there isn't a good way to predict how large it is without going through the full process of building. |
Indeed, the inability to predict kernel object data is a problem. Maybe reserve enough space, or add a third link, use the final elf to generate kobject_hash.c again, and relink the new elf. |
Thanks for the explanation. It looks like that will require a major overhaul, which should probably be a separate PR. |
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.
Approving for now, noting that it is not feasible for userspace to have the bss as the last section in the RAM.
fix bss section be copy to binary. When compiling with non-xip. All sections will be placed in the ram. If NOBITS section isn't placed at the end of ram, objcopy will placed these section to binary file. The modify only for no-userspace. In userspace the section will be adjust, kobject_data size increase, the bss be shifted, the content of kobject_data will no mactch to kernel obj of bss. Signed-off-by: Frank Li <lgl88911@163.com>
@galak @MaureenHelm @andrewboie @ioannisg This PR has been pending for a long time, can you help review if need to make other changes? |
Yep, this should be followed-up. @lgl88911 if you get no response before tomorrow I can suggest you add it to the dev-review meeting and join if you are able to. But I think this mostly needs an approval from @ioannisg. |
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.
Fine with this for now, but I'm going to open a GH enhancement to investigate this more deeply, such that if user mode is enabled on a non-XIP system the binary isn't inflated by NOBITS sections.
@carlescufi Is there any document explaining how to proceed with "add item to the dev-review meeting", I have never done this. Thanks! |
…mode Userspace originally required bss to precede kobject_data, as kobject_data size was not known until the final linking stage (zephyrproject-rtos#21747). zephyrproject-rtos#33687 reserved space for kobject_data, allowing bss to now be after kobject_data. Placing bss/noinit at the end of the linker script reduces the size of a "zephyr.bin" file, as the NOLOAD sections can be excluded. It also keeps the code common between kernel/user mode Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
…mode Userspace originally required bss to precede kobject_data, as kobject_data size was not known until the final linking stage (#21747). #33687 reserved space for kobject_data, allowing bss to now be after kobject_data. Placing bss/noinit at the end of the linker script reduces the size of a "zephyr.bin" file, as the NOLOAD sections can be excluded. It also keeps the code common between kernel/user mode Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com>
…mode Userspace originally required bss to precede kobject_data, as kobject_data size was not known until the final linking stage (zephyrproject-rtos#21747). zephyrproject-rtos#33687 reserved space for kobject_data, allowing bss to now be after kobject_data. Placing bss/noinit at the end of the linker script reduces the size of a "zephyr.bin" file, as the NOLOAD sections can be excluded. It also keeps the code common between kernel/user mode (cherry picked from commit f9d69fc) Original-Signed-off-by: Grant Ramsay <gramsay@enphaseenergy.com> GitOrigin-RevId: f9d69fc Cr-Build-Id: 8723641050355720609 Cr-Build-Url: https://cr-buildbucket.appspot.com/build/8723641050355720609 Copybot-Job-Name: zephyr-main-copybot-downstream Change-Id: I96b5fbac36ff22a501f30c08c1b4ca42a0425fec Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/6241424 Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org> Tested-by: ChromeOS Prod (Robot) <chromeos-ci-prod@chromeos-bot.iam.gserviceaccount.com> Reviewed-by: Jonathon Murphy <jpmurphy@google.com> Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Bot-Commit: ChromeOS Prod (Robot) <chromeos-ci-prod@chromeos-bot.iam.gserviceaccount.com>
fix bss section be copy to binary
Signed-off-by: Frank Li lgl88911@163.com