[rtems commit] bsps/arm: Fix bsp_section_data_end linker symbol

Joel Sherrill joel at rtems.org
Thu Feb 13 00:18:47 UTC 2020


Module:    rtems
Branch:    master
Commit:    970baf885956928f630f0950ead669722c6086b2
Changeset: http://git.rtems.org/rtems/commit/?id=970baf885956928f630f0950ead669722c6086b2

Author:    Jeff Kubascik <jeff.kubascik at dornerworks.com>
Date:      Fri Jan 24 08:39:56 2020 -0500

bsps/arm: Fix bsp_section_data_end linker symbol

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.

---

 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 fb819e2..47eac79 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;



More information about the vc mailing list