1# SPDX-License-Identifier: Apache-2.0 2 3zephyr_library() 4 5zephyr_library_include_directories(include) 6 7# Library may be empty due to kconfigs 8zephyr_library_property(ALLOW_EMPTY TRUE) 9 10if(CONFIG_GEN_ISR_TABLES) 11 zephyr_library_sources( 12 sw_isr_common.c 13 ) 14 zephyr_library_sources_ifdef( 15 CONFIG_DYNAMIC_INTERRUPTS 16 dynamic_isr.c 17 ) 18endif() 19 20zephyr_library_sources_ifdef( 21 CONFIG_ISR_TABLE_SHELL 22 isr_tables_shell.c 23) 24 25zephyr_library_sources_ifdef( 26 CONFIG_MULTI_LEVEL_INTERRUPTS 27 multilevel_irq.c 28 ) 29 30zephyr_library_sources_ifdef(CONFIG_LEGACY_MULTI_LEVEL_TABLE_GENERATION multilevel_irq_legacy.c) 31 32zephyr_library_sources_ifdef(CONFIG_SHARED_INTERRUPTS shared_irq.c) 33 34if(NOT CONFIG_ARCH_HAS_TIMING_FUNCTIONS AND 35 NOT CONFIG_SOC_HAS_TIMING_FUNCTIONS AND 36 NOT CONFIG_BOARD_HAS_TIMING_FUNCTIONS) 37zephyr_library_sources_ifdef(CONFIG_TIMING_FUNCTIONS timing.c) 38endif() 39 40# Put functions and data in their own binary sections so that ld can 41# garbage collect them 42zephyr_cc_option(-ffunction-sections -fdata-sections) 43 44zephyr_linker_sources_ifdef(CONFIG_GEN_ISR_TABLES 45 SECTIONS 46 ${ZEPHYR_BASE}/include/zephyr/linker/intlist.ld 47) 48 49zephyr_linker_sources_ifdef(CONFIG_ISR_TABLES_LOCAL_DECLARATION 50 SECTIONS 51 ${ZEPHYR_BASE}/include/zephyr/linker/isr-local-drop-unused.ld 52) 53 54zephyr_linker_sources_ifdef(CONFIG_GEN_IRQ_VECTOR_TABLE 55 ROM_START 56 SORT_KEY 0x0vectors 57 ${ZEPHYR_BASE}/include/zephyr/linker/irq-vector-table-section.ld 58) 59 60if(CONFIG_GEN_ISR_TABLES) 61 zephyr_linker_section(NAME .intList VMA IDT_LIST LMA IDT_LIST NOINPUT PASS NOT LINKER_ZEPHYR_FINAL) 62 zephyr_linker_section_configure(SECTION .intList KEEP INPUT ".irq_info" FIRST) 63 zephyr_linker_section_configure(SECTION .intList KEEP INPUT ".intList") 64 65 zephyr_linker_section_configure(SECTION /DISCARD/ KEEP INPUT ".irq_info" PASS LINKER_ZEPHYR_FINAL) 66 zephyr_linker_section_configure(SECTION /DISCARD/ KEEP INPUT ".intList" PASS LINKER_ZEPHYR_FINAL) 67endif() 68 69zephyr_linker_sources_ifdef(CONFIG_ARCH_HAS_RAMFUNC_SUPPORT 70 RAM_SECTIONS 71 ramfunc.ld 72) 73 74zephyr_linker_sources_ifdef(CONFIG_NOCACHE_MEMORY 75 RAM_SECTIONS 76 nocache.ld 77) 78 79# Only ARM, X86 and OPENISA_RV32M1_RISCV32 use ROM_START_OFFSET. 80if (DEFINED CONFIG_ARM OR DEFINED CONFIG_X86 OR DEFINED CONFIG_ARM64 81 OR DEFINED CONFIG_SOC_OPENISA_RV32M1) 82 # Exclamation mark is printable character with lowest number in ASCII table. 83 # We are sure that this file will be included as a first. 84 zephyr_linker_sources(ROM_START SORT_KEY ! rom_start_address.ld) 85 # Some linkers fill unspecified region with pattern other than 0x00. Include 86 # fill_with_zeros.ld file which forces the linker to use 0x00 pattern. Please 87 # note that the pattern will affect empty spaces created after FILL(0x00). 88 zephyr_linker_sources(ROM_START SORT_KEY $ fill_with_zeros.ld) 89 zephyr_linker_sources(ROM_START SORT_KEY 0x0 rom_start_offset.ld) 90 # Handled in ld.cmake 91endif() 92 93 94# isr_tables is a normal CMake library and not a zephyr_library because it 95# should not be --whole-archive'd 96if (CONFIG_GEN_ISR_TABLES) 97 add_library(isr_tables 98 isr_tables.c 99 ) 100 101 add_dependencies(isr_tables zephyr_generated_headers) 102 target_link_libraries(isr_tables zephyr_interface) 103 zephyr_library_link_libraries(isr_tables) 104endif() 105 106if(CONFIG_COVERAGE) 107 zephyr_compile_options($<TARGET_PROPERTY:compiler,coverage>) 108 zephyr_link_libraries_ifndef(CONFIG_NATIVE_LIBRARY $<TARGET_PROPERTY:linker,coverage>) 109endif() 110 111zephyr_library_sources_ifdef(CONFIG_SEMIHOST semihost.c) 112