source: rtems-docs/c-user/linker_sets.rst @ a4b23d9

5
Last change on this file since a4b23d9 was a4b23d9, checked in by Sebastian Huber <sebastian.huber@…>, on 02/05/20 at 08:05:07

c-user: Document new linker set macros

Adjust copyright. Linker sets were introduced in 2015.

Update #2408.
Close #3865.

  • Property mode set to 100644
File size: 23.8 KB
Line 
1.. SPDX-License-Identifier: CC-BY-SA-4.0
2
3.. Copyright (C) 2015, 2020 embedded brains GmbH
4.. Copyright (C) 2015, 2020 Sebastian Huber
5
6.. index:: linkersets
7
8.. _linker_sets:
9
10Linker Sets
11***********
12
13Introduction
14============
15
16Linker sets are a flexible means to create arrays of items out of a set of
17object files at link-time.  For example its possible to define an item *I* of
18type *T* in object file *A* and an item *J* of type *T* in object file *B* to
19be a member of a linker set *S*.  The linker will then collect these two items
20*I* and *J* and place them in consecutive memory locations, so that they can be
21accessed like a normal array defined in one object file.  The size of a linker
22set is defined by its begin and end markers.  A linker set may be empty.  It
23should only contain items of the same type.
24
25The following macros are provided to create, populate and use linker sets.
26
27- RTEMS_LINKER_SET_BEGIN_ - Designator of the linker set begin marker
28
29- RTEMS_LINKER_SET_END_ - Designator of the linker set end marker
30
31- RTEMS_LINKER_SET_SIZE_ - The linker set size in characters
32
33- RTEMS_LINKER_SET_ITEM_COUNT_ - The linker set item count
34
35- RTEMS_LINKER_SET_IS_EMPTY_ - Is the linker set empty?
36
37- RTEMS_LINKER_SET_FOREACH_ - Iterate through the linker set items
38
39- RTEMS_LINKER_ROSET_DECLARE_ - Declares a read-only linker set
40
41- RTEMS_LINKER_ROSET_ - Defines a read-only linker set
42
43- RTEMS_LINKER_ROSET_ITEM_DECLARE_ - Declares a read-only linker set item
44
45- RTEMS_LINKER_ROSET_ITEM_ORDERED_DECLARE_ - Declares an ordered read-only linker set item
46
47- RTEMS_LINKER_ROSET_ITEM_REFERENCE_ - References a read-only linker set item
48
49- RTEMS_LINKER_ROSET_ITEM_ - Defines a read-only linker set item
50
51- RTEMS_LINKER_ROSET_ITEM_ORDERED_ - Defines an ordered read-only linker set item
52
53- RTEMS_LINKER_ROSET_CONTENT_ - Marks a declaration as a read-only linker set content
54
55- RTEMS_LINKER_RWSET_DECLARE_ - Declares a read-write linker set
56
57- RTEMS_LINKER_RWSET_ - Defines a read-write linker set
58
59- RTEMS_LINKER_RWSET_ITEM_DECLARE_ - Declares a read-write linker set item
60
61- RTEMS_LINKER_RWSET_ITEM_ORDERED_DECLARE_ - Declares an ordered read-write linker set item
62
63- RTEMS_LINKER_RWSET_ITEM_REFERENCE_ - References a read-write linker set item
64
65- RTEMS_LINKER_RWSET_ITEM_ - Defines a read-write linker set item
66
67- RTEMS_LINKER_RWSET_ITEM_ORDERED_ - Defines an ordered read-write linker set item
68
69- RTEMS_LINKER_RWSET_CONTENT_ - Marks a declaration as a read-write linker set content
70
71Background
72==========
73
74Linker sets are used not only in RTEMS, but also for example in Linux, in
75FreeBSD, for the GNU C constructor extension and for global C++ constructors.
76They provide a space efficient and flexible means to initialize modules.  A
77linker set consists of
78
79- dedicated input sections for the linker (e.g. ``.ctors`` and ``.ctors.*`` in
80  the case of global constructors),
81
82- a begin marker (e.g. provided by ``crtbegin.o``, and
83
84- an end marker (e.g. provided by ``ctrend.o``).
85
86A module may place a certain data item into the dedicated input section.  The
87linker will collect all such data items in this section and creates a begin and
88end marker.  The initialization code can then use the begin and end markers to
89find all the collected data items (e.g. pointers to initialization functions).
90
91In the linker command file of the GNU linker we need the following output
92section descriptions.
93
94.. code-block:: c
95
96    /* To be placed in a read-only memory region */
97    .rtemsroset : {
98      KEEP (*(SORT(.rtemsroset.*)))
99    }
100    /* To be placed in a read-write memory region */
101    .rtemsrwset : {
102      KEEP (*(SORT(.rtemsrwset.*)))
103    }
104
105The ``KEEP()`` ensures that a garbage collection by the linker will not discard
106the content of this section.  This would normally be the case since the linker
107set items are not referenced directly.  The ``SORT()`` directive sorts the
108input sections lexicographically.  Please note the lexicographical order of the
109``.begin``, ``.content`` and ``.end`` section name parts in the RTEMS linker
110sets macros which ensures that the position of the begin and end markers are
111right.
112
113So, what is the benefit of using linker sets to initialize modules?  It can be
114used to initialize and include only those RTEMS managers and other components
115which are used by the application.  For example, in case an application uses
116message queues, it must call ``rtems_message_queue_create()``.  In the module
117implementing this function, we can place a linker set item and register the
118message queue handler constructor.  Otherwise, in case the application does not
119use message queues, there will be no reference to the
120``rtems_message_queue_create()`` function and the constructor is not
121registered, thus nothing of the message queue handler will be in the final
122executable.
123
124For an example see test program :file:`sptests/splinkersets01`.
125
126Directives
127==========
128
129.. raw:: latex
130
131   \clearpage
132
133.. index:: RTEMS_LINKER_SET_BEGIN
134
135.. _RTEMS_LINKER_SET_BEGIN:
136
137RTEMS_LINKER_SET_BEGIN - Designator of the linker set begin marker
138------------------------------------------------------------------
139
140CALLING SEQUENCE:
141    .. code-block:: c
142
143        type *begin = RTEMS_LINKER_SET_BEGIN( set );
144
145DESCRIPTION:
146    This macro generates the designator of the begin marker of the linker set
147    identified by ``set``.  The item at the begin marker address is the first
148    member of the linker set if it exists, e.g. the linker set is not empty.  A
149    linker set is empty, if and only if the begin and end markers have the same
150    address.
151
152    The ``set`` parameter itself must be a valid C designator on which no macro
153    expansion is performed.  It uniquely identifies the linker set.
154
155NOTE:
156    The compiler may try to be smart.  In general it will not work to assign linker
157    set begin and end addresses to pointer variables and treat them like
158    ordinary pointers.  The compiler may exploit the fact that actually two
159    distinct objects are involved and use this to optimize.  To avoid trouble
160    use :ref:`RTEMS_LINKER_SET_SIZE`, :ref:`RTEMS_LINKER_SET_ITEM_COUNT`,
161    :ref:`RTEMS_LINKER_SET_IS_EMPTY` and :ref:`RTEMS_LINKER_SET_FOREACH`.
162
163.. raw:: latex
164
165   \clearpage
166
167.. index:: RTEMS_LINKER_SET_END
168
169.. _RTEMS_LINKER_SET_END:
170
171RTEMS_LINKER_SET_END - Designator of the linker set end marker
172--------------------------------------------------------------
173
174CALLING SEQUENCE:
175    .. code-block:: c
176
177        type *end = RTEMS_LINKER_SET_END( set );
178
179DESCRIPTION:
180    This macro generates the designator of the end marker of the linker set
181    identified by ``set``.  The item at the end marker address is not a member
182    of the linker set.  The ``set`` parameter itself must be a valid C
183    designator on which no macro expansion is performed.  It uniquely
184    identifies the linker set.
185
186.. raw:: latex
187
188   \clearpage
189
190.. index:: RTEMS_LINKER_SET_SIZE
191
192.. _RTEMS_LINKER_SET_SIZE:
193
194RTEMS_LINKER_SET_SIZE - The linker set size in characters
195---------------------------------------------------------
196
197CALLING SEQUENCE:
198    .. code-block:: c
199
200        size_t size = RTEMS_LINKER_SET_SIZE( set );
201
202DESCRIPTION:
203    This macro returns the size of the linker set identified by ``set`` in
204    characters.  The ``set`` parameter itself must be a valid C designator on
205    which no macro expansion is performed.  It uniquely identifies the linker
206    set.
207
208.. raw:: latex
209
210   \clearpage
211
212.. index:: RTEMS_LINKER_SET_ITEM_COUNT
213
214.. _RTEMS_LINKER_SET_ITEM_COUNT:
215
216RTEMS_LINKER_SET_ITEM_COUNT - The linker set item count
217---------------------------------------------------------
218
219CALLING SEQUENCE:
220    .. code-block:: c
221
222        size_t item_count = RTEMS_LINKER_SET_ITEM_COUNT( set );
223
224DESCRIPTION:
225    This macro returns the item count of the linker set identified by ``set``.
226    The ``set`` parameter itself must be a valid C designator on which no macro
227    expansion is performed.  It uniquely identifies the linker set.
228
229.. raw:: latex
230
231   \clearpage
232
233.. index:: RTEMS_LINKER_SET_IS_EMPTY
234
235.. _RTEMS_LINKER_SET_IS_EMPTY:
236
237RTEMS_LINKER_SET_IS_EMPTY - Is the linker set empty?
238---------------------------------------------------------
239
240CALLING SEQUENCE:
241    .. code-block:: c
242
243        bool is_empty = RTEMS_LINKER_SET_IS_EMPTY( set );
244
245DESCRIPTION:
246    This macro returns true if the linker set identified by ``set`` is empty,
247    otherwise returns false.  The ``set`` parameter itself must be a valid C
248    designator on which no macro expansion is performed.  It uniquely
249    identifies the linker set.
250
251.. raw:: latex
252
253   \clearpage
254
255.. index:: RTEMS_LINKER_SET_FOREACH
256
257.. _RTEMS_LINKER_SET_FOREACH:
258
259RTEMS_LINKER_SET_FOREACH - Iterate through the linker set items
260---------------------------------------------------------
261
262CALLING SEQUENCE:
263    .. code-block:: c
264
265        RTEMS_LINKER_RWSET( myset, int );
266
267        int count( void )
268        {
269          int *item;
270          int n;
271
272          n = 0;
273          RTEMS_LINKER_SET_FOREACH( myset, item ) {
274            n += *item;
275          }
276
277          return n;
278        }
279
280DESCRIPTION:
281    This macro generates a for loop statement which iterates through each item
282    of a linker set identified by ``set``.  The ``set`` parameter itself must
283    be a valid C designator on which no macro expansion is performed.  It
284    uniquely identifies the linker set.  The ``item`` parameter must be a
285    pointer to an item of the linker set.  It iterates through all items of the
286    linker set from begin to end.
287
288.. raw:: latex
289
290   \clearpage
291
292.. index:: RTEMS_LINKER_ROSET_DECLARE
293
294.. _RTEMS_LINKER_ROSET_DECLARE:
295
296RTEMS_LINKER_ROSET_DECLARE - Declares a read-only linker set
297------------------------------------------------------------
298
299CALLING SEQUENCE:
300    .. code-block:: c
301
302        RTEMS_LINKER_ROSET_DECLARE( set, type );
303
304DESCRIPTION:
305    This macro generates declarations for the begin and end markers of a
306    read-only linker set identified by ``set``.  The ``set`` parameter itself
307    must be a valid C designator on which no macro expansion is performed.  It
308    uniquely identifies the linker set. The ``type`` parameter defines the type
309    of the linker set items.  The type must be the same for all macro
310    invocations of a particular linker set.
311
312.. raw:: latex
313
314   \clearpage
315
316.. index:: RTEMS_LINKER_ROSET
317
318.. _RTEMS_LINKER_ROSET:
319
320RTEMS_LINKER_ROSET - Defines a read-only linker set
321---------------------------------------------------
322
323CALLING SEQUENCE:
324    .. code-block:: c
325
326        RTEMS_LINKER_ROSET( set, type );
327
328DESCRIPTION:
329    This macro generates definitions for the begin and end markers of a
330    read-only linker set identified by ``set``.  The ``set`` parameter itself
331    must be a valid C designator on which no macro expansion is performed.  It
332    uniquely identifies the linker set. The ``type`` parameter defines the type
333    of the linker set items.  The type must be the same for all macro
334    invocations of a particular linker set.
335
336.. raw:: latex
337
338   \clearpage
339
340.. index:: RTEMS_LINKER_ROSET_ITEM_DECLARE
341
342.. _RTEMS_LINKER_ROSET_ITEM_DECLARE:
343
344RTEMS_LINKER_ROSET_ITEM_DECLARE - Declares a read-only linker set item
345----------------------------------------------------------------------
346
347CALLING SEQUENCE:
348    .. code-block:: c
349
350        RTEMS_LINKER_ROSET_ITEM_DECLARE( set, type, item );
351
352DESCRIPTION:
353    This macro generates a declaration of an item contained in the read-only
354    linker set identified by ``set``.  For a description of the ``set``,
355    ``type``, and ``item`` parameters see :ref:`RTEMS_LINKER_ROSET_ITEM`.
356
357.. raw:: latex
358
359   \clearpage
360
361.. index:: RTEMS_LINKER_ROSET_ITEM_ORDERED_DECLARE
362
363.. _RTEMS_LINKER_ROSET_ITEM_ORDERED_DECLARE:
364
365RTEMS_LINKER_ROSET_ITEM_ORDERED_DECLARE - Declares an ordered read-only linker set item
366---------------------------------------------------------------------------------------
367
368CALLING SEQUENCE:
369    .. code-block:: c
370
371        RTEMS_LINKER_ROSET_ITEM_ORDERED_DECLARE( set, type, item, order );
372
373DESCRIPTION:
374    This macro generates a declaration of an ordered item contained in the
375    read-only linker set identified by ``set``.  For a description of the
376    ``set``, ``type``, ``item``, and ``order`` parameters see
377    :ref:`RTEMS_LINKER_ROSET_ITEM_ORDERED`.
378
379.. raw:: latex
380
381   \clearpage
382
383.. index:: RTEMS_LINKER_ROSET_ITEM_REFERENCE
384
385.. _RTEMS_LINKER_ROSET_ITEM_REFERENCE:
386
387RTEMS_LINKER_ROSET_ITEM_REFERENCE - References a read-only linker set item
388--------------------------------------------------------------------------
389
390CALLING SEQUENCE:
391    .. code-block:: c
392
393        RTEMS_LINKER_ROSET_ITEM_REFERENCE( set, type, item );
394
395DESCRIPTION:
396    This macro generates a reference to an item contained in the read-only
397    linker set identified by ``set``.  The ``set`` parameter itself must be a
398    valid C designator on which no macro expansion is performed.  It uniquely
399    identifies the linker set. The ``type`` parameter defines the type of the
400    linker set items.  The type must be the same for all macro invocations of a
401    particular linker set. The ``item`` parameter itself must be a valid C
402    designator on which no macro expansion is performed.  It uniquely
403    identifies an item in the linker set.
404
405.. raw:: latex
406
407   \clearpage
408
409.. index:: RTEMS_LINKER_ROSET_ITEM
410
411.. _RTEMS_LINKER_ROSET_ITEM:
412
413RTEMS_LINKER_ROSET_ITEM - Defines a read-only linker set item
414-------------------------------------------------------------
415
416CALLING SEQUENCE:
417    .. code-block:: c
418
419        RTEMS_LINKER_ROSET_ITEM( set, type, item );
420
421DESCRIPTION:
422    This macro generates a definition of an item contained in the read-only
423    linker set identified by ``set``.  The ``set`` parameter itself must be a
424    valid C designator on which no macro expansion is performed.  It uniquely
425    identifies the linker set. The ``type`` parameter defines the type of the
426    linker set items.  The type must be the same for all macro invocations of a
427    particular linker set. The ``item`` parameter itself must be a valid C
428    designator on which no macro expansion is performed.  It uniquely
429    identifies an item in the linker set.
430
431.. raw:: latex
432
433   \clearpage
434
435.. index:: RTEMS_LINKER_ROSET_ITEM_ORDERED
436
437.. _RTEMS_LINKER_ROSET_ITEM_ORDERED:
438
439RTEMS_LINKER_ROSET_ITEM_ORDERED - Defines an ordered read-only linker set item
440------------------------------------------------------------------------------
441
442CALLING SEQUENCE:
443    .. code-block:: c
444
445        RTEMS_LINKER_ROSET_ITEM_ORDERED( set, type, item, order );
446
447DESCRIPTION:
448    This macro generates a definition of an ordered item contained in the
449    read-only linker set identified by ``set``.  The ``set`` parameter itself
450    must be a valid C designator on which no macro expansion is performed.  It
451    uniquely identifies the linker set. The ``type`` parameter defines the type
452    of the linker set items.  The type must be the same for all macro
453    invocations of a particular linker set.  The ``item`` parameter itself must
454    be a valid C designator on which no macro expansion is performed.  It
455    uniquely identifies an item in the linker set. The ``order`` parameter must
456    be a valid linker input section name part on which macro expansion is
457    performed.  The items are lexicographically ordered according to the
458    ``order`` parameter within a linker set.  Ordered items are placed before
459    unordered items in the linker set.
460
461NOTES:
462    To be resilient to typos in the order parameter, it is recommended to use
463    the following construct in macros defining items for a particular linker
464    set (see enum in ``XYZ_ITEM()``).
465
466    .. code-block:: c
467
468        #include <rtems/linkersets.h>
469
470        typedef struct {
471          int foo;
472        } xyz_item;
473
474        /* The XYZ-order defines */
475        #define XYZ_ORDER_FIRST 0x00001000
476        #define XYZ_ORDER_AND_SO_ON 0x00002000
477
478        /* Defines an ordered XYZ-item */
479        #define XYZ_ITEM( item, order ) \
480          enum { xyz_##item = order }; \
481          RTEMS_LINKER_ROSET_ITEM_ORDERED( \
482            xyz, const xyz_item *, item, order \
483          ) = { &item }
484
485        /* Example item */
486        static const xyz_item some_item = { 123 };
487        XYZ_ITEM( some_item, XYZ_ORDER_FIRST );
488
489.. raw:: latex
490
491   \clearpage
492
493.. index:: RTEMS_LINKER_ROSET_CONTENT
494
495.. _RTEMS_LINKER_ROSET_CONTENT:
496
497RTEMS_LINKER_ROSET_CONTENT - Marks a declaration as a read-only linker set content
498----------------------------------------------------------------------------------
499
500CALLING SEQUENCE:
501    .. code-block:: c
502
503        RTEMS_LINKER_ROSET_CONTENT( set, decl );
504
505DESCRIPTION:
506    This macro marks a declaration as a read-only linker set content.  The
507    linker set is identified by ``set``.  The ``set`` parameter itself must be
508    a valid C designator on which no macro expansion is performed.  It uniquely
509    identifies the linker set. The ``decl`` parameter must be an arbitrary
510    variable declaration.
511
512.. raw:: latex
513
514   \clearpage
515
516.. index:: RTEMS_LINKER_RWSET_DECLARE
517
518.. _RTEMS_LINKER_RWSET_DECLARE:
519
520RTEMS_LINKER_RWSET_DECLARE - Declares a read-write linker set
521-------------------------------------------------------------
522
523CALLING SEQUENCE:
524    .. code-block:: c
525
526        RTEMS_LINKER_RWSET_DECLARE( set, type );
527
528DESCRIPTION:
529    This macro generates declarations for the begin and end markers of a
530    read-write linker set identified by ``set``.  The ``set`` parameter itself
531    must be a valid C designator on which no macro expansion is performed.  It
532    uniquely identifies the linker set. The ``type`` parameter defines the type
533    of the linker set items.  The type must be the same for all macro
534    invocations of a particular linker set.
535
536.. raw:: latex
537
538   \clearpage
539
540.. index:: RTEMS_LINKER_RWSET
541
542.. _RTEMS_LINKER_RWSET:
543
544RTEMS_LINKER_RWSET - Defines a read-write linker set
545----------------------------------------------------
546
547CALLING SEQUENCE:
548    .. code-block:: c
549
550        RTEMS_LINKER_RWSET( set, type );
551
552DESCRIPTION:
553    This macro generates definitions for the begin and end markers of a
554    read-write linker set identified by ``set``.  The ``set`` parameter itself
555    must be a valid C designator on which no macro expansion is performed.  It
556    uniquely identifies the linker set. The ``type`` parameter defines the type
557    of the linker set items.  The type must be the same for all macro
558    invocations of a particular linker set.
559
560.. raw:: latex
561
562   \clearpage
563
564.. index:: RTEMS_LINKER_RWSET_ITEM_DECLARE
565
566.. _RTEMS_LINKER_RWSET_ITEM_DECLARE:
567
568RTEMS_LINKER_RWSET_ITEM_DECLARE - Declares a read-write linker set item
569-----------------------------------------------------------------------
570
571CALLING SEQUENCE:
572    .. code-block:: c
573
574        RTEMS_LINKER_RWSET_ITEM_DECLARE( set, type, item );
575
576DESCRIPTION:
577    This macro generates a declaration of an item contained in the read-write
578    linker set identified by ``set``.  For a description of the ``set``,
579    ``type``, and ``item`` parameters see :ref:`RTEMS_LINKER_RWSET_ITEM`.
580
581.. raw:: latex
582
583   \clearpage
584
585.. index:: RTEMS_LINKER_RWSET_ITEM_ORDERED_DECLARE
586
587.. _RTEMS_LINKER_RWSET_ITEM_ORDERED_DECLARE:
588
589RTEMS_LINKER_RWSET_ITEM_ORDERED_DECLARE - Declares an ordered read-write linker set item
590----------------------------------------------------------------------------------------
591
592CALLING SEQUENCE:
593    .. code-block:: c
594
595        RTEMS_LINKER_RWSET_ITEM_ORDERED_DECLARE( set, type, item, order );
596
597DESCRIPTION:
598    This macro generates a declaration of an ordered item contained in the
599    read-write linker set identified by ``set``.  For a description of the
600    ``set``, ``type``, ``item``, and ``order`` parameters see
601    :ref:`RTEMS_LINKER_RWSET_ITEM_ORDERED`.
602
603.. raw:: latex
604
605   \clearpage
606
607.. index:: RTEMS_LINKER_RWSET_ITEM_REFERENCE
608
609.. _RTEMS_LINKER_RWSET_ITEM_REFERENCE:
610
611RTEMS_LINKER_RWSET_ITEM_REFERENCE - References a read-write linker set item
612---------------------------------------------------------------------------
613
614CALLING SEQUENCE:
615    .. code-block:: c
616
617        RTEMS_LINKER_RWSET_ITEM_REFERENCE( set, type, item );
618
619DESCRIPTION:
620    This macro generates a reference to an item contained in the read-write
621    linker set identified by ``set``.  The ``set`` parameter itself must be a
622    valid C designator on which no macro expansion is performed.  It uniquely
623    identifies the linker set. The ``type`` parameter defines the type of the
624    linker set items.  The type must be the same for all macro invocations of a
625    particular linker set. The ``item`` parameter itself must be a valid C
626    designator on which no macro expansion is performed.  It uniquely
627    identifies an item in the linker set.
628
629.. raw:: latex
630
631   \clearpage
632
633.. index:: RTEMS_LINKER_RWSET_ITEM
634
635.. _RTEMS_LINKER_RWSET_ITEM:
636
637RTEMS_LINKER_RWSET_ITEM - Defines a read-write linker set item
638--------------------------------------------------------------
639
640CALLING SEQUENCE:
641    .. code-block:: c
642
643        RTEMS_LINKER_RWSET_ITEM( set, type, item );
644
645DESCRIPTION:
646    This macro generates a definition of an item contained in the read-write
647    linker set identified by ``set``.  The ``set`` parameter itself must be a
648    valid C designator on which no macro expansion is performed.  It uniquely
649    identifies the linker set. The ``type`` parameter defines the type of the
650    linker set items.  The type must be the same for all macro invocations of a
651    particular linker set. The ``item`` parameter itself must be a valid C
652    designator on which no macro expansion is performed.  It uniquely
653    identifies an item in the linker set.
654
655.. raw:: latex
656
657   \clearpage
658
659.. index:: RTEMS_LINKER_RWSET_ITEM_ORDERED
660
661.. _RTEMS_LINKER_RWSET_ITEM_ORDERED:
662
663RTEMS_LINKER_RWSET_ITEM_ORDERED - Defines an ordered read-write linker set item
664-------------------------------------------------------------------------------
665
666CALLING SEQUENCE:
667    .. code-block:: c
668
669        RTEMS_LINKER_RWSET_ITEM_ORDERED( set, type, item, order );
670
671DESCRIPTION:
672    This macro generates a definition of an ordered item contained in the
673    read-write linker set identified by ``set``.  The ``set`` parameter itself
674    must be a valid C designator on which no macro expansion is performed.  It
675    uniquely identifies the linker set. The ``type`` parameter defines the type
676    of the linker set items.  The type must be the same for all macro
677    invocations of a particular linker set.  The ``item`` parameter itself must
678    be a valid C designator on which no macro expansion is performed.  It
679    uniquely identifies an item in the linker set. The ``order`` parameter must
680    be a valid linker input section name part on which macro expansion is
681    performed.  The items are lexicographically ordered according to the
682    ``order`` parameter within a linker set.  Ordered items are placed before
683    unordered items in the linker set.
684
685NOTES:
686    To be resilient to typos in the order parameter, it is recommended to use
687    the following construct in macros defining items for a particular linker
688    set (see enum in ``XYZ_ITEM()``).
689
690    .. code-block:: c
691
692        #include <rtems/linkersets.h>
693
694        typedef struct {
695          int foo;
696        } xyz_item;
697
698        /* The XYZ-order defines */
699        #define XYZ_ORDER_FIRST 0x00001000
700        #define XYZ_ORDER_AND_SO_ON 0x00002000
701
702        /* Defines an ordered XYZ-item */
703        #define XYZ_ITEM( item, order ) \
704          enum { xyz_##item = order }; \
705          RTEMS_LINKER_RWSET_ITEM_ORDERED( \
706            xyz, const xyz_item *, item, order \
707          ) = { &item }
708
709        /* Example item */
710        static const xyz_item some_item = { 123 };
711        XYZ_ITEM( some_item, XYZ_ORDER_FIRST );
712
713.. raw:: latex
714
715   \clearpage
716
717.. index:: RTEMS_LINKER_RWSET_CONTENT
718
719.. _RTEMS_LINKER_RWSET_CONTENT:
720
721RTEMS_LINKER_RWSET_CONTENT - Marks a declaration as a read-write linker set content
722-----------------------------------------------------------------------------------
723
724CALLING SEQUENCE:
725    .. code-block:: c
726
727        RTEMS_LINKER_RWSET_CONTENT( set, decl );
728
729DESCRIPTION:
730    This macro marks a declaration as a read-write linker set content.  The
731    linker set is identified by ``set``.  The ``set`` parameter itself must be
732    a valid C designator on which no macro expansion is performed.  It uniquely
733    identifies the linker set. The ``decl`` parameter must be an arbitrary
734    variable declaration.
Note: See TracBrowser for help on using the repository browser.