[rtems commit] score: Clarify TLS support

Joel Sherrill Joel.Sherrill at OARcorp.com
Thu Apr 17 12:13:23 UTC 2014


Thanks for adding this. Fun my phone so it may be ready to find. Is there a single place in GCC to see what the ABI requires register wise? Or a machine description pattern?

It seems research is needed for each architecture and what to hunt for is important.

On Apr 17, 2014 1:09 AM, Sebastian Huber <sebh at rtems.org> wrote:
Module:    rtems
Branch:    master
Commit:    320faf8e68796bcea316accdfa75c1f64a73f6b7
Changeset: http://git.rtems.org/rtems/commit/?id=320faf8e68796bcea316accdfa75c1f64a73f6b7

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Apr 17 07:57:09 2014 +0200

score: Clarify TLS support

---

 c/src/lib/libcpu/powerpc/new-exceptions/cpu.c |    2 +-
 cpukit/score/cpu/m68k/cpu.c                   |    2 +-
 cpukit/score/cpu/sparc/cpu.c                  |    2 +-
 cpukit/score/cpu/sparc64/cpu.c                |    2 +-
 cpukit/score/include/rtems/score/tls.h        |    4 ++--
 doc/cpu_supplement/general.t                  |   21 ++++++++++++++++++++-
 6 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/c/src/lib/libcpu/powerpc/new-exceptions/cpu.c b/c/src/lib/libcpu/powerpc/new-exceptions/cpu.c
index 3b17662..73a1d3e 100644
--- a/c/src/lib/libcpu/powerpc/new-exceptions/cpu.c
+++ b/c/src/lib/libcpu/powerpc/new-exceptions/cpu.c
@@ -135,7 +135,7 @@ void _CPU_Context_Initialize(
 #endif

   if ( tls_area != NULL ) {
-    void *tls_block = _TLS_TCB_before_tls_block_initialize( tls_area );
+    void *tls_block = _TLS_TCB_before_TLS_block_initialize( tls_area );

     the_ppc_context->gpr2 = (uint32_t) tls_block + 0x7000;
   } else {
diff --git a/cpukit/score/cpu/m68k/cpu.c b/cpukit/score/cpu/m68k/cpu.c
index f6342d6..4efaaa4 100644
--- a/cpukit/score/cpu/m68k/cpu.c
+++ b/cpukit/score/cpu/m68k/cpu.c
@@ -205,6 +205,6 @@ void _CPU_Context_Initialize(
 #endif

   if ( tls_area != NULL ) {
-    _TLS_TCB_before_tls_block_initialize( tls_area );
+    _TLS_TCB_before_TLS_block_initialize( tls_area );
   }
 }
diff --git a/cpukit/score/cpu/sparc/cpu.c b/cpukit/score/cpu/sparc/cpu.c
index 2878c3e..73ed4fd 100644
--- a/cpukit/score/cpu/sparc/cpu.c
+++ b/cpukit/score/cpu/sparc/cpu.c
@@ -327,7 +327,7 @@ void _CPU_Context_Initialize(
     the_context->isr_dispatch_disable = 0;

   if ( tls_area != NULL ) {
-    void *tcb = _TLS_TCB_after_tls_block_initialize( tls_area );
+    void *tcb = _TLS_TCB_after_TLS_block_initialize( tls_area );

     the_context->g7 = (uintptr_t) tcb;
   }
diff --git a/cpukit/score/cpu/sparc64/cpu.c b/cpukit/score/cpu/sparc64/cpu.c
index c5420c3..6d79a5a 100644
--- a/cpukit/score/cpu/sparc64/cpu.c
+++ b/cpukit/score/cpu/sparc64/cpu.c
@@ -103,7 +103,7 @@ void _CPU_Context_Initialize(
     the_context->isr_dispatch_disable = 0;

   if ( tls_area != NULL ) {
-    void *tcb = _TLS_TCB_after_tls_block_initialize( tls_area );
+    void *tcb = _TLS_TCB_after_TLS_block_initialize( tls_area );

     the_context->g7 = (uintptr_t) tcb;
   }
diff --git a/cpukit/score/include/rtems/score/tls.h b/cpukit/score/include/rtems/score/tls.h
index 75213d8..f9abc27 100644
--- a/cpukit/score/include/rtems/score/tls.h
+++ b/cpukit/score/include/rtems/score/tls.h
@@ -146,7 +146,7 @@ static inline void *_TLS_TCB_at_area_begin_initialize( void *tls_area )
 }

 /* Use Variant I, TLS offsets emitted by linker neglects the TCB */
-static inline void *_TLS_TCB_before_tls_block_initialize( void *tls_area )
+static inline void *_TLS_TCB_before_TLS_block_initialize( void *tls_area )
 {
   void *tls_block = (char *) tls_area
     + _TLS_Get_thread_control_block_area_size( (uintptr_t) _TLS_Alignment );
@@ -160,7 +160,7 @@ static inline void *_TLS_TCB_before_tls_block_initialize( void *tls_area )
 }

 /* Use Variant II */
-static inline void *_TLS_TCB_after_tls_block_initialize( void *tls_area )
+static inline void *_TLS_TCB_after_TLS_block_initialize( void *tls_area )
 {
   uintptr_t size = (uintptr_t) _TLS_Size;
   uintptr_t tls_align = (uintptr_t) _TLS_Alignment;
diff --git a/doc/cpu_supplement/general.t b/doc/cpu_supplement/general.t
index 9c952a7..173f84f 100644
--- a/doc/cpu_supplement/general.t
+++ b/doc/cpu_supplement/general.t
@@ -319,7 +319,26 @@ operations of the default CPU specific fatal error handler.
 In order to support thread-local storage (TLS) the CPU port must implement the
 facilities mandated by the application binary interface (ABI) of the CPU
 architecture.  The CPU port must initialize the TLS area in the
- at code{_CPU_Context_Initialize} function.
+ at code{_CPU_Context_Initialize()} function.  There are support functions available
+via @code{#include <rtems/score/tls.h>} which implement Variants I and II
+according to Ulrich Drepper, @cite{ELF Handling For Thread-Local Storage}.
+
+ at table @code
+
+ at item _TLS_TCB_at_area_begin_initialize()
+Uses Variant I, TLS offsets emitted by linker takes the TCB into account.  For
+a reference implementation see @file{cpukit/score/cpu/arm/cpu.c}.
+
+ at item _TLS_TCB_before_TLS_block_initialize()
+Uses Variant I, TLS offsets emitted by linker neglects the TCB.  For a
+reference implementation see
+ at file{c/src/lib/libcpu/powerpc/new-exceptions/cpu.c}.
+
+ at item _TLS_TCB_after_TLS_block_initialize()
+Uses Variant II.  For a reference implementation see
+ at file{cpukit/score/cpu/sparc/cpu.c}.
+
+ at end table

 The board support package (BSP) must provide the following sections and symbols
 in its linker command file:

_______________________________________________
rtems-vc mailing list
rtems-vc at rtems.org
http://www.rtems.org/mailman/listinfo/rtems-vc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20140417/d4602684/attachment.html>


More information about the devel mailing list