Changeset be57318 in rtems


Ignore:
Timestamp:
Sep 23, 2016, 4:45:07 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
826f3afa
Parents:
97eaefd4
git-author:
Sebastian Huber <sebastian.huber@…> (09/23/16 04:45:07)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/12/16 09:12:40)
Message:

score: More robust linker sets

Update #2408.
Update #2790.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/sapi/src/exinit.c

    r97eaefd4 rbe57318  
    132132void rtems_initialize_executive(void)
    133133{
    134   const volatile rtems_sysinit_item *cur = RTEMS_LINKER_SET_BEGIN(_Sysinit );
    135   const volatile rtems_sysinit_item *end = RTEMS_LINKER_SET_END( _Sysinit );
     134  const rtems_sysinit_item *cur;
     135  const rtems_sysinit_item *end;
     136
     137  RTEMS_LINKER_SET_ASSIGN_BEGIN(_Sysinit, cur );
     138  RTEMS_LINKER_SET_ASSIGN_END( _Sysinit, end );
    136139
    137140  /* Invoke the registered system initialization handlers */
  • cpukit/score/include/rtems/linkersets.h

    r97eaefd4 rbe57318  
    11/*
    2  * Copyright (c) 2015 embedded brains GmbH.  All rights reserved.
     2 * Copyright (c) 2015, 2016 embedded brains GmbH.  All rights reserved.
    33 *
    44 *  embedded brains GmbH
     
    2222#endif /* __cplusplus */
    2323
    24 #define RTEMS_LINKER_SET_BEGIN( set ) \
     24#define _LINKER_SET_BEGIN( set ) \
    2525  _Linker_set_##set##_begin
    2626
    27 #define RTEMS_LINKER_SET_END( set ) \
     27#define _LINKER_SET_END( set ) \
    2828  _Linker_set_##set##_end
     29
     30#define RTEMS_LINKER_SET_ASSIGN_BEGIN( set, item ) \
     31  do { \
     32    item = _LINKER_SET_BEGIN( set ); \
     33    RTEMS_OBFUSCATE_POINTER( item ); \
     34  } while ( 0 )
     35
     36#define RTEMS_LINKER_SET_ASSIGN_END( set, item ) \
     37  do { \
     38    item = _LINKER_SET_END( set ); \
     39    RTEMS_OBFUSCATE_POINTER( item ); \
     40  } while ( 0 )
    2941
    3042#define RTEMS_LINKER_SET_SIZE( set ) \
     
    3244
    3345#define RTEMS_LINKER_ROSET_DECLARE( set, type ) \
    34   extern type volatile const RTEMS_LINKER_SET_BEGIN( set )[0]; \
    35   extern type volatile const RTEMS_LINKER_SET_END( set )[0]
     46  extern type const _LINKER_SET_BEGIN( set )[0]; \
     47  extern type const _LINKER_SET_END( set )[0]
    3648
    3749#define RTEMS_LINKER_ROSET( set, type ) \
    38   type volatile const RTEMS_LINKER_SET_BEGIN( set )[0] \
     50  type const _LINKER_SET_BEGIN( set )[0] \
    3951  RTEMS_SECTION( ".rtemsroset." #set ".begin" ) RTEMS_USED; \
    40   type volatile const RTEMS_LINKER_SET_END( set )[0] \
     52  type const _LINKER_SET_END( set )[0] \
    4153  RTEMS_SECTION( ".rtemsroset." #set ".end" ) RTEMS_USED
    4254
    4355#define RTEMS_LINKER_ROSET_ITEM_DECLARE( set, type, item ) \
    44   extern type volatile const _Linker_set_##set##_##item
     56  extern type const _Linker_set_##set##_##item
    4557
    4658#define RTEMS_LINKER_ROSET_ITEM_REFERENCE( set, type, item ) \
    47   static type volatile const * const _Set_reference_##set##_##item \
     59  static type const * const _Set_reference_##set##_##item \
    4860  RTEMS_SECTION( ".rtemsroset.reference" ) RTEMS_USED = \
    4961  &_Linker_set_##set##_##item
    5062
    5163#define RTEMS_LINKER_ROSET_ITEM_ORDERED( set, type, item, order ) \
    52   type volatile const _Linker_set_##set##_##item \
     64  type const _Linker_set_##set##_##item \
    5365  RTEMS_SECTION( ".rtemsroset." #set ".content.0." RTEMS_XSTRING( order ) ) \
    5466  RTEMS_USED
    5567
    5668#define RTEMS_LINKER_ROSET_ITEM( set, type, item ) \
    57   type volatile const _Linker_set_##set##_##item \
     69  type const _Linker_set_##set##_##item \
    5870  RTEMS_SECTION( ".rtemsroset." #set ".content.1" ) RTEMS_USED
    5971
     
    6375
    6476#define RTEMS_LINKER_RWSET_DECLARE( set, type ) \
    65   extern type volatile RTEMS_LINKER_SET_BEGIN( set )[0]; \
    66   extern type volatile RTEMS_LINKER_SET_END( set )[0]
     77  extern type _LINKER_SET_BEGIN( set )[0]; \
     78  extern type _LINKER_SET_END( set )[0]
    6779
    6880#define RTEMS_LINKER_RWSET( set, type ) \
    69   type volatile RTEMS_LINKER_SET_BEGIN( set )[0] \
     81  type _LINKER_SET_BEGIN( set )[0] \
    7082  RTEMS_SECTION( ".rtemsrwset." #set ".begin" ) RTEMS_USED; \
    71   type volatile RTEMS_LINKER_SET_END( set )[0] \
     83  type _LINKER_SET_END( set )[0] \
    7284  RTEMS_SECTION( ".rtemsrwset." #set ".end" ) RTEMS_USED
    7385
    7486#define RTEMS_LINKER_RWSET_ITEM_DECLARE( set, type, item ) \
    75   extern type volatile _Linker_set_##set##_##item
     87  extern type _Linker_set_##set##_##item
    7688
    7789/*
     
    8193 */
    8294#define RTEMS_LINKER_RWSET_ITEM_REFERENCE( set, type, item ) \
    83   static type volatile * const _Set_reference_##set##_##item \
     95  static type * const _Set_reference_##set##_##item \
    8496  RTEMS_SECTION( ".rtemsroset.reference" ) RTEMS_USED = \
    8597  &_Linker_set_##set##_##item
    8698
    8799#define RTEMS_LINKER_RWSET_ITEM_ORDERED( set, type, item, order ) \
    88   type volatile _Linker_set_##set##_##item \
     100  type _Linker_set_##set##_##item \
    89101  RTEMS_SECTION( ".rtemsrwset." #set ".content.0." RTEMS_XSTRING( order ) ) \
    90102  RTEMS_USED
    91103
    92104#define RTEMS_LINKER_RWSET_ITEM( set, type, item ) \
    93   type volatile _Linker_set_##set##_##item \
     105  type _Linker_set_##set##_##item \
    94106  RTEMS_SECTION( ".rtemsrwset." #set ".content.1" ) RTEMS_USED
    95107
  • testsuites/sptests/splinkersets01/init.c

    r97eaefd4 rbe57318  
    8686static void test(void)
    8787{
    88   const int * volatile *b = RTEMS_LINKER_SET_BEGIN(test_rw);
    89   const int * volatile *e = RTEMS_LINKER_SET_END(test_rw);
    90   const int * volatile const *cb = RTEMS_LINKER_SET_BEGIN(test_ro);
    91   const int * volatile const *ce = RTEMS_LINKER_SET_END(test_ro);
    92   const int * volatile *bi = RTEMS_LINKER_SET_BEGIN(test_rw_i);
    93   const int * volatile *ei = RTEMS_LINKER_SET_END(test_rw_i);
    94   const int * volatile const *cbi = RTEMS_LINKER_SET_BEGIN(test_ro_i);
    95   const int * volatile const *cei = RTEMS_LINKER_SET_END(test_ro_i);
    96   const int * volatile const *sb = RTEMS_LINKER_SET_BEGIN(test_ro_s);
    97   const int * volatile const *se = RTEMS_LINKER_SET_END(test_ro_s);
     88  const int **b;
     89  const int **e;
     90  const int * const *cb;
     91  const int * const *ce;
     92  const int **bi;
     93  const int **ei;
     94  const int * const *cbi;
     95  const int * const *cei;
     96  const int * const *sb;
     97  const int * const *se;
    9898  size_t i;
     99
     100  RTEMS_LINKER_SET_ASSIGN_BEGIN(test_rw, b);
     101  RTEMS_LINKER_SET_ASSIGN_END(test_rw, e);
     102  RTEMS_LINKER_SET_ASSIGN_BEGIN(test_ro, cb);
     103  RTEMS_LINKER_SET_ASSIGN_END(test_ro, ce);
     104  RTEMS_LINKER_SET_ASSIGN_BEGIN(test_rw_i, bi);
     105  RTEMS_LINKER_SET_ASSIGN_END(test_rw_i, ei);
     106  RTEMS_LINKER_SET_ASSIGN_BEGIN(test_ro_i, cbi);
     107  RTEMS_LINKER_SET_ASSIGN_END(test_ro_i, cei);
     108  RTEMS_LINKER_SET_ASSIGN_BEGIN(test_ro_s, sb);
     109  RTEMS_LINKER_SET_ASSIGN_END(test_ro_s, se);
    99110
    100111  rtems_test_assert((size_t) (e - b) == RTEMS_ARRAY_SIZE(a));
     
    133144static void test_content(void)
    134145{
    135   uintptr_t b_rw = (uintptr_t) RTEMS_LINKER_SET_BEGIN(test_content_rw);
    136   uintptr_t e_rw = (uintptr_t) RTEMS_LINKER_SET_END(test_content_rw);
     146  const char *b_rw;
     147  const char *e_rw;
     148  const char *b_ro;
     149  const char *e_ro;
    137150
    138   uintptr_t b_ro = (uintptr_t) RTEMS_LINKER_SET_BEGIN(test_content_ro);
    139   uintptr_t e_ro = (uintptr_t) RTEMS_LINKER_SET_END(test_content_ro);
     151  RTEMS_LINKER_SET_ASSIGN_BEGIN(test_content_rw, b_rw);
     152  RTEMS_LINKER_SET_ASSIGN_END(test_content_rw, e_rw);
     153  RTEMS_LINKER_SET_ASSIGN_BEGIN(test_content_ro, b_ro);
     154  RTEMS_LINKER_SET_ASSIGN_END(test_content_ro, e_ro);
    140155
    141   rtems_test_assert((uintptr_t) &content_rw_1 >= b_rw);
    142   rtems_test_assert((uintptr_t) &content_rw_2 >= b_rw);
    143   rtems_test_assert((uintptr_t) &content_rw_3 >= b_rw);
    144   rtems_test_assert((uintptr_t) &content_rw_1 <= e_rw);
    145   rtems_test_assert((uintptr_t) &content_rw_2 <= e_rw);
    146   rtems_test_assert((uintptr_t) &content_rw_3 <= e_rw);
     156  rtems_test_assert((uintptr_t) &content_rw_1 >= (uintptr_t) b_rw);
     157  rtems_test_assert((uintptr_t) &content_rw_2 >= (uintptr_t) b_rw);
     158  rtems_test_assert((uintptr_t) &content_rw_3 >= (uintptr_t) b_rw);
     159  rtems_test_assert((uintptr_t) &content_rw_1 <= (uintptr_t) e_rw);
     160  rtems_test_assert((uintptr_t) &content_rw_2 <= (uintptr_t) e_rw);
     161  rtems_test_assert((uintptr_t) &content_rw_3 <= (uintptr_t) e_rw);
    147162
    148   rtems_test_assert((uintptr_t) &content_ro_1 >= b_ro);
    149   rtems_test_assert((uintptr_t) &content_ro_2 >= b_ro);
    150   rtems_test_assert((uintptr_t) &content_ro_3 >= b_ro);
    151   rtems_test_assert((uintptr_t) &content_ro_1 <= e_ro);
    152   rtems_test_assert((uintptr_t) &content_ro_2 <= e_ro);
    153   rtems_test_assert((uintptr_t) &content_ro_3 <= e_ro);
     163  rtems_test_assert((uintptr_t) &content_ro_1 >= (uintptr_t) b_ro);
     164  rtems_test_assert((uintptr_t) &content_ro_2 >= (uintptr_t) b_ro);
     165  rtems_test_assert((uintptr_t) &content_ro_3 >= (uintptr_t) b_ro);
     166  rtems_test_assert((uintptr_t) &content_ro_1 <= (uintptr_t) e_ro);
     167  rtems_test_assert((uintptr_t) &content_ro_2 <= (uintptr_t) e_ro);
     168  rtems_test_assert((uintptr_t) &content_ro_3 <= (uintptr_t) e_ro);
    154169}
    155170
Note: See TracChangeset for help on using the changeset viewer.