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