linker: add macros so iterable sections can be garbage collected
The iterable section macros Z_ITERABLE_SECTION_ROM()/_RAM() uses Z_LINK_ITERABLE() which does KEEP() on all symbols. This results in all symbols under those sections being kept in final image even though these symbols are not referred directly from the code. This adds the new set of macros which does not force KEEP() on the symbols, and allows symbols to be garbage collected. The existing macros are kept as-is so as not to change their behaviors. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
parent
0fe62c6392
commit
04d706b450
1 changed files with 42 additions and 0 deletions
|
@ -42,11 +42,20 @@
|
|||
KEEP(*(SORT_BY_NAME(._##struct_type.static.*))); \
|
||||
_CONCAT(_##struct_type, _list_end) = .
|
||||
|
||||
#define Z_LINK_ITERABLE_GC_ALLOWED(struct_type) \
|
||||
_CONCAT(_##struct_type, _list_start) = .; \
|
||||
*(SORT_BY_NAME(._##struct_type.static.*)); \
|
||||
_CONCAT(_##struct_type, _list_end) = .
|
||||
|
||||
/* Define an output section which will set up an iterable area
|
||||
* of equally-sized data structures. For use with Z_STRUCT_SECTION_ITERABLE.
|
||||
* Input sections will be sorted by name, per ld's SORT_BY_NAME.
|
||||
*
|
||||
* This macro should be used for read-only data.
|
||||
*
|
||||
* Note that this keeps the symbols in the image even though
|
||||
* they are not being directly referenced. Use this when symbols
|
||||
* are indirectly referenced by iterating through the section.
|
||||
*/
|
||||
#define Z_ITERABLE_SECTION_ROM(struct_type, subalign) \
|
||||
SECTION_PROLOGUE(struct_type##_area,,SUBALIGN(subalign)) \
|
||||
|
@ -54,11 +63,29 @@
|
|||
Z_LINK_ITERABLE(struct_type); \
|
||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||
|
||||
/* Define an output section which will set up an iterable area
|
||||
* of equally-sized data structures. For use with Z_STRUCT_SECTION_ITERABLE.
|
||||
* Input sections will be sorted by name, per ld's SORT_BY_NAME.
|
||||
*
|
||||
* This macro should be used for read-only data.
|
||||
*
|
||||
* Note that the symbols within the section can be garbage collected.
|
||||
*/
|
||||
#define Z_ITERABLE_SECTION_ROM_GC_ALLOWED(struct_type, subalign) \
|
||||
SECTION_PROLOGUE(struct_type##_area,,SUBALIGN(subalign)) \
|
||||
{ \
|
||||
Z_LINK_ITERABLE_GC_ALLOWED(struct_type); \
|
||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||
|
||||
/* Define an output section which will set up an iterable area
|
||||
* of equally-sized data structures. For use with Z_STRUCT_SECTION_ITERABLE.
|
||||
* Input sections will be sorted by name, per ld's SORT_BY_NAME.
|
||||
*
|
||||
* This macro should be used for read-write data that is modified at runtime.
|
||||
*
|
||||
* Note that this keeps the symbols in the image even though
|
||||
* they are not being directly referenced. Use this when symbols
|
||||
* are indirectly referenced by iterating through the section.
|
||||
*/
|
||||
#define Z_ITERABLE_SECTION_RAM(struct_type, subalign) \
|
||||
SECTION_DATA_PROLOGUE(struct_type##_area,,SUBALIGN(subalign)) \
|
||||
|
@ -66,6 +93,21 @@
|
|||
Z_LINK_ITERABLE(struct_type); \
|
||||
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
|
||||
/* Define an output section which will set up an iterable area
|
||||
* of equally-sized data structures. For use with Z_STRUCT_SECTION_ITERABLE.
|
||||
* Input sections will be sorted by name, per ld's SORT_BY_NAME.
|
||||
*
|
||||
* This macro should be used for read-write data that is modified at runtime.
|
||||
*
|
||||
* Note that the symbols within the section can be garbage collected.
|
||||
*/
|
||||
#define Z_ITERABLE_SECTION_RAM_GC_ALLOWED(struct_type, subalign) \
|
||||
SECTION_DATA_PROLOGUE(struct_type##_area,,SUBALIGN(subalign)) \
|
||||
{ \
|
||||
Z_LINK_ITERABLE_GC_ALLOWED(struct_type); \
|
||||
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
/*
|
||||
* generate a symbol to mark the start of the objects array for
|
||||
* the specified object and level, then link all of those objects
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue