[rtems commit] score: Add RTEMS_DEFINE_GLOBAL_SYMBOL_IN_SECTION()
Sebastian Huber
sebh at rtems.org
Mon Oct 28 09:01:51 UTC 2019
Module: rtems
Branch: master
Commit: 795b167545ac074509f4b7c5fd7ed1c0da717460
Changeset: http://git.rtems.org/rtems/commit/?id=795b167545ac074509f4b7c5fd7ed1c0da717460
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Fri Oct 4 08:51:13 2019 +0200
score: Add RTEMS_DEFINE_GLOBAL_SYMBOL_IN_SECTION()
Update #3799.
---
cpukit/include/rtems/score/basedefs.h | 19 +++++++++++++++++++
testsuites/sptests/spmisc01/init.c | 7 +++++++
2 files changed, 26 insertions(+)
diff --git a/cpukit/include/rtems/score/basedefs.h b/cpukit/include/rtems/score/basedefs.h
index 7829589..5f38559 100644
--- a/cpukit/include/rtems/score/basedefs.h
+++ b/cpukit/include/rtems/score/basedefs.h
@@ -344,6 +344,25 @@
#endif
/**
+ * @brief Defines a global symbol with the specified name in the specified
+ * section.
+ *
+ * The name must be a valid designator.
+ */
+#if defined(__GNUC__)
+ #define RTEMS_DEFINE_GLOBAL_SYMBOL_IN_SECTION( _name, _section ) \
+ __asm__( \
+ ".pushsection \"" _section "\"\n" \
+ "\t.globl " \
+ RTEMS_XSTRING( RTEMS_XCONCAT( __USER_LABEL_PREFIX__, _name ) ) "\n" \
+ RTEMS_XSTRING( RTEMS_XCONCAT( __USER_LABEL_PREFIX__, _name ) ) ":\n" \
+ "\t.popsection\n" \
+ )
+#else
+ #define RTEMS_DEFINE_GLOBAL_SYMBOL_IN_SECTION( _name, section )
+#endif
+
+/**
* @brief Returns the value of the specified integral expression and tells the
* compiler that the predicted value is true (1).
*
diff --git a/testsuites/sptests/spmisc01/init.c b/testsuites/sptests/spmisc01/init.c
index 9090069..8d713c4 100644
--- a/testsuites/sptests/spmisc01/init.c
+++ b/testsuites/sptests/spmisc01/init.c
@@ -99,6 +99,10 @@ RTEMS_DECLARE_GLOBAL_SYMBOL(a_global_symbol);
RTEMS_DEFINE_GLOBAL_SYMBOL(a_global_symbol, 0xabc);
+RTEMS_DECLARE_GLOBAL_SYMBOL(a_second_symbol);
+
+RTEMS_DEFINE_GLOBAL_SYMBOL_IN_SECTION(a_second_symbol, ".rtemsroset.dummy");
+
RTEMS_STATIC_ASSERT(0 != 1, zero_neq_one);
static int array[3];
@@ -211,6 +215,9 @@ static void Init(rtems_task_argument arg)
rtems_test_assert(printflike_func("%i", 0) == 56);
rtems_test_assert(obfuscate_variable(63) == 63);
rtems_test_assert((uintptr_t)a_global_symbol == 0xabc);
+ p = a_second_symbol;
+ RTEMS_OBFUSCATE_VARIABLE(p);
+ rtems_test_assert((uintptr_t)p != 0);
rtems_test_assert(RTEMS_ARRAY_SIZE(array) == 3);
rtems_test_assert(sizeof(zero_length_array_struct) == 4);
container_of();
More information about the vc
mailing list