[PATCH v1 2/2] bsps/aarch64: Resolve usage of SUBALIGN()

Kinsey Moore kinsey.moore at oarcorp.com
Thu Feb 18 18:59:05 UTC 2021


Remove usage of SUBALIGN() in aarch64 linkcmds which works around a
difference in behavior on AArch64 platforms. According to commentary on
GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99143 this behavior
was never expected to be consistent across platforms and any alignment
requirements for linker sections need to be enforced explicitly. This
adds those explicit alignment requirements such that splinkersets01
passes on both AArch64 multilibs.

Closes #4178.
Closes #4255.
---
 bsps/aarch64/shared/start/linkcmds.base |  4 +--
 cpukit/include/rtems/linkersets.h       | 39 +++++++++++++------------
 2 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/bsps/aarch64/shared/start/linkcmds.base b/bsps/aarch64/shared/start/linkcmds.base
index 294390870a..1768ed001a 100644
--- a/bsps/aarch64/shared/start/linkcmds.base
+++ b/bsps/aarch64/shared/start/linkcmds.base
@@ -245,7 +245,7 @@ SECTIONS {
 	.got : ALIGN_WITH_INPUT {
 		*(.got.plt) *(.igot.plt) *(.got) *(.igot)
 	} > REGION_RODATA AT > REGION_RODATA_LOAD
-	.rtemsroset : ALIGN_WITH_INPUT SUBALIGN(bsp_set_align) {
+	.rtemsroset : ALIGN_WITH_INPUT {
 		/* Special FreeBSD linker set sections */
 		__start_set_sysctl_set = .;
 		*(set_sysctl_*);
@@ -299,7 +299,7 @@ SECTIONS {
 	.data1 : ALIGN_WITH_INPUT {
 		*(.data1)
 	} > REGION_DATA AT > REGION_DATA_LOAD
-	.rtemsrwset : ALIGN_WITH_INPUT SUBALIGN(bsp_set_align) {
+	.rtemsrwset : ALIGN_WITH_INPUT {
 		KEEP (*(SORT(.rtemsrwset.*)))
 		bsp_section_data_end = .;
 	} > REGION_DATA AT > REGION_DATA_LOAD
diff --git a/cpukit/include/rtems/linkersets.h b/cpukit/include/rtems/linkersets.h
index d3ed76043a..fce6676e4a 100644
--- a/cpukit/include/rtems/linkersets.h
+++ b/cpukit/include/rtems/linkersets.h
@@ -27,36 +27,39 @@ extern "C" {
 #define RTEMS_LINKER_SET_END( set ) \
   _Linker_set_##set##_end
 
+#define RTEMS_LINKER_ALIGN( type ) \
+  __attribute__((__aligned__(_Alignof(type))))
+
 #define RTEMS_LINKER_ROSET_DECLARE( set, type ) \
-  extern type const RTEMS_LINKER_SET_BEGIN( set )[]; \
-  extern type const RTEMS_LINKER_SET_END( set )[]
+  RTEMS_LINKER_ALIGN(type) extern type const RTEMS_LINKER_SET_BEGIN( set )[]; \
+  RTEMS_LINKER_ALIGN(type) extern type const RTEMS_LINKER_SET_END( set )[]
 
 #define RTEMS_LINKER_ROSET( set, type ) \
-  type const RTEMS_LINKER_SET_BEGIN( set )[ 0 ] \
+  RTEMS_LINKER_ALIGN(type) type const RTEMS_LINKER_SET_BEGIN( set )[ 0 ] \
   RTEMS_SECTION( ".rtemsroset." #set ".begin" ) RTEMS_USED; \
-  type const RTEMS_LINKER_SET_END( set )[ 0 ] \
+  RTEMS_LINKER_ALIGN(type) type const RTEMS_LINKER_SET_END( set )[ 0 ] \
   RTEMS_SECTION( ".rtemsroset." #set ".end" ) RTEMS_USED
 
 #define RTEMS_LINKER_ROSET_ITEM_ORDERED_DECLARE( set, type, item, order ) \
-  extern type const _Linker_set_##set##_##item \
+  RTEMS_LINKER_ALIGN(type) extern type const _Linker_set_##set##_##item \
   RTEMS_SECTION( ".rtemsroset." #set ".content.0." RTEMS_XSTRING( order ) )
 
 #define RTEMS_LINKER_ROSET_ITEM_DECLARE( set, type, item ) \
-  extern type const _Linker_set_##set##_##item \
+  RTEMS_LINKER_ALIGN(type) extern type const _Linker_set_##set##_##item \
   RTEMS_SECTION( ".rtemsroset." #set ".content.1" )
 
 #define RTEMS_LINKER_ROSET_ITEM_REFERENCE( set, type, item ) \
-  static type const * const _Set_reference_##set##_##item \
+  RTEMS_LINKER_ALIGN(type) static type const * const _Set_reference_##set##_##item \
   RTEMS_SECTION( ".rtemsroset.reference" ) RTEMS_USED = \
   &_Linker_set_##set##_##item
 
 #define RTEMS_LINKER_ROSET_ITEM_ORDERED( set, type, item, order ) \
-  type const _Linker_set_##set##_##item \
+  RTEMS_LINKER_ALIGN(type) type const _Linker_set_##set##_##item \
   RTEMS_SECTION( ".rtemsroset." #set ".content.0." RTEMS_XSTRING( order ) ) \
   RTEMS_USED
 
 #define RTEMS_LINKER_ROSET_ITEM( set, type, item ) \
-  type const _Linker_set_##set##_##item \
+  RTEMS_LINKER_ALIGN(type) type const _Linker_set_##set##_##item \
   RTEMS_SECTION( ".rtemsroset." #set ".content.1" ) RTEMS_USED
 
 #define RTEMS_LINKER_ROSET_CONTENT( set, decl ) \
@@ -64,21 +67,21 @@ extern "C" {
   RTEMS_SECTION( ".rtemsroset." #set ".content" )
 
 #define RTEMS_LINKER_RWSET_DECLARE( set, type ) \
-  extern type RTEMS_LINKER_SET_BEGIN( set )[]; \
-  extern type RTEMS_LINKER_SET_END( set )[]
+  RTEMS_LINKER_ALIGN(type) extern type RTEMS_LINKER_SET_BEGIN( set )[]; \
+  RTEMS_LINKER_ALIGN(type) extern type RTEMS_LINKER_SET_END( set )[]
 
 #define RTEMS_LINKER_RWSET( set, type ) \
-  type RTEMS_LINKER_SET_BEGIN( set )[ 0 ] \
+  RTEMS_LINKER_ALIGN(type) type RTEMS_LINKER_SET_BEGIN( set )[ 0 ] \
   RTEMS_SECTION( ".rtemsrwset." #set ".begin" ) RTEMS_USED; \
-  type RTEMS_LINKER_SET_END( set )[ 0 ] \
+  RTEMS_LINKER_ALIGN(type) type RTEMS_LINKER_SET_END( set )[ 0 ] \
   RTEMS_SECTION( ".rtemsrwset." #set ".end" ) RTEMS_USED
 
 #define RTEMS_LINKER_RWSET_ITEM_ORDERED_DECLARE( set, type, item, order ) \
-  extern type _Linker_set_##set##_##item \
+  RTEMS_LINKER_ALIGN(type) extern type _Linker_set_##set##_##item \
   RTEMS_SECTION( ".rtemsrwset." #set ".content.0." RTEMS_XSTRING( order ) )
 
 #define RTEMS_LINKER_RWSET_ITEM_DECLARE( set, type, item ) \
-  extern type _Linker_set_##set##_##item \
+  RTEMS_LINKER_ALIGN(type) extern type _Linker_set_##set##_##item \
   RTEMS_SECTION( ".rtemsrwset." #set ".content.1" )
 
 /*
@@ -87,17 +90,17 @@ extern "C" {
  * in a dedicated area of the RTEMS read-only linker set section.
  */
 #define RTEMS_LINKER_RWSET_ITEM_REFERENCE( set, type, item ) \
-  static type * const _Set_reference_##set##_##item \
+  RTEMS_LINKER_ALIGN(type) static type * const _Set_reference_##set##_##item \
   RTEMS_SECTION( ".rtemsroset.reference" ) RTEMS_USED = \
   &_Linker_set_##set##_##item
 
 #define RTEMS_LINKER_RWSET_ITEM_ORDERED( set, type, item, order ) \
-  type _Linker_set_##set##_##item \
+  RTEMS_LINKER_ALIGN(type) type _Linker_set_##set##_##item \
   RTEMS_SECTION( ".rtemsrwset." #set ".content.0." RTEMS_XSTRING( order ) ) \
   RTEMS_USED
 
 #define RTEMS_LINKER_RWSET_ITEM( set, type, item ) \
-  type _Linker_set_##set##_##item \
+  RTEMS_LINKER_ALIGN(type) type _Linker_set_##set##_##item \
   RTEMS_SECTION( ".rtemsrwset." #set ".content.1" ) RTEMS_USED
 
 #define RTEMS_LINKER_RWSET_CONTENT( set, decl ) \
-- 
2.20.1



More information about the devel mailing list