linker: add iterable section macros
For iterable areas defined with Z_STRUCT_SECTION_ITERABLE(), the corresponding output section in the linker script is just boilerplate. Add macros to make these definitions simpler. Unfortunately, we have a fair number of iterable sections not defined with Z_STRUCT_SECTION_ITERABLE(), this patch does not address this. The output sections are all named <struct name>_area, update sanitylib.py with this. sys_sem with no userspace, and k_lifo/k_fifo are special cases where different data types that are all equivalent need to be put in the same iterable area. Add Z_STRUCT_SECTION_ITERABLE_ALTERNATE() for this special case. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
973487fdad
commit
45979dafb4
7 changed files with 84 additions and 154 deletions
|
@ -68,12 +68,7 @@
|
|||
__log_dynamic_end = .;
|
||||
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
SECTION_DATA_PROLOGUE(_static_thread_area,,SUBALIGN(4))
|
||||
{
|
||||
__static_thread_data_list_start = .;
|
||||
KEEP(*(SORT_BY_NAME(".__static_thread_data.static.*")))
|
||||
__static_thread_data_list_end = .;
|
||||
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
Z_ITERABLE_SECTION_RAM(_static_thread_data, 4)
|
||||
|
||||
#ifdef CONFIG_USERSPACE
|
||||
/* All kernel objects within are assumed to be either completely
|
||||
|
@ -86,85 +81,17 @@
|
|||
_static_kernel_objects_begin = .;
|
||||
#endif /* CONFIG_USERSPACE */
|
||||
|
||||
SECTION_DATA_PROLOGUE(_k_timer_area,,SUBALIGN(4))
|
||||
{
|
||||
_k_timer_list_start = .;
|
||||
KEEP(*("._k_timer.static.*"))
|
||||
_k_timer_list_end = .;
|
||||
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
SECTION_DATA_PROLOGUE(_k_mem_slab_area,,SUBALIGN(4))
|
||||
{
|
||||
_k_mem_slab_list_start = .;
|
||||
KEEP(*("._k_mem_slab.static.*"))
|
||||
_k_mem_slab_list_end = .;
|
||||
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
SECTION_DATA_PROLOGUE(_k_mem_pool_area,,SUBALIGN(4))
|
||||
{
|
||||
_k_mem_pool_list_start = .;
|
||||
KEEP(*("._k_mem_pool.static.*"))
|
||||
_k_mem_pool_list_end = .;
|
||||
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
SECTION_DATA_PROLOGUE(_k_heap_area,,SUBALIGN(4))
|
||||
{
|
||||
_k_heap_list_start = .;
|
||||
KEEP(*("._k_heap.static.*"))
|
||||
_k_heap_list_end = .;
|
||||
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
SECTION_DATA_PROLOGUE(_k_sem_area,,SUBALIGN(4))
|
||||
{
|
||||
_k_sem_list_start = .;
|
||||
KEEP(*("._k_sem.static.*"))
|
||||
KEEP(*("._sys_sem.static.*"))
|
||||
_k_sem_list_end = .;
|
||||
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
SECTION_DATA_PROLOGUE(_k_mutex_area,,SUBALIGN(4))
|
||||
{
|
||||
_k_mutex_list_start = .;
|
||||
KEEP(*("._k_mutex.static.*"))
|
||||
_k_mutex_list_end = .;
|
||||
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
SECTION_DATA_PROLOGUE(_k_queue_area,,SUBALIGN(4))
|
||||
{
|
||||
_k_queue_list_start = .;
|
||||
KEEP(*("._k_queue.static.*"))
|
||||
KEEP(*("._k_fifo.static.*"))
|
||||
KEEP(*("._k_lifo.static.*"))
|
||||
_k_queue_list_end = .;
|
||||
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
SECTION_DATA_PROLOGUE(_k_stack_area,,SUBALIGN(4))
|
||||
{
|
||||
_k_stack_list_start = .;
|
||||
KEEP(*("._k_stack.static.*"))
|
||||
_k_stack_list_end = .;
|
||||
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
SECTION_DATA_PROLOGUE(_k_msgq_area,,SUBALIGN(4))
|
||||
{
|
||||
_k_msgq_list_start = .;
|
||||
KEEP(*("._k_msgq.static.*"))
|
||||
_k_msgq_list_end = .;
|
||||
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
SECTION_DATA_PROLOGUE(_k_mbox_area,,SUBALIGN(4))
|
||||
{
|
||||
_k_mbox_list_start = .;
|
||||
KEEP(*("._k_mbox.static.*"))
|
||||
_k_mbox_list_end = .;
|
||||
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
|
||||
SECTION_DATA_PROLOGUE(_k_pipe_area,,SUBALIGN(4))
|
||||
{
|
||||
_k_pipe_list_start = .;
|
||||
KEEP(*("._k_pipe.static.*"))
|
||||
_k_pipe_list_end = .;
|
||||
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
|
||||
Z_ITERABLE_SECTION_RAM(k_timer, 4)
|
||||
Z_ITERABLE_SECTION_RAM(k_mem_slab, 4)
|
||||
Z_ITERABLE_SECTION_RAM(k_mem_pool, 4)
|
||||
Z_ITERABLE_SECTION_RAM(k_heap, 4)
|
||||
Z_ITERABLE_SECTION_RAM(k_mutex, 4)
|
||||
Z_ITERABLE_SECTION_RAM(k_stack, 4)
|
||||
Z_ITERABLE_SECTION_RAM(k_msgq, 4)
|
||||
Z_ITERABLE_SECTION_RAM(k_mbox, 4)
|
||||
Z_ITERABLE_SECTION_RAM(k_pipe, 4)
|
||||
Z_ITERABLE_SECTION_RAM(k_sem, 4)
|
||||
Z_ITERABLE_SECTION_RAM(k_queue, 4)
|
||||
|
||||
SECTION_DATA_PROLOGUE(_net_buf_pool_area,,SUBALIGN(4))
|
||||
{
|
||||
|
|
|
@ -76,12 +76,7 @@
|
|||
/* Build-time assignment of permissions to kernel objects to
|
||||
* threads declared with K_THREAD_DEFINE()
|
||||
*/
|
||||
SECTION_PROLOGUE(object_access,,)
|
||||
{
|
||||
_z_object_assignment_list_start = .;
|
||||
KEEP(*("._z_object_assignment.*"))
|
||||
_z_object_assignment_list_end = .;
|
||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||
Z_ITERABLE_SECTION_ROM(z_object_assignment, 4)
|
||||
#endif
|
||||
|
||||
SECTION_PROLOGUE(app_shmem_regions,,)
|
||||
|
@ -100,12 +95,7 @@
|
|||
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||
|
||||
#if defined(CONFIG_NET_SOCKETS)
|
||||
SECTION_PROLOGUE(net_socket_register,,)
|
||||
{
|
||||
_net_socket_register_list_start = .;
|
||||
KEEP(*(SORT_BY_NAME("._net_socket_register.*")))
|
||||
_net_socket_register_list_end = .;
|
||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||
Z_ITERABLE_SECTION_ROM(net_socket_register, 4)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NET_L2_PPP)
|
||||
|
@ -118,36 +108,16 @@
|
|||
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||
#endif
|
||||
|
||||
SECTION_DATA_PROLOGUE(_bt_channels_area,,SUBALIGN(4))
|
||||
{
|
||||
_bt_l2cap_fixed_chan_list_start = .;
|
||||
KEEP(*(SORT_BY_NAME("._bt_l2cap_fixed_chan.static.*")))
|
||||
_bt_l2cap_fixed_chan_list_end = .;
|
||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||
Z_ITERABLE_SECTION_ROM(bt_l2cap_fixed_chan, 4)
|
||||
|
||||
#if defined(CONFIG_BT_BREDR)
|
||||
SECTION_DATA_PROLOGUE(_bt_br_channels_area,,SUBALIGN(4))
|
||||
{
|
||||
_bt_l2cap_br_fixed_chan_list_start = .;
|
||||
KEEP(*(SORT_BY_NAME("._bt_l2cap_br_fixed_chan.static.*")))
|
||||
_bt_l2cap_br_fixed_chan_list_end = .;
|
||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||
Z_ITERABLE_SECTION_ROM(bt_l2cap_br_fixed_chan, 4)
|
||||
#endif
|
||||
|
||||
SECTION_DATA_PROLOGUE(_bt_services_area,,SUBALIGN(4))
|
||||
{
|
||||
_bt_gatt_service_static_list_start = .;
|
||||
KEEP(*(SORT_BY_NAME("._bt_gatt_service_static.static.*")))
|
||||
_bt_gatt_service_static_list_end = .;
|
||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||
Z_ITERABLE_SECTION_ROM(bt_gatt_service_static, 4)
|
||||
|
||||
#if defined(CONFIG_SETTINGS)
|
||||
SECTION_DATA_PROLOGUE(_settings_handlers_area,,SUBALIGN(4))
|
||||
{
|
||||
_settings_handler_static_list_start = .;
|
||||
KEEP(*(SORT_BY_NAME("._settings_handler_static.static.*")))
|
||||
_settings_handler_static_list_end = .;
|
||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||
Z_ITERABLE_SECTION_ROM(settings_handler_static, 4)
|
||||
#endif
|
||||
|
||||
SECTION_DATA_PROLOGUE(log_const_sections,,)
|
||||
|
@ -164,12 +134,7 @@
|
|||
__log_backends_end = .;
|
||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||
|
||||
SECTION_DATA_PROLOGUE(shell_sections,,)
|
||||
{
|
||||
_shell_list_start = .;
|
||||
KEEP(*(SORT(._shell.static.*)));
|
||||
_shell_list_end = .;
|
||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||
Z_ITERABLE_SECTION_ROM(shell, 4)
|
||||
|
||||
SECTION_DATA_PROLOGUE(shell_root_cmds_sections,,)
|
||||
{
|
||||
|
@ -185,9 +150,4 @@
|
|||
__font_entry_end = .;
|
||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||
|
||||
SECTION_DATA_PROLOGUE(tracing_backends_sections,,)
|
||||
{
|
||||
_tracing_backend_list_start = .;
|
||||
KEEP(*("._tracing_backend.*"));
|
||||
_tracing_backend_list_end = .;
|
||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||
Z_ITERABLE_SECTION_ROM(tracing_backend, 4)
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#define ZEPHYR_INCLUDE_LINKER_LINKER_DEFS_H_
|
||||
|
||||
#include <toolchain.h>
|
||||
#include <toolchain/common.h>
|
||||
#include <linker/sections.h>
|
||||
#include <sys/util.h>
|
||||
#include <offsets.h>
|
||||
|
@ -36,6 +37,35 @@
|
|||
#endif
|
||||
|
||||
#ifdef _LINKER
|
||||
#define Z_LINK_ITERABLE(struct_type) \
|
||||
_CONCAT(_##struct_type, _list_start) = .; \
|
||||
KEEP(*(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.
|
||||
*/
|
||||
#define Z_ITERABLE_SECTION_ROM(struct_type, subalign) \
|
||||
SECTION_PROLOGUE(struct_type##_area,,SUBALIGN(subalign)) \
|
||||
{ \
|
||||
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-write data that is modified at runtime.
|
||||
*/
|
||||
#define Z_ITERABLE_SECTION_RAM(struct_type, subalign) \
|
||||
SECTION_DATA_PROLOGUE(struct_type##_area,,SUBALIGN(subalign)) \
|
||||
{ \
|
||||
Z_LINK_ITERABLE(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