1# SPDX-License-Identifier: Apache-2.0
2
3if(CONFIG_GEN_ISR_TABLES)
4  zephyr_library()
5
6  zephyr_library_sources_ifdef(
7    CONFIG_GEN_ISR_TABLES
8    sw_isr_common.c
9    )
10endif()
11
12if(NOT CONFIG_ARCH_HAS_TIMING_FUNCTIONS AND
13    NOT CONFIG_SOC_HAS_TIMING_FUNCTIONS AND
14    NOT CONFIG_BOARD_HAS_TIMING_FUNCTIONS)
15zephyr_library_sources_ifdef(CONFIG_TIMING_FUNCTIONS timing.c)
16endif()
17
18# Put functions and data in their own binary sections so that ld can
19# garbage collect them
20zephyr_cc_option(-ffunction-sections -fdata-sections)
21
22zephyr_linker_sources_ifdef(CONFIG_GEN_ISR_TABLES
23  SECTIONS
24  ${ZEPHYR_BASE}/include/zephyr/linker/intlist.ld
25)
26
27zephyr_linker_sources_ifdef(CONFIG_GEN_IRQ_VECTOR_TABLE
28  ROM_START
29  SORT_KEY 0x0vectors
30  ${ZEPHYR_BASE}/include/zephyr/linker/irq-vector-table-section.ld
31)
32
33if(CONFIG_GEN_ISR_TABLES)
34  zephyr_linker_section(NAME .intList VMA IDT_LIST LMA IDT_LIST NOINPUT PASS NOT LINKER_ZEPHYR_FINAL)
35  zephyr_linker_section_configure(SECTION .intList KEEP INPUT ".irq_info" FIRST)
36  zephyr_linker_section_configure(SECTION .intList KEEP INPUT ".intList")
37
38  zephyr_linker_section_configure(SECTION /DISCARD/ KEEP INPUT ".irq_info" PASS LINKER_ZEPHYR_FINAL)
39  zephyr_linker_section_configure(SECTION /DISCARD/ KEEP INPUT ".intList"  PASS LINKER_ZEPHYR_FINAL)
40endif()
41
42zephyr_linker_sources_ifdef(CONFIG_ARCH_HAS_RAMFUNC_SUPPORT
43  RAM_SECTIONS
44  ramfunc.ld
45)
46
47zephyr_linker_sources_ifdef(CONFIG_NOCACHE_MEMORY
48  RAM_SECTIONS
49  nocache.ld
50)
51
52# Only ARM, X86 and OPENISA_RV32M1_RISCV32 use ROM_START_OFFSET.
53if (DEFINED CONFIG_ARM OR DEFINED CONFIG_X86 OR DEFINED CONFIG_ARM64
54    OR DEFINED CONFIG_SOC_OPENISA_RV32M1_RISCV32)
55  zephyr_linker_sources(ROM_START SORT_KEY 0x0 rom_start_offset.ld)
56  # Handled in ld.cmake
57endif()
58
59
60# isr_tables is a normal CMake library and not a zephyr_library because it
61# should not be --whole-archive'd
62if (CONFIG_GEN_ISR_TABLES)
63  add_library(isr_tables
64    isr_tables.c
65  )
66
67  add_dependencies(isr_tables zephyr_generated_headers)
68  target_link_libraries(isr_tables zephyr_interface)
69  zephyr_library_link_libraries(isr_tables)
70endif()
71
72if(CONFIG_COVERAGE)
73  zephyr_compile_options($<TARGET_PROPERTY:compiler,coverage>)
74  zephyr_link_libraries($<TARGET_PROPERTY:linker,coverage>)
75endif()
76
77zephyr_sources_ifdef(CONFIG_SEMIHOST semihost.c)
78