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 | .. _Linker Sets: |
---|
8 | |
---|
9 | Linker Sets |
---|
10 | *********** |
---|
11 | |
---|
12 | .. index:: linkersets |
---|
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_ROSET_DECLARE_ - Declares a read-only linker set |
---|
35 | |
---|
36 | - RTEMS_LINKER_ROSET_ - Defines a read-only linker set |
---|
37 | |
---|
38 | - RTEMS_LINKER_ROSET_ITEM_DECLARE_ - Declares a read-only linker set item |
---|
39 | |
---|
40 | - RTEMS_LINKER_ROSET_ITEM_REFERENCE_ - References a read-only linker set item |
---|
41 | |
---|
42 | - RTEMS_LINKER_ROSET_ITEM_ - Defines a read-only linker set item |
---|
43 | |
---|
44 | - RTEMS_LINKER_ROSET_ITEM_ORDERED_ - Defines an ordered read-only linker set item |
---|
45 | |
---|
46 | - RTEMS_LINKER_RWSET_DECLARE_ - Declares a read-write linker set |
---|
47 | |
---|
48 | - RTEMS_LINKER_RWSET_ - Defines a read-write linker set |
---|
49 | |
---|
50 | - RTEMS_LINKER_RWSET_ITEM_DECLARE_ - Declares a read-write linker set item |
---|
51 | |
---|
52 | - RTEMS_LINKER_RWSET_ITEM_REFERENCE_ - References a read-write linker set item |
---|
53 | |
---|
54 | - RTEMS_LINKER_RWSET_ITEM_ - Defines a read-write linker set item |
---|
55 | |
---|
56 | - RTEMS_LINKER_RWSET_ITEM_ORDERED_ - Defines an ordered read-write linker set item |
---|
57 | |
---|
58 | Background |
---|
59 | ========== |
---|
60 | |
---|
61 | Linker sets are used not only in RTEMS, but also for example in Linux, in |
---|
62 | FreeBSD, for the GNU C constructor extension and for global C++ constructors. |
---|
63 | They provide a space efficient and flexible means to initialize modules. A |
---|
64 | linker set consists of |
---|
65 | |
---|
66 | - dedicated input sections for the linker (e.g. ``.ctors`` and ``.ctors.*`` in |
---|
67 | the case of global constructors), |
---|
68 | |
---|
69 | - a begin marker (e.g. provided by ``crtbegin.o``, and |
---|
70 | |
---|
71 | - an end marker (e.g. provided by ``ctrend.o``). |
---|
72 | |
---|
73 | A module may place a certain data item into the dedicated input section. The |
---|
74 | linker will collect all such data items in this section and creates a begin and |
---|
75 | end marker. The initialization code can then use the begin and end markers to |
---|
76 | find all the collected data items (e.g. pointers to initialization functions). |
---|
77 | |
---|
78 | In the linker command file of the GNU linker we need the following output |
---|
79 | section descriptions. |
---|
80 | |
---|
81 | .. code-block:: c |
---|
82 | |
---|
83 | /* To be placed in a read-only memory region */ |
---|
84 | .rtemsroset : { |
---|
85 | KEEP (*(SORT(.rtemsroset.*))) |
---|
86 | } |
---|
87 | /* To be placed in a read-write memory region */ |
---|
88 | .rtemsrwset : { |
---|
89 | KEEP (*(SORT(.rtemsrwset.*))) |
---|
90 | } |
---|
91 | |
---|
92 | The ``KEEP()`` ensures that a garbage collection by the linker will not discard |
---|
93 | the content of this section. This would normally be the case since the linker |
---|
94 | set items are not referenced directly. The ``SORT()`` directive sorts the |
---|
95 | input sections lexicographically. Please note the lexicographical order of the |
---|
96 | ``.begin``, ``.content`` and ``.end`` section name parts in the RTEMS linker |
---|
97 | sets macros which ensures that the position of the begin and end markers are |
---|
98 | right. |
---|
99 | |
---|
100 | So, what is the benefit of using linker sets to initialize modules? It can be |
---|
101 | used to initialize and include only those RTEMS managers and other components |
---|
102 | which are used by the application. For example, in case an application uses |
---|
103 | message queues, it must call ``rtems_message_queue_create()``. In the module |
---|
104 | implementing this function, we can place a linker set item and register the |
---|
105 | message queue handler constructor. Otherwise, in case the application does not |
---|
106 | use message queues, there will be no reference to the |
---|
107 | ``rtems_message_queue_create()`` function and the constructor is not |
---|
108 | registered, thus nothing of the message queue handler will be in the final |
---|
109 | executable. |
---|
110 | |
---|
111 | For an example see test program :file:`sptests/splinkersets01`. |
---|
112 | |
---|
113 | Directives |
---|
114 | ========== |
---|
115 | |
---|
116 | .. raw:: latex |
---|
117 | |
---|
118 | \clearpage |
---|
119 | |
---|
120 | .. _RTEMS_LINKER_SET_BEGIN: |
---|
121 | |
---|
122 | RTEMS_LINKER_SET_BEGIN - Designator of the linker set begin marker |
---|
123 | ------------------------------------------------------------------ |
---|
124 | .. index:: RTEMS_LINKER_SET_BEGIN |
---|
125 | |
---|
126 | CALLING SEQUENCE: |
---|
127 | .. code-block:: c |
---|
128 | |
---|
129 | volatile type *begin = RTEMS_LINKER_SET_BEGIN( set ); |
---|
130 | |
---|
131 | DESCRIPTION: |
---|
132 | This macro generates the designator of the begin marker of the linker set |
---|
133 | identified by ``set``. The item at the begin marker address is the first |
---|
134 | member of the linker set if it exists, e.g. the linker set is not empty. A |
---|
135 | linker set is empty, if and only if the begin and end markers have the same |
---|
136 | address. |
---|
137 | |
---|
138 | The ``set`` parameter itself must be a valid C designator on which no macro |
---|
139 | expansion is performed. It uniquely identifies the linker set. |
---|
140 | |
---|
141 | .. raw:: latex |
---|
142 | |
---|
143 | \clearpage |
---|
144 | |
---|
145 | .. _RTEMS_LINKER_SET_END: |
---|
146 | |
---|
147 | RTEMS_LINKER_SET_END - Designator of the linker set end marker |
---|
148 | -------------------------------------------------------------- |
---|
149 | .. index:: RTEMS_LINKER_SET_END |
---|
150 | |
---|
151 | CALLING SEQUENCE: |
---|
152 | .. code-block:: c |
---|
153 | |
---|
154 | volatile type *end = RTEMS_LINKER_SET_END( set ); |
---|
155 | |
---|
156 | DESCRIPTION: |
---|
157 | This macro generates the designator of the end marker of the linker set |
---|
158 | identified by ``set``. The item at the end marker address is not a member |
---|
159 | of the linker set. The ``set`` parameter itself must be a valid C |
---|
160 | designator on which no macro expansion is performed. It uniquely |
---|
161 | identifies the linker set. |
---|
162 | |
---|
163 | .. raw:: latex |
---|
164 | |
---|
165 | \clearpage |
---|
166 | |
---|
167 | .. _RTEMS_LINKER_SET_SIZE: |
---|
168 | |
---|
169 | RTEMS_LINKER_SET_SIZE - The linker set size in characters |
---|
170 | --------------------------------------------------------- |
---|
171 | .. index:: RTEMS_LINKER_SET_SIZE |
---|
172 | |
---|
173 | CALLING SEQUENCE: |
---|
174 | .. code-block:: c |
---|
175 | |
---|
176 | size_t size = RTEMS_LINKER_SET_SIZE( set ); |
---|
177 | |
---|
178 | DESCRIPTION: |
---|
179 | This macro returns the size of the linker set identified by ``set`` in |
---|
180 | characters. The ``set`` parameter itself must be a valid C designator on |
---|
181 | which no macro expansion is performed. It uniquely identifies the linker |
---|
182 | set. |
---|
183 | |
---|
184 | .. raw:: latex |
---|
185 | |
---|
186 | \clearpage |
---|
187 | |
---|
188 | .. _RTEMS_LINKER_ROSET_DECLARE: |
---|
189 | |
---|
190 | RTEMS_LINKER_ROSET_DECLARE - Declares a read-only linker set |
---|
191 | ------------------------------------------------------------ |
---|
192 | .. index:: RTEMS_LINKER_ROSET_DECLARE |
---|
193 | |
---|
194 | CALLING SEQUENCE: |
---|
195 | .. code-block:: c |
---|
196 | |
---|
197 | RTEMS_LINKER_ROSET_DECLARE( set, type ); |
---|
198 | |
---|
199 | DESCRIPTION: |
---|
200 | This macro generates declarations for the begin and end markers of a |
---|
201 | read-only linker set identified by ``set``. The ``set`` parameter itself |
---|
202 | must be a valid C designator on which no macro expansion is performed. It |
---|
203 | uniquely identifies the linker set. The ``type`` parameter defines the type |
---|
204 | of the linker set items. The type must be the same for all macro |
---|
205 | invocations of a particular linker set. |
---|
206 | |
---|
207 | .. raw:: latex |
---|
208 | |
---|
209 | \clearpage |
---|
210 | |
---|
211 | .. _RTEMS_LINKER_ROSET: |
---|
212 | |
---|
213 | RTEMS_LINKER_ROSET - Defines a read-only linker set |
---|
214 | --------------------------------------------------- |
---|
215 | .. index:: RTEMS_LINKER_ROSET |
---|
216 | |
---|
217 | CALLING SEQUENCE: |
---|
218 | .. code-block:: c |
---|
219 | |
---|
220 | RTEMS_LINKER_ROSET( set, type ); |
---|
221 | |
---|
222 | DESCRIPTION: |
---|
223 | This macro generates definitions for the begin and end markers of a |
---|
224 | read-only linker set identified by ``set``. The ``set`` parameter itself |
---|
225 | must be a valid C designator on which no macro expansion is performed. It |
---|
226 | uniquely identifies the linker set. The ``type`` parameter defines the type |
---|
227 | of the linker set items. The type must be the same for all macro |
---|
228 | invocations of a particular linker set. |
---|
229 | |
---|
230 | .. raw:: latex |
---|
231 | |
---|
232 | \clearpage |
---|
233 | |
---|
234 | .. _RTEMS_LINKER_ROSET_ITEM_DECLARE: |
---|
235 | |
---|
236 | RTEMS_LINKER_ROSET_ITEM_DECLARE - Declares a read-only linker set item |
---|
237 | ---------------------------------------------------------------------- |
---|
238 | .. index:: RTEMS_LINKER_ROSET_ITEM_DECLARE |
---|
239 | |
---|
240 | CALLING SEQUENCE: |
---|
241 | .. code-block:: c |
---|
242 | |
---|
243 | RTEMS_LINKER_ROSET_ITEM_DECLARE( set, type, item ); |
---|
244 | |
---|
245 | DESCRIPTION: |
---|
246 | This macro generates a declaration of an item contained in the read-only |
---|
247 | linker set identified by ``set``. The ``set`` parameter itself must be a |
---|
248 | valid C designator on which no macro expansion is performed. It uniquely |
---|
249 | identifies the linker set. The ``type`` parameter defines the type of the |
---|
250 | linker set items. The type must be the same for all macro invocations of a |
---|
251 | particular linker set. The ``item`` parameter itself must be a valid C |
---|
252 | designator on which no macro expansion is performed. It uniquely |
---|
253 | identifies an item in the linker set. |
---|
254 | |
---|
255 | .. raw:: latex |
---|
256 | |
---|
257 | \clearpage |
---|
258 | |
---|
259 | .. _RTEMS_LINKER_ROSET_ITEM_REFERENCE: |
---|
260 | |
---|
261 | RTEMS_LINKER_ROSET_ITEM_REFERENCE - References a read-only linker set item |
---|
262 | -------------------------------------------------------------------------- |
---|
263 | .. index:: RTEMS_LINKER_ROSET_ITEM_REFERENCE |
---|
264 | |
---|
265 | CALLING SEQUENCE: |
---|
266 | .. code-block:: c |
---|
267 | |
---|
268 | RTEMS_LINKER_ROSET_ITEM_REFERENCE( set, type, item ); |
---|
269 | |
---|
270 | DESCRIPTION: |
---|
271 | This macro generates a reference to an item contained in the read-only |
---|
272 | linker set identified by ``set``. The ``set`` parameter itself must be a |
---|
273 | valid C designator on which no macro expansion is performed. It uniquely |
---|
274 | identifies the linker set. The ``type`` parameter defines the type of the |
---|
275 | linker set items. The type must be the same for all macro invocations of a |
---|
276 | particular linker set. The ``item`` parameter itself must be a valid C |
---|
277 | designator on which no macro expansion is performed. It uniquely |
---|
278 | identifies an item in the linker set. |
---|
279 | |
---|
280 | .. raw:: latex |
---|
281 | |
---|
282 | \clearpage |
---|
283 | |
---|
284 | .. _RTEMS_LINKER_ROSET_ITEM: |
---|
285 | |
---|
286 | RTEMS_LINKER_ROSET_ITEM - Defines a read-only linker set item |
---|
287 | ------------------------------------------------------------- |
---|
288 | .. index:: RTEMS_LINKER_ROSET_ITEM |
---|
289 | |
---|
290 | CALLING SEQUENCE: |
---|
291 | .. code-block:: c |
---|
292 | |
---|
293 | RTEMS_LINKER_ROSET_ITEM( set, type, item ); |
---|
294 | |
---|
295 | DESCRIPTION: |
---|
296 | This macro generates a definition of an item contained in the read-only |
---|
297 | linker set identified by ``set``. The ``set`` parameter itself must be a |
---|
298 | valid C designator on which no macro expansion is performed. It uniquely |
---|
299 | identifies the linker set. The ``type`` parameter defines the type of the |
---|
300 | linker set items. The type must be the same for all macro invocations of a |
---|
301 | particular linker set. The ``item`` parameter itself must be a valid C |
---|
302 | designator on which no macro expansion is performed. It uniquely |
---|
303 | identifies an item in the linker set. |
---|
304 | |
---|
305 | .. raw:: latex |
---|
306 | |
---|
307 | \clearpage |
---|
308 | |
---|
309 | .. _RTEMS_LINKER_ROSET_ITEM_ORDERED: |
---|
310 | |
---|
311 | RTEMS_LINKER_ROSET_ITEM_ORDERED - Defines an ordered read-only linker set item |
---|
312 | ------------------------------------------------------------------------------ |
---|
313 | .. index:: RTEMS_LINKER_ROSET_ITEM_ORDERED |
---|
314 | |
---|
315 | CALLING SEQUENCE: |
---|
316 | .. code-block:: c |
---|
317 | |
---|
318 | RTEMS_LINKER_ROSET_ITEM_ORDERED( set, type, item, order ); |
---|
319 | |
---|
320 | DESCRIPTION: |
---|
321 | This macro generates a definition of an ordered item contained in the |
---|
322 | read-only linker set identified by ``set``. The ``set`` parameter itself |
---|
323 | must be a valid C designator on which no macro expansion is performed. It |
---|
324 | uniquely identifies the linker set. The ``type`` parameter defines the type |
---|
325 | of the linker set items. The type must be the same for all macro |
---|
326 | invocations of a particular linker set. The ``item`` parameter itself must |
---|
327 | be a valid C designator on which no macro expansion is performed. It |
---|
328 | uniquely identifies an item in the linker set. The ``order`` parameter must |
---|
329 | be a valid linker input section name part on which macro expansion is |
---|
330 | performed. The items are lexicographically ordered according to the |
---|
331 | ``order`` parameter within a linker set. Ordered items are placed before |
---|
332 | unordered items in the linker set. |
---|
333 | |
---|
334 | NOTES: |
---|
335 | To be resilient to typos in the order parameter, it is recommended to use |
---|
336 | the following construct in macros defining items for a particular linker |
---|
337 | set (see enum in ``XYZ_ITEM()``). |
---|
338 | |
---|
339 | .. code-block:: c |
---|
340 | |
---|
341 | #include <rtems/linkersets.h> |
---|
342 | |
---|
343 | typedef struct { |
---|
344 | int foo; |
---|
345 | } xyz_item; |
---|
346 | |
---|
347 | /* The XYZ-order defines */ |
---|
348 | #define XYZ_ORDER_FIRST 0x00001000 |
---|
349 | #define XYZ_ORDER_AND_SO_ON 0x00002000 |
---|
350 | |
---|
351 | /* Defines an ordered XYZ-item */ |
---|
352 | #define XYZ_ITEM( item, order ) \ |
---|
353 | enum { xyz_##item = order - order }; \ |
---|
354 | RTEMS_LINKER_ROSET_ITEM_ORDERED( \ |
---|
355 | xyz, const xyz_item *, item, order \ |
---|
356 | ) = { &item } |
---|
357 | |
---|
358 | /* Example item */ |
---|
359 | static const xyz_item some_item = { 123 }; |
---|
360 | XYZ_ITEM( some_item, XYZ_ORDER_FIRST ); |
---|
361 | |
---|
362 | .. raw:: latex |
---|
363 | |
---|
364 | \clearpage |
---|
365 | |
---|
366 | .. _RTEMS_LINKER_RWSET_DECLARE: |
---|
367 | |
---|
368 | RTEMS_LINKER_RWSET_DECLARE - Declares a read-write linker set |
---|
369 | ------------------------------------------------------------- |
---|
370 | .. index:: RTEMS_LINKER_RWSET_DECLARE |
---|
371 | |
---|
372 | CALLING SEQUENCE: |
---|
373 | .. code-block:: c |
---|
374 | |
---|
375 | RTEMS_LINKER_RWSET_DECLARE( set, type ); |
---|
376 | |
---|
377 | DESCRIPTION: |
---|
378 | This macro generates declarations for the begin and end markers of a |
---|
379 | read-write linker set identified by ``set``. The ``set`` parameter itself |
---|
380 | must be a valid C designator on which no macro expansion is performed. It |
---|
381 | uniquely identifies the linker set. The ``type`` parameter defines the type |
---|
382 | of the linker set items. The type must be the same for all macro |
---|
383 | invocations of a particular linker set. |
---|
384 | |
---|
385 | .. raw:: latex |
---|
386 | |
---|
387 | \clearpage |
---|
388 | |
---|
389 | .. _RTEMS_LINKER_RWSET: |
---|
390 | |
---|
391 | RTEMS_LINKER_RWSET - Defines a read-write linker set |
---|
392 | ---------------------------------------------------- |
---|
393 | .. index:: RTEMS_LINKER_RWSET |
---|
394 | |
---|
395 | CALLING SEQUENCE: |
---|
396 | .. code-block:: c |
---|
397 | |
---|
398 | RTEMS_LINKER_RWSET( set, type ); |
---|
399 | |
---|
400 | DESCRIPTION: |
---|
401 | This macro generates definitions for the begin and end markers of a |
---|
402 | read-write linker set identified by ``set``. The ``set`` parameter itself |
---|
403 | must be a valid C designator on which no macro expansion is performed. It |
---|
404 | uniquely identifies the linker set. The ``type`` parameter defines the type |
---|
405 | of the linker set items. The type must be the same for all macro |
---|
406 | invocations of a particular linker set. |
---|
407 | |
---|
408 | .. raw:: latex |
---|
409 | |
---|
410 | \clearpage |
---|
411 | |
---|
412 | .. _RTEMS_LINKER_RWSET_ITEM_DECLARE: |
---|
413 | |
---|
414 | RTEMS_LINKER_RWSET_ITEM_DECLARE - Declares a read-write linker set item |
---|
415 | ----------------------------------------------------------------------- |
---|
416 | .. index:: RTEMS_LINKER_RWSET_ITEM_DECLARE |
---|
417 | |
---|
418 | CALLING SEQUENCE: |
---|
419 | .. code-block:: c |
---|
420 | |
---|
421 | RTEMS_LINKER_RWSET_ITEM_DECLARE( set, type, item ); |
---|
422 | |
---|
423 | DESCRIPTION: |
---|
424 | This macro generates a declaration of an item contained in the read-write |
---|
425 | linker set identified by ``set``. The ``set`` parameter itself must be a |
---|
426 | valid C designator on which no macro expansion is performed. It uniquely |
---|
427 | identifies the linker set. The ``type`` parameter defines the type of the |
---|
428 | linker set items. The type must be the same for all macro invocations of a |
---|
429 | particular linker set. The ``item`` parameter itself must be a valid C |
---|
430 | designator on which no macro expansion is performed. It uniquely |
---|
431 | identifies an item in the linker set. |
---|
432 | |
---|
433 | .. raw:: latex |
---|
434 | |
---|
435 | \clearpage |
---|
436 | |
---|
437 | .. _RTEMS_LINKER_RWSET_ITEM_REFERENCE: |
---|
438 | |
---|
439 | RTEMS_LINKER_RWSET_ITEM_REFERENCE - References a read-write linker set item |
---|
440 | --------------------------------------------------------------------------- |
---|
441 | .. index:: RTEMS_LINKER_RWSET_ITEM_REFERENCE |
---|
442 | |
---|
443 | CALLING SEQUENCE: |
---|
444 | .. code-block:: c |
---|
445 | |
---|
446 | RTEMS_LINKER_RWSET_ITEM_REFERENCE( set, type, item ); |
---|
447 | |
---|
448 | DESCRIPTION: |
---|
449 | This macro generates a reference to an item contained in the read-write |
---|
450 | linker set identified by ``set``. The ``set`` parameter itself must be a |
---|
451 | valid C designator on which no macro expansion is performed. It uniquely |
---|
452 | identifies the linker set. The ``type`` parameter defines the type of the |
---|
453 | linker set items. The type must be the same for all macro invocations of a |
---|
454 | particular linker set. The ``item`` parameter itself must be a valid C |
---|
455 | designator on which no macro expansion is performed. It uniquely |
---|
456 | identifies an item in the linker set. |
---|
457 | |
---|
458 | .. raw:: latex |
---|
459 | |
---|
460 | \clearpage |
---|
461 | |
---|
462 | .. _RTEMS_LINKER_RWSET_ITEM: |
---|
463 | |
---|
464 | RTEMS_LINKER_RWSET_ITEM - Defines a read-write linker set item |
---|
465 | -------------------------------------------------------------- |
---|
466 | .. index:: RTEMS_LINKER_RWSET_ITEM |
---|
467 | |
---|
468 | CALLING SEQUENCE: |
---|
469 | .. code-block:: c |
---|
470 | |
---|
471 | RTEMS_LINKER_RWSET_ITEM( set, type, item ); |
---|
472 | |
---|
473 | DESCRIPTION: |
---|
474 | This macro generates a definition of an item contained in the read-write |
---|
475 | linker set identified by ``set``. The ``set`` parameter itself must be a |
---|
476 | valid C designator on which no macro expansion is performed. It uniquely |
---|
477 | identifies the linker set. The ``type`` parameter defines the type of the |
---|
478 | linker set items. The type must be the same for all macro invocations of a |
---|
479 | particular linker set. The ``item`` parameter itself must be a valid C |
---|
480 | designator on which no macro expansion is performed. It uniquely |
---|
481 | identifies an item in the linker set. |
---|
482 | |
---|
483 | .. raw:: latex |
---|
484 | |
---|
485 | \clearpage |
---|
486 | |
---|
487 | .. _RTEMS_LINKER_RWSET_ITEM_ORDERED: |
---|
488 | |
---|
489 | RTEMS_LINKER_RWSET_ITEM_ORDERED - Defines an ordered read-write linker set item |
---|
490 | ------------------------------------------------------------------------------- |
---|
491 | .. index:: RTEMS_LINKER_RWSET_ITEM_ORDERED |
---|
492 | |
---|
493 | CALLING SEQUENCE: |
---|
494 | .. code-block:: c |
---|
495 | |
---|
496 | RTEMS_LINKER_RWSET_ITEM_ORDERED( set, type, item, order ); |
---|
497 | |
---|
498 | DESCRIPTION: |
---|
499 | This macro generates a definition of an ordered item contained in the |
---|
500 | read-write linker set identified by ``set``. The ``set`` parameter itself |
---|
501 | must be a valid C designator on which no macro expansion is performed. It |
---|
502 | uniquely identifies the linker set. The ``type`` parameter defines the type |
---|
503 | of the linker set items. The type must be the same for all macro |
---|
504 | invocations of a particular linker set. The ``item`` parameter itself must |
---|
505 | be a valid C designator on which no macro expansion is performed. It |
---|
506 | uniquely identifies an item in the linker set. The ``order`` parameter must |
---|
507 | be a valid linker input section name part on which macro expansion is |
---|
508 | performed. The items are lexicographically ordered according to the |
---|
509 | ``order`` parameter within a linker set. Ordered items are placed before |
---|
510 | unordered items in the linker set. |
---|
511 | |
---|
512 | NOTES: |
---|
513 | To be resilient to typos in the order parameter, it is recommended to use |
---|
514 | the following construct in macros defining items for a particular linker |
---|
515 | set (see enum in ``XYZ_ITEM()``). |
---|
516 | |
---|
517 | .. code-block:: c |
---|
518 | |
---|
519 | #include <rtems/linkersets.h> |
---|
520 | |
---|
521 | typedef struct { |
---|
522 | int foo; |
---|
523 | } xyz_item; |
---|
524 | |
---|
525 | /* The XYZ-order defines */ |
---|
526 | #define XYZ_ORDER_FIRST 0x00001000 |
---|
527 | #define XYZ_ORDER_AND_SO_ON 0x00002000 |
---|
528 | |
---|
529 | /* Defines an ordered XYZ-item */ |
---|
530 | #define XYZ_ITEM( item, order ) \ |
---|
531 | enum { xyz_##item = order - order }; \ |
---|
532 | RTEMS_LINKER_RWSET_ITEM_ORDERED( \ |
---|
533 | xyz, const xyz_item *, item, order \ |
---|
534 | ) = { &item } |
---|
535 | /* Example item */ |
---|
536 | static const xyz_item some_item = { 123 }; |
---|
537 | XYZ_ITEM( some_item, XYZ_ORDER_FIRST ); |
---|