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