linker: Add Z_LINK_ITERABLE_SUBALIGN

The macro Z_LINK_ITERABLE_SUBALIGN is used by linker scripts to
select the default subalignment based on whether it is 32/64-bit
architecture. 64-bit architectures set the default subalignment
to 8, while 32-bit architectures set it to 4.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
This commit is contained in:
Peter Mitsis 2024-04-10 11:32:30 -04:00 committed by Anas Nashif
parent d382c3d644
commit 89679cd975
8 changed files with 89 additions and 83 deletions

View file

@ -5,10 +5,10 @@
#if defined(CONFIG_NETWORKING)
#ifndef NETWORK_RAM_SECTIONS
#define NETWORK_RAM_SECTIONS \
ITERABLE_SECTION_RAM(net_if, 4) \
ITERABLE_SECTION_RAM(net_if_dev, 4) \
ITERABLE_SECTION_RAM(net_l2, 4) \
ITERABLE_SECTION_RAM(eth_bridge, 4)
ITERABLE_SECTION_RAM(net_if, Z_LINK_ITERABLE_SUBALIGN) \
ITERABLE_SECTION_RAM(net_if_dev, Z_LINK_ITERABLE_SUBALIGN) \
ITERABLE_SECTION_RAM(net_l2, Z_LINK_ITERABLE_SUBALIGN) \
ITERABLE_SECTION_RAM(eth_bridge, Z_LINK_ITERABLE_SUBALIGN)
#endif
#endif /* NETWORKING */
@ -44,7 +44,7 @@
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
#if CONFIG_PM_DEVICE
ITERABLE_SECTION_RAM(pm_device_slots, 4)
ITERABLE_SECTION_RAM(pm_device_slots, Z_LINK_ITERABLE_SUBALIGN)
#endif
#if defined(CONFIG_DEVICE_DEPS_DYNAMIC)
@ -54,9 +54,9 @@
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
#endif /* CONFIG_DEVICE_DEPS_DYNAMIC */
ITERABLE_SECTION_RAM_GC_ALLOWED(log_mpsc_pbuf, 4)
ITERABLE_SECTION_RAM(log_msg_ptr, 4)
ITERABLE_SECTION_RAM(log_dynamic, 4)
ITERABLE_SECTION_RAM_GC_ALLOWED(log_mpsc_pbuf, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_RAM(log_msg_ptr, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_RAM(log_dynamic, Z_LINK_ITERABLE_SUBALIGN)
#ifdef CONFIG_USERSPACE
/* All kernel objects within are assumed to be either completely
@ -69,34 +69,34 @@
_static_kernel_objects_begin = .;
#endif /* CONFIG_USERSPACE */
ITERABLE_SECTION_RAM_GC_ALLOWED(k_timer, 4)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_mem_slab, 4)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_heap, 4)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_mutex, 4)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_stack, 4)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_msgq, 4)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_mbox, 4)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_pipe, 4)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_sem, 4)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_event, 4)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_queue, 4)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_fifo, 4)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_lifo, 4)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_condvar, 4)
ITERABLE_SECTION_RAM_GC_ALLOWED(sys_mem_blocks_ptr, 4)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_timer, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_mem_slab, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_heap, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_mutex, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_stack, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_msgq, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_mbox, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_pipe, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_sem, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_event, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_queue, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_fifo, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_lifo, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_RAM_GC_ALLOWED(k_condvar, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_RAM_GC_ALLOWED(sys_mem_blocks_ptr, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_RAM(net_buf_pool, 4)
ITERABLE_SECTION_RAM(net_buf_pool, Z_LINK_ITERABLE_SUBALIGN)
#if defined(CONFIG_NETWORKING)
NETWORK_RAM_SECTIONS
#endif /* NETWORKING */
#if defined(CONFIG_PCIE)
ITERABLE_SECTION_RAM(pcie_dev, 4)
ITERABLE_SECTION_RAM(pcie_dev, Z_LINK_ITERABLE_SUBALIGN)
#endif /* PCIE */
#if defined(CONFIG_UART_MUX)
ITERABLE_SECTION_RAM(uart_mux, 4)
ITERABLE_SECTION_RAM(uart_mux, Z_LINK_ITERABLE_SUBALIGN)
#endif
#if defined(CONFIG_USB_DEVICE_STACK)
@ -108,7 +108,7 @@
__usb_descriptor_end = .;
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
ITERABLE_SECTION_RAM(usb_cfg_data, 4)
ITERABLE_SECTION_RAM(usb_cfg_data, Z_LINK_ITERABLE_SUBALIGN)
#endif /* CONFIG_USB_DEVICE_STACK */
#if defined(CONFIG_USB_DEVICE_BOS)
@ -122,14 +122,14 @@
#endif /* CONFIG_USB_DEVICE_BOS */
#if defined(CONFIG_RTIO)
ITERABLE_SECTION_RAM(rtio, 4)
ITERABLE_SECTION_RAM(rtio_iodev, 4)
ITERABLE_SECTION_RAM(rtio_sqe_pool, 4)
ITERABLE_SECTION_RAM(rtio_cqe_pool, 4)
ITERABLE_SECTION_RAM(rtio, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_RAM(rtio_iodev, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_RAM(rtio_sqe_pool, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_RAM(rtio_cqe_pool, Z_LINK_ITERABLE_SUBALIGN)
#endif /* CONFIG_RTIO */
#if defined(CONFIG_SENSING)
ITERABLE_SECTION_RAM(sensing_sensor, 4)
ITERABLE_SECTION_RAM(sensing_sensor, Z_LINK_ITERABLE_SUBALIGN)
#endif /* CONFIG_SENSING */
#if defined(CONFIG_ZBUS)
@ -137,11 +137,11 @@
#endif /* CONFIG_ZBUS */
#if defined(CONFIG_DEVICE_MUTABLE)
ITERABLE_SECTION_RAM(device_mutable, 4)
ITERABLE_SECTION_RAM(device_mutable, Z_LINK_ITERABLE_SUBALIGN)
#endif
#if defined(CONFIG_BT_ZEPHYR_NUS)
ITERABLE_SECTION_RAM(bt_nus_inst, 4)
ITERABLE_SECTION_RAM(bt_nus_inst, Z_LINK_ITERABLE_SUBALIGN)
#endif
#ifdef CONFIG_USERSPACE

View file

@ -2,41 +2,41 @@
#include <zephyr/linker/iterable_sections.h>
ITERABLE_SECTION_ROM(bt_l2cap_fixed_chan, 4)
ITERABLE_SECTION_ROM(bt_l2cap_fixed_chan, Z_LINK_ITERABLE_SUBALIGN)
#if defined(CONFIG_BT_CLASSIC)
ITERABLE_SECTION_ROM(bt_l2cap_br_fixed_chan, 4)
ITERABLE_SECTION_ROM(bt_l2cap_br_fixed_chan, Z_LINK_ITERABLE_SUBALIGN)
#endif
#if defined(CONFIG_BT_CONN)
ITERABLE_SECTION_ROM(bt_conn_cb, 4)
ITERABLE_SECTION_ROM(bt_conn_cb, Z_LINK_ITERABLE_SUBALIGN)
#endif
ITERABLE_SECTION_ROM(bt_gatt_service_static, 4)
ITERABLE_SECTION_ROM(bt_gatt_service_static, Z_LINK_ITERABLE_SUBALIGN)
#if defined(CONFIG_BT_MESH)
ITERABLE_SECTION_ROM(bt_mesh_subnet_cb, 4)
ITERABLE_SECTION_ROM(bt_mesh_app_key_cb, 4)
ITERABLE_SECTION_ROM(bt_mesh_subnet_cb, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_ROM(bt_mesh_app_key_cb, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_ROM(bt_mesh_hb_cb, 4)
ITERABLE_SECTION_ROM(bt_mesh_hb_cb, Z_LINK_ITERABLE_SUBALIGN)
#if defined(CONFIG_BT_TESTING)
ITERABLE_SECTION_ROM(bt_mesh_beacon_cb, 4)
ITERABLE_SECTION_ROM(bt_mesh_beacon_cb, Z_LINK_ITERABLE_SUBALIGN)
#endif
#endif
#if defined(CONFIG_BT_MESH_FRIEND)
ITERABLE_SECTION_ROM(bt_mesh_friend_cb, 4)
ITERABLE_SECTION_ROM(bt_mesh_friend_cb, Z_LINK_ITERABLE_SUBALIGN)
#endif
#if defined(CONFIG_BT_MESH_LOW_POWER)
ITERABLE_SECTION_ROM(bt_mesh_lpn_cb, 4)
ITERABLE_SECTION_ROM(bt_mesh_lpn_cb, Z_LINK_ITERABLE_SUBALIGN)
#endif
#if defined(CONFIG_BT_IAS)
ITERABLE_SECTION_ROM(bt_ias_cb, 4)
ITERABLE_SECTION_ROM(bt_ias_cb, Z_LINK_ITERABLE_SUBALIGN)
#endif
#if defined(CONFIG_BT_MESH_GATT_PROXY)
ITERABLE_SECTION_ROM(bt_mesh_proxy_cb, 4)
ITERABLE_SECTION_ROM(bt_mesh_proxy_cb, Z_LINK_ITERABLE_SUBALIGN)
#endif

View file

@ -2,7 +2,7 @@
#include <zephyr/linker/iterable_sections.h>
ITERABLE_SECTION_ROM(tracing_backend, 4)
ITERABLE_SECTION_ROM(tracing_backend, Z_LINK_ITERABLE_SUBALIGN)
SECTION_DATA_PROLOGUE(zephyr_dbg_info,,)
{

View file

@ -23,7 +23,7 @@
__deferred_init_list_end = .;
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
ITERABLE_SECTION_ROM_NUMERIC(device, 4)
ITERABLE_SECTION_ROM_NUMERIC(device, Z_LINK_ITERABLE_SUBALIGN)
#if defined(CONFIG_GEN_SW_ISR_TABLE) && defined(CONFIG_SHARED_INTERRUPTS)
/* since z_shared_isr() is not referenced anywhere when
@ -78,7 +78,7 @@
/* Build-time assignment of permissions to kernel objects to
* threads declared with K_THREAD_DEFINE()
*/
ITERABLE_SECTION_ROM(k_object_assignment, 4)
ITERABLE_SECTION_ROM(k_object_assignment, Z_LINK_ITERABLE_SUBALIGN)
#endif
SECTION_DATA_PROLOGUE(app_shmem_regions,,)
@ -88,12 +88,12 @@
__app_shmem_regions_end = .;
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
ITERABLE_SECTION_ROM(k_p4wq_initparam, 4)
ITERABLE_SECTION_ROM(k_p4wq_initparam, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_ROM(_static_thread_data, 4)
ITERABLE_SECTION_ROM(_static_thread_data, Z_LINK_ITERABLE_SUBALIGN)
#if defined(CONFIG_PCIE)
ITERABLE_SECTION_ROM(irq_alloc, 4)
ITERABLE_SECTION_ROM(irq_alloc, Z_LINK_ITERABLE_SUBALIGN)
#endif /* CONFIG_PCIE */
#if !defined(CONFIG_DEVICE_DEPS_DYNAMIC)

View file

@ -3,16 +3,16 @@
#include <zephyr/linker/iterable_sections.h>
#if defined(CONFIG_LOG_FMT_SECTION_STRIP) && defined(DEVNULL_REGION)
SECTION_PROLOGUE(log_strings,(COPY),SUBALIGN(4))
SECTION_PROLOGUE(log_strings,(COPY),Z_LINK_ITERABLE_SUBALIGN)
{
Z_LINK_ITERABLE(log_strings);
} GROUP_ROM_LINK_IN(DEVNULL_REGION, DEVNULL_REGION)
#else
ITERABLE_SECTION_ROM(log_strings, 4)
ITERABLE_SECTION_ROM(log_strings, Z_LINK_ITERABLE_SUBALIGN)
#endif
ITERABLE_SECTION_ROM(log_const, 4)
ITERABLE_SECTION_ROM(log_const, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_ROM(log_backend, 4)
ITERABLE_SECTION_ROM(log_backend, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_ROM(log_link, 4)
ITERABLE_SECTION_ROM(log_link, Z_LINK_ITERABLE_SUBALIGN)

View file

@ -3,45 +3,45 @@
#include <zephyr/linker/iterable_sections.h>
#if defined(CONFIG_EC_HOST_CMD)
ITERABLE_SECTION_ROM(ec_host_cmd_handler, 4)
ITERABLE_SECTION_ROM(ec_host_cmd_handler, Z_LINK_ITERABLE_SUBALIGN)
#endif
#if defined(CONFIG_SETTINGS)
ITERABLE_SECTION_ROM(settings_handler_static, 4)
ITERABLE_SECTION_ROM(settings_handler_static, Z_LINK_ITERABLE_SUBALIGN)
#endif
#if defined(CONFIG_SENSING)
ITERABLE_SECTION_ROM(sensing_sensor_info, 4)
ITERABLE_SECTION_ROM(sensing_sensor_info, Z_LINK_ITERABLE_SUBALIGN)
#endif
#if defined(CONFIG_SENSOR_INFO)
ITERABLE_SECTION_ROM(sensor_info, 4)
ITERABLE_SECTION_ROM(sensor_info, Z_LINK_ITERABLE_SUBALIGN)
#endif
#if defined(CONFIG_SENSOR_ASYNC_API)
ITERABLE_SECTION_ROM(sensor_decoder_api, 4)
ITERABLE_SECTION_ROM(sensor_decoder_api, Z_LINK_ITERABLE_SUBALIGN)
#endif
#if defined(CONFIG_MCUMGR)
ITERABLE_SECTION_ROM(mcumgr_handler, 4)
ITERABLE_SECTION_ROM(mcumgr_handler, Z_LINK_ITERABLE_SUBALIGN)
#endif
#if defined(CONFIG_INPUT)
ITERABLE_SECTION_ROM(input_callback, 4)
ITERABLE_SECTION_ROM(input_callback, Z_LINK_ITERABLE_SUBALIGN)
#endif
#if defined(CONFIG_EMUL)
ITERABLE_SECTION_ROM(emul, 4)
ITERABLE_SECTION_ROM(emul, Z_LINK_ITERABLE_SUBALIGN)
#endif /* CONFIG_EMUL */
#if defined(CONFIG_ZBUS)
ITERABLE_SECTION_ROM(zbus_channel, 4)
ITERABLE_SECTION_ROM(zbus_observer, 4)
ITERABLE_SECTION_ROM(zbus_channel_observation, 4)
ITERABLE_SECTION_ROM(zbus_channel, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_ROM(zbus_observer, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_ROM(zbus_channel_observation, Z_LINK_ITERABLE_SUBALIGN)
#endif /* CONFIG_ZBUS */
#ifdef CONFIG_LLEXT
ITERABLE_SECTION_ROM(llext_const_symbol, 4)
ITERABLE_SECTION_ROM(llext_const_symbol, Z_LINK_ITERABLE_SUBALIGN)
#endif /* CONFIG_LLEXT */
SECTION_DATA_PROLOGUE(symbol_to_keep,,)
@ -51,20 +51,20 @@
__symbol_to_keep_end = .;
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
ITERABLE_SECTION_ROM(shell, 4)
ITERABLE_SECTION_ROM(shell, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_ROM(shell_root_cmds, 4)
ITERABLE_SECTION_ROM(shell_root_cmds, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_ROM(shell_subcmds, 4)
ITERABLE_SECTION_ROM(shell_subcmds, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_ROM(shell_dynamic_subcmds, 4)
ITERABLE_SECTION_ROM(shell_dynamic_subcmds, Z_LINK_ITERABLE_SUBALIGN)
ITERABLE_SECTION_ROM(cfb_font, 4)
ITERABLE_SECTION_ROM(cfb_font, Z_LINK_ITERABLE_SUBALIGN)
#if defined(CONFIG_GNSS)
ITERABLE_SECTION_ROM(gnss_data_callback, 4)
ITERABLE_SECTION_ROM(gnss_data_callback, Z_LINK_ITERABLE_SUBALIGN)
#endif
#if defined(CONFIG_GNSS_SATELLITES)
ITERABLE_SECTION_ROM(gnss_satellites_callback, 4)
ITERABLE_SECTION_ROM(gnss_satellites_callback, Z_LINK_ITERABLE_SUBALIGN)
#endif

View file

@ -3,29 +3,29 @@
#include <zephyr/linker/iterable_sections.h>
#if defined(CONFIG_NET_SOCKETS)
ITERABLE_SECTION_ROM(net_socket_register, 4)
ITERABLE_SECTION_ROM(net_socket_register, Z_LINK_ITERABLE_SUBALIGN)
#endif
#if defined(CONFIG_NET_L2_PPP)
ITERABLE_SECTION_ROM(ppp_protocol_handler, 4)
ITERABLE_SECTION_ROM(ppp_protocol_handler, Z_LINK_ITERABLE_SUBALIGN)
#endif
#if defined(CONFIG_DNS_SD)
ITERABLE_SECTION_ROM(dns_sd_rec, 4)
ITERABLE_SECTION_ROM(dns_sd_rec, Z_LINK_ITERABLE_SUBALIGN)
#endif
#if defined(CONFIG_HTTP_SERVER)
ITERABLE_SECTION_ROM(http_service_desc, 4)
ITERABLE_SECTION_ROM(http_service_desc, Z_LINK_ITERABLE_SUBALIGN)
#endif
#if defined(CONFIG_COAP_SERVER)
ITERABLE_SECTION_ROM(coap_service, 4)
ITERABLE_SECTION_ROM(coap_service, Z_LINK_ITERABLE_SUBALIGN)
#endif
#if defined(CONFIG_NET_MGMT_EVENT)
ITERABLE_SECTION_ROM(net_mgmt_event_static_handler, 4)
ITERABLE_SECTION_ROM(net_mgmt_event_static_handler, Z_LINK_ITERABLE_SUBALIGN)
#endif
#if defined(CONFIG_NET_SOCKETS_SERVICE)
ITERABLE_SECTION_ROM(net_socket_service_desc, 4)
ITERABLE_SECTION_ROM(net_socket_service_desc, Z_LINK_ITERABLE_SUBALIGN)
#endif

View file

@ -32,6 +32,12 @@
*(SORT_BY_NAME(._##struct_type.static.*)); \
_CONCAT(_##struct_type, _list_end) = .
#ifdef CONFIG_64BIT
#define Z_LINK_ITERABLE_SUBALIGN 8
#else
#define Z_LINK_ITERABLE_SUBALIGN 4
#endif
/**
* @brief Define a read-only iterable section output.
*