[PATCH] bsps/arm: Fix bsp_section_data_end linker symbol

Jeff Kubascik jeff.kubascik at dornerworks.com
Fri Jan 24 13:39:56 UTC 2020


The bsp_section_data_end linker symbol indicates the end of region
REGION_DATA, which includes the sections data, data1, and rtemsrwset.
The rtemsrwset section will be empty if linker sets are not used in the
build.

When the zImage header patch was submitted, the rtemsrwset section
had a 1 byte alignment. The rtemsrwset section now has a 64 byte
alignment - this change occurred in commit 234d155e "linkersets: Revert
to zero-length arrays".

In the case that the rtemsrwset section is empty, the
bsp_section_data_end symbol will contain start address of this section,
which is rouded up to the alignment. This does not match the actual end
address of the region, which would be the end of data1.

This mismatch becomes apparent when using objcopy to convert the ELF to
a BIN image - objcopy does not pad up to the rtemsrwset section since it
is empty. As a result, the length of the BIN image does not match the
bsp_section_data_end symbol, which is used in the zImage header. Certain
image loaders will check for this and throw an error.

This change adds a conditional statement to the linker script that will
use the end of the data1 section in the case that rtemsrwset is empty.
---
Hello,

This patch is a follow up to a email I sent to rtems-devel last week
titled "Linker sets alignment change". This email described an issue
that was introduced with a change to linker sets. The issue affects
the zImage header that's being used in the Xen BSP.

I'm waiting for Sebastian to be back in the office so that he can
respond to the original email. However, I'm currently ramping down on
this project and wanted to get the patch out.

Sincerely,
Jeff Kubascik
---
 bsps/arm/shared/start/linkcmds.base | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/bsps/arm/shared/start/linkcmds.base b/bsps/arm/shared/start/linkcmds.base
index fb819e2bb1..47eac79729 100644
--- a/bsps/arm/shared/start/linkcmds.base
+++ b/bsps/arm/shared/start/linkcmds.base
@@ -295,11 +295,15 @@ SECTIONS {
 	} > REGION_DATA AT > REGION_DATA_LOAD
 	.data1 : ALIGN_WITH_INPUT {
 		*(.data1)
+		bsp_section_data1_end = .;
 	} > REGION_DATA AT > REGION_DATA_LOAD
 	.rtemsrwset : ALIGN_WITH_INPUT {
 		KEEP (*(SORT(.rtemsrwset.*)))
-		bsp_section_data_end = .;
+		bsp_section_rtemsrwset_end = .;
 	} > REGION_DATA AT > REGION_DATA_LOAD
+
+	bsp_section_data_end = (SIZEOF(.rtemsrwset) > 0) ? bsp_section_rtemsrwset_end : bsp_section_data1_end;
+
 	bsp_section_data_size = bsp_section_data_end - bsp_section_data_begin;
 	bsp_section_data_load_begin = LOADADDR (.data);
 	bsp_section_data_load_end = bsp_section_data_load_begin + bsp_section_data_size;
-- 
2.17.1



More information about the devel mailing list