summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKinsey Moore <kinsey.moore@oarcorp.com>2021-02-15 10:51:37 -0600
committerJoel Sherrill <joel@rtems.org>2021-03-05 08:43:15 -0600
commitbbc9974a2450e7599cf9c08dbfd394b523bf6c51 (patch)
treeeeca26c503dda727550341ab1b19f08d21f11011
parentbsps: Allow override of ARM TM27 IRQs (diff)
downloadrtems-bbc9974a2450e7599cf9c08dbfd394b523bf6c51.tar.bz2
cpukit: Explicitly enforce alignment requirements
According to commentary on GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99143, the alignment behavior of linker sections on which RTEMS has relied was never guaranteed to be consistent across platforms and any alignment requirements for linker sections needs to be enforced explicitly. This adds those explicit alignment requirements. Closes #4255.
-rw-r--r--cpukit/include/rtems/linkersets.h52
1 files changed, 32 insertions, 20 deletions
diff --git a/cpukit/include/rtems/linkersets.h b/cpukit/include/rtems/linkersets.h
index d3ed76043a..e156fd4379 100644
--- a/cpukit/include/rtems/linkersets.h
+++ b/cpukit/include/rtems/linkersets.h
@@ -27,36 +27,47 @@ extern "C" {
#define RTEMS_LINKER_SET_END( set ) \
_Linker_set_##set##_end
+/*
+ * Modern GCC optimizes for speed which may insert padding between linker
+ * sections that previous versions avoided. Alignment must now be explicit to
+ * maintain the behavior of previous versions.
+ */
+#define RTEMS_LINKER_SET_ALIGN( type ) \
+ RTEMS_ALIGNED( RTEMS_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 )[]
+ extern RTEMS_LINKER_SET_ALIGN( type ) type \
+ const RTEMS_LINKER_SET_BEGIN( set )[]; \
+ extern RTEMS_LINKER_SET_ALIGN( type ) type \
+ const RTEMS_LINKER_SET_END( set )[]
#define RTEMS_LINKER_ROSET( set, type ) \
- type const RTEMS_LINKER_SET_BEGIN( set )[ 0 ] \
+ RTEMS_LINKER_SET_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_SET_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 \
+ extern RTEMS_LINKER_SET_ALIGN( type ) 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 \
+ extern RTEMS_LINKER_SET_ALIGN( type ) 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_SECTION( ".rtemsroset.reference" ) RTEMS_USED = \
+#define RTEMS_LINKER_ROSET_ITEM_REFERENCE( set, type, item ) \
+ static RTEMS_LINKER_SET_ALIGN( type ) 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_SET_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_SET_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 +75,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 )[]
+ extern RTEMS_LINKER_SET_ALIGN( type ) type RTEMS_LINKER_SET_BEGIN( set )[]; \
+ extern RTEMS_LINKER_SET_ALIGN( type ) type RTEMS_LINKER_SET_END( set )[]
#define RTEMS_LINKER_RWSET( set, type ) \
- type RTEMS_LINKER_SET_BEGIN( set )[ 0 ] \
+ RTEMS_LINKER_SET_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_SET_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 \
+ extern RTEMS_LINKER_SET_ALIGN( type ) 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 \
+ extern RTEMS_LINKER_SET_ALIGN( type ) type _Linker_set_##set##_##item \
RTEMS_SECTION( ".rtemsrwset." #set ".content.1" )
/*
@@ -87,17 +98,18 @@ 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 \
+ static RTEMS_LINKER_SET_ALIGN( type ) 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_SET_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_SET_ALIGN( type ) type _Linker_set_##set##_##item \
RTEMS_SECTION( ".rtemsrwset." #set ".content.1" ) RTEMS_USED
#define RTEMS_LINKER_RWSET_CONTENT( set, decl ) \