1/* SPDX-License-Identifier: Apache-2.0 */ 2 3#include <zephyr/linker/iterable_sections.h> 4 5 SECTION_PROLOGUE(initlevel,,) 6 { 7 /* 8 * link in initialization objects for all objects that are 9 * automatically initialized by the kernel; the objects are 10 * sorted in the order they will be initialized (i.e. ordered 11 * by level, sorted by priority within a level) 12 */ 13 __init_start = .; 14 CREATE_OBJ_LEVEL(init, EARLY) 15 CREATE_OBJ_LEVEL(init, PRE_KERNEL_1) 16 CREATE_OBJ_LEVEL(init, PRE_KERNEL_2) 17 CREATE_OBJ_LEVEL(init, POST_KERNEL) 18 CREATE_OBJ_LEVEL(init, APPLICATION) 19 CREATE_OBJ_LEVEL(init, SMP) 20 __init_end = .; 21 } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) 22 23 ITERABLE_SECTION_ROM_NUMERIC(device, 4) 24 25#if defined(CONFIG_GEN_SW_ISR_TABLE) && defined(CONFIG_SHARED_INTERRUPTS) 26 /* since z_shared_isr() is not referenced anywhere when 27 * zephyr_pre0.elf is built, the linker will end up dropping it. 28 * Later on, during the second linking stage (when zephyr.elf is 29 * built), the symbol will be added to the text section since it's 30 * now being referenced (thanks to isr_tables.c). This is very 31 * problematic because adding the z_shared_isr symbol between 32 * the linking stages will end up shifting the addresses of the 33 * functions, which, in turn, will end up messing the ISR table 34 * (as the entries from _sw_isr_table will end up pointing to 35 * old addresses of the registered ISRs). To prevent this from 36 * happening, instruct the linker to avoid dropping z_shared_isr 37 * if it's not being referenced anywhere. 38 */ 39 SECTION_PROLOGUE(.text.z_shared_isr,,) 40 { 41 KEEP(*(.text.z_shared_isr)) 42 } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) 43#endif 44 45#if defined(CONFIG_GEN_SW_ISR_TABLE) && !defined(CONFIG_DYNAMIC_INTERRUPTS) 46 SECTION_PROLOGUE(sw_isr_table,,) 47 { 48 /* 49 * Some arch requires an entry to be aligned to arch 50 * specific boundary for using double word load 51 * instruction. See include/sw_isr_table.h. 52 */ 53 . = ALIGN(CONFIG_ARCH_SW_ISR_TABLE_ALIGN); 54 *(_SW_ISR_TABLE_SECTION_SYMS) 55 } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) 56 57#if defined(CONFIG_SHARED_INTERRUPTS) 58 SECTION_PROLOGUE(shared_sw_isr_table,,) 59 { 60 /* TODO: does this section require alignment? */ 61 KEEP(*(_SHARED_SW_ISR_TABLE_SECTION_SYMS)) 62 } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) 63#endif 64 65#endif 66 67 /* verify we don't have rogue .z_init_<something> initlevel sections */ 68 SECTION_PROLOGUE(initlevel_error,,) 69 { 70 KEEP(*(SORT(.z_init_[_A-Z0-9]*))) 71 } 72 ASSERT(SIZEOF(initlevel_error) == 0, "Undefined initialization levels used.") 73 74#ifdef CONFIG_USERSPACE 75 /* Build-time assignment of permissions to kernel objects to 76 * threads declared with K_THREAD_DEFINE() 77 */ 78 ITERABLE_SECTION_ROM(k_object_assignment, 4) 79#endif 80 81 SECTION_DATA_PROLOGUE(app_shmem_regions,,) 82 { 83 __app_shmem_regions_start = .; 84 KEEP(*(SORT(.app_regions.*))); 85 __app_shmem_regions_end = .; 86 } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) 87 88 ITERABLE_SECTION_ROM(k_p4wq_initparam, 4) 89 90 ITERABLE_SECTION_ROM(_static_thread_data, 4) 91 92#if defined(CONFIG_PCIE) 93 ITERABLE_SECTION_ROM(irq_alloc, 4) 94#endif /* CONFIG_PCIE */ 95 96#if !defined(CONFIG_DEVICE_DEPS_DYNAMIC) 97 SECTION_DATA_PROLOGUE(device_deps,,) 98 { 99#include <zephyr/linker/device-deps.ld> 100 } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) 101#endif /* !CONFIG_DEVICE_DEPS_DYNAMIC */ 102