-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
Build issues observed when using CONFIG_BUILD_OUTPUT_ADJUST_LMA #58080
Build issues observed when using CONFIG_BUILD_OUTPUT_ADJUST_LMA #58080
Comments
The problem is that the BFD program header rewrite implementation makes a questionable assumption that the LMA of a segment will be aligned to the alignment of the first section in the segment: /* If the first section in a segment does not start at
the beginning of the segment, then something is
wrong. */
if (align_power (map->p_paddr
+ (map->includes_filehdr
? iehdr->e_ehsize : 0)
+ (map->includes_phdrs
? iehdr->e_phnum * iehdr->e_phentsize
: 0),
output_section->alignment_power * opb)
!= output_section->lma * opb)
goto sorry; This is not a problem when the LMA is equal to the VMA and both are aligned at the section alignment; but, for the sections that have different VMA and LMA, only the VMA is guaranteed to be aligned at the section alignment and the LMA may or may not be aligned at the same boundary. Now looking at the cases with Good:
Bad:
(the full dump can be found in https://gist.github.com/stephanosio/5946bd6f8f249b5329fb4982f87cd58e) Note that, for both good and bad, the For good, the LMA is 0x10f64 which is aligned at As seen above, the BFD implementation expects the LMA of a segment to be aligned at the alignment of the first section of the segment, and attempts to align the address of the segment LMA to the alignment of the first section before comparing it to the actual LMA of the first section for the purpose of verifying that the first section starts at the beginning of the segment. When running In case of good, since the segment LMA is divisible by 4 ( Since the diff --git a/bfd/elf.c b/bfd/elf.c
index 79f71aa81e2..a0b65c4fd3b 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -7412,7 +7412,7 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd, bfd_vma maxpagesize)
/* If the first section in a segment does not start at
the beginning of the segment, then something is
wrong. */
- if (align_power (map->p_paddr
+ if ((align_power (map->p_paddr
+ (map->includes_filehdr
? iehdr->e_ehsize : 0)
+ (map->includes_phdrs
@@ -7420,6 +7420,7 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd, bfd_vma maxpagesize)
: 0),
output_section->alignment_power * opb)
!= output_section->lma * opb)
+ && (map->p_paddr != output_section->lma * opb))
goto sorry;
}
else |
Disable test due to observed issues with CONFIG_BUILD_OUTPUT_ADJUST_LMA. Refer to zephyrproject-rtos#58080. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Disable test due to observed issues with CONFIG_BUILD_OUTPUT_ADJUST_LMA. Refer to #58080. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Disable test due to observed issues with CONFIG_BUILD_OUTPUT_ADJUST_LMA. Refer to zephyrproject-rtos/zephyr#58080. (cherry picked from commit fc312b0) Original-Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no> GitOrigin-RevId: fc312b0 Change-Id: I816be0ed79d67959b092080b784fe9d38f891168 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/4570771 Commit-Queue: Keith Short <keithshort@chromium.org> Tested-by: CopyBot Service Account <copybot.service@gmail.com> Tested-by: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
Disable test due to observed issues with CONFIG_BUILD_OUTPUT_ADJUST_LMA. Refer to zephyrproject-rtos#58080. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
The dev branch in PR #60400 hits the same bug (see https://github.com/zephyrproject-rtos/zephyr/actions/runs/5861777078/job/15892496313?pr=60400), this time the offender is tests/boot/test_mcuboot/boot.mcuboot.assert which is not yet skipped. (Same root cause, though - it's the same little app that triggers the issue.) @stephanosio Should that one be skipped as well? |
The current mcuboot tests fail due to zephyrproject-rtos#58080. Tests are being skipped until the bug has been fixed. Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The current mcuboot tests fail due to zephyrproject-rtos#58080. Tests are being skipped until the bug has been fixed. Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The current mcuboot tests fail due to zephyrproject-rtos#58080. Tests are being skipped until the bug has been fixed. Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The current mcuboot tests fail due to zephyrproject-rtos#58080. Tests are being skipped until the bug has been fixed. Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The current mcuboot tests fail due to zephyrproject-rtos#58080. Tests are being skipped until the bug has been fixed. Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The current mcuboot tests fail due to zephyrproject-rtos#58080. Tests are being skipped until the bug has been fixed. Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The current mcuboot tests fail due to zephyrproject-rtos#58080. Tests are being skipped until the bug has been fixed. Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The current mcuboot tests fail due to zephyrproject-rtos#58080. Tests are being skipped until the bug has been fixed. Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The current mcuboot tests fail due to zephyrproject-rtos#58080. Tests are being skipped until the bug has been fixed. Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The current mcuboot tests fail due to zephyrproject-rtos#58080. Tests are being skipped until the bug has been fixed. Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The current mcuboot tests fail due to zephyrproject-rtos#58080. Tests are being skipped until the bug has been fixed. Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The current mcuboot tests fail due to zephyrproject-rtos#58080. Tests are being skipped until the bug has been fixed. Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The current mcuboot tests fail due to zephyrproject-rtos#58080. Tests are being skipped until the bug has been fixed. Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The current mcuboot tests fail due to zephyrproject-rtos#58080. Tests are being skipped until the bug has been fixed. Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Padding section alignment for 64bit-aligned timeout struct. Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Padding section alignment for 64bit-aligned timeout struct. Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Padding section alignment for 64bit-aligned timeout struct. Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
NXP MCUX has no issue with zephyrproject-rtos#58080, so enable tests for NXP Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
NXP MCUX has no issue with zephyrproject-rtos#58080, so enable tests for NXP Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
NXP MCUX has no issue with zephyrproject-rtos#58080, so enable tests for NXP Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
NXP MCUX has no issue with zephyrproject-rtos#58080, so enable tests for NXP Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
NXP MCUX has no issue with zephyrproject-rtos#58080, so enable tests for NXP Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
NXP MCUX has no issue with zephyrproject-rtos#58080, so enable tests for NXP Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
NXP MCUX has no issue with #58080, so enable tests for NXP Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
NXP MCUX has no issue with zephyrproject-rtos#58080, so enable tests for NXP (cherry picked from commit d05e274) Original-Signed-off-by: Hake Huang <hake.huang@oss.nxp.com> GitOrigin-RevId: d05e274 Change-Id: If64845848443c7a1150ae59cd28cdc71a1f60d98 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/4984267 Reviewed-by: Al Semjonovs <asemjonovs@google.com> Tested-by: Al Semjonovs <asemjonovs@google.com> Commit-Queue: Al Semjonovs <asemjonovs@google.com> Tested-by: ChromeOS Prod (Robot) <chromeos-ci-prod@chromeos-bot.iam.gserviceaccount.com>
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
@stephanosio any plans to get this upstreamed into gcc? |
I will release an SDK RC with the proposed patch above next week. |
Closing this since Zephyr SDK 0.16.5 with the binutils fix for this issue has been mainlined. |
Do you agree? @fgrandel would you like to open an issue to get #60934 reverted? If you can point to a specific bug the commit causes, we might be able to make the change prior to the release |
@danieldegrasse Sorry, saw your comment only now, revisiting this issue. I seems to me that the additional Kconfig switch is redundant in the current mainline now that the underlying root cause was fixed. It might cause bugs in the future when the condition described in my original message applies. I might be mistaken, though, as I might misunderstand the intent of the CONFIG_BUILD_ALIGN_LMA switch in the first place. |
No worries, you're understanding the purpose of |
Describe the bug
I discovered a heisenbug while adding this new feature to Zephyr: #57229. Some failures with objcopy occur when using
CONFIG_BUILD_OUTPUT_ADJUST_LMA
, e.g. when compiling some MCUboot tests.To Reproduce
Use #57229 branch and build:
If the following patch is applied to the branch, the problem disappears:
Expected behavior
Build succeeds
Impact
Blocker
Logs and console output
Environment (please complete the following information):
Additional context
N/A
The text was updated successfully, but these errors were encountered: