2019-04-06 21:08:09 +08:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2023-08-11 03:48:13 +08:00
|
|
|
zephyr_library()
|
2019-11-01 19:10:26 +08:00
|
|
|
|
2023-10-16 15:39:48 +08:00
|
|
|
zephyr_library_include_directories(include)
|
|
|
|
|
2023-08-11 03:48:13 +08:00
|
|
|
# Library may be empty due to kconfigs
|
|
|
|
zephyr_library_property(ALLOW_EMPTY TRUE)
|
|
|
|
|
2023-11-06 15:37:52 +08:00
|
|
|
if(CONFIG_GEN_ISR_TABLES)
|
|
|
|
zephyr_library_sources(
|
|
|
|
sw_isr_common.c
|
|
|
|
)
|
|
|
|
zephyr_library_sources_ifdef(
|
|
|
|
CONFIG_DYNAMIC_INTERRUPTS
|
|
|
|
dynamic_isr.c
|
2023-08-11 03:48:13 +08:00
|
|
|
)
|
2023-11-06 15:37:52 +08:00
|
|
|
endif()
|
2019-11-01 19:10:26 +08:00
|
|
|
|
2024-08-08 11:00:42 +08:00
|
|
|
zephyr_library_sources_ifdef(
|
|
|
|
CONFIG_ISR_TABLE_SHELL
|
|
|
|
isr_tables_shell.c
|
|
|
|
)
|
|
|
|
|
2023-11-06 15:27:30 +08:00
|
|
|
zephyr_library_sources_ifdef(
|
|
|
|
CONFIG_MULTI_LEVEL_INTERRUPTS
|
|
|
|
multilevel_irq.c
|
|
|
|
)
|
|
|
|
|
2023-12-20 21:06:14 +08:00
|
|
|
zephyr_library_sources_ifdef(CONFIG_LEGACY_MULTI_LEVEL_TABLE_GENERATION multilevel_irq_legacy.c)
|
|
|
|
|
2023-08-11 16:58:34 +08:00
|
|
|
zephyr_library_sources_ifdef(CONFIG_SHARED_INTERRUPTS shared_irq.c)
|
|
|
|
|
2020-08-28 11:07:01 +08:00
|
|
|
if(NOT CONFIG_ARCH_HAS_TIMING_FUNCTIONS AND
|
|
|
|
NOT CONFIG_SOC_HAS_TIMING_FUNCTIONS AND
|
|
|
|
NOT CONFIG_BOARD_HAS_TIMING_FUNCTIONS)
|
|
|
|
zephyr_library_sources_ifdef(CONFIG_TIMING_FUNCTIONS timing.c)
|
|
|
|
endif()
|
|
|
|
|
2017-10-27 21:43:34 +08:00
|
|
|
# Put functions and data in their own binary sections so that ld can
|
|
|
|
# garbage collect them
|
|
|
|
zephyr_cc_option(-ffunction-sections -fdata-sections)
|
|
|
|
|
2019-03-20 20:10:48 +08:00
|
|
|
zephyr_linker_sources_ifdef(CONFIG_GEN_ISR_TABLES
|
|
|
|
SECTIONS
|
2022-05-09 19:52:12 +08:00
|
|
|
${ZEPHYR_BASE}/include/zephyr/linker/intlist.ld
|
2019-03-20 20:10:48 +08:00
|
|
|
)
|
2019-03-13 00:15:32 +08:00
|
|
|
|
2023-12-19 23:54:18 +08:00
|
|
|
zephyr_linker_sources_ifdef(CONFIG_ISR_TABLES_LOCAL_DECLARATION
|
|
|
|
SECTIONS
|
|
|
|
${ZEPHYR_BASE}/include/zephyr/linker/isr-local-drop-unused.ld
|
|
|
|
)
|
|
|
|
|
2022-06-21 20:26:03 +08:00
|
|
|
zephyr_linker_sources_ifdef(CONFIG_GEN_IRQ_VECTOR_TABLE
|
|
|
|
ROM_START
|
|
|
|
SORT_KEY 0x0vectors
|
|
|
|
${ZEPHYR_BASE}/include/zephyr/linker/irq-vector-table-section.ld
|
|
|
|
)
|
|
|
|
|
2021-06-01 16:04:31 +08:00
|
|
|
if(CONFIG_GEN_ISR_TABLES)
|
2021-11-01 20:22:55 +08:00
|
|
|
zephyr_linker_section(NAME .intList VMA IDT_LIST LMA IDT_LIST NOINPUT PASS NOT LINKER_ZEPHYR_FINAL)
|
2021-06-01 16:04:31 +08:00
|
|
|
zephyr_linker_section_configure(SECTION .intList KEEP INPUT ".irq_info" FIRST)
|
|
|
|
zephyr_linker_section_configure(SECTION .intList KEEP INPUT ".intList")
|
|
|
|
|
2021-11-01 20:22:55 +08:00
|
|
|
zephyr_linker_section_configure(SECTION /DISCARD/ KEEP INPUT ".irq_info" PASS LINKER_ZEPHYR_FINAL)
|
|
|
|
zephyr_linker_section_configure(SECTION /DISCARD/ KEEP INPUT ".intList" PASS LINKER_ZEPHYR_FINAL)
|
2021-06-01 16:04:31 +08:00
|
|
|
endif()
|
|
|
|
|
2019-03-13 00:15:32 +08:00
|
|
|
zephyr_linker_sources_ifdef(CONFIG_ARCH_HAS_RAMFUNC_SUPPORT
|
|
|
|
RAM_SECTIONS
|
|
|
|
ramfunc.ld
|
|
|
|
)
|
2019-03-20 20:04:45 +08:00
|
|
|
|
|
|
|
zephyr_linker_sources_ifdef(CONFIG_NOCACHE_MEMORY
|
|
|
|
RAM_SECTIONS
|
|
|
|
nocache.ld
|
|
|
|
)
|
2019-11-29 20:31:00 +08:00
|
|
|
|
2020-02-10 15:37:24 +08:00
|
|
|
# Only ARM, X86 and OPENISA_RV32M1_RISCV32 use ROM_START_OFFSET.
|
2021-03-25 18:56:15 +08:00
|
|
|
if (DEFINED CONFIG_ARM OR DEFINED CONFIG_X86 OR DEFINED CONFIG_ARM64
|
2022-09-15 04:23:15 +08:00
|
|
|
OR DEFINED CONFIG_SOC_OPENISA_RV32M1)
|
arch/common: Fix moving location counter backwards when using LLD
In GNU LD, the location counter (the 'dot' variable) always refers to
the byte offset from the start of current object as mentioned in
documentation[1]:
```
'.' actually refers to the byte offset from the start of the current
containing object. Normally this is the SECTIONS statement, whose start
address is 0, hence '.' can be used as an absolute address. If '.' is
used inside a section description however, it refers to the byte offset
from the start of that section, not an absolute address.
```
For example, if the section 'rom_start':
rom_start : {
. = 0x400;
_vector_start = ABSOLUTE(.);
} > FLASH
has a starting address of 0x8000000, then _vector_start will be
0x8000400
However, behavior of LLVM LLD is quite different, the value of the
location counter is always absolute (see discussion [2]), so in the
example above, the linker will return error, because it will interpret
'. = 0x400' as an attempt to move the location counter backwards.
It could be fixed by changing line to '. += 0x400' (#54796) which will
move the location counter by 0x400 for both linkers, but it would work
only when we are at the beginning of section. Consider the following
example:
rom_start : {
. = 0x400;
KEEP(*(.boot_hdr.conf))
. = 0x1000;
KEEP(*(.boot_hdr.ivt))
KEEP(*(.boot_hdr.data))
KEEP(*(.boot_hdr.dcd_data))
. = 0x2000;
_vector_start = .;
} > FLASH
In this case, _vector_start will be 0x2000, but if we change
'. = 0x2000' to '. += 0x2000', then the value of _vector_start depends
on size of data in input sections (but it's 0x3000 at least).
Actually, this example comes from final linker script when compiling
firmware for mimxrt1170_evk_cm7 board. This board failed to boot
(#55296) after #54796 was merged.
This patch introduces method compatible with both linkers. We calculate
relative offset from the beginning of the section and use that value to
calculate number of bytes by which we should move the location counter
to get CONFIG_ROM_START_OFFSET.
[1] https://sourceware.org/binutils/docs/ld/Location-Counter.html
[2] https://discourse.llvm.org/t/lld-location-counter-inside-objects
Signed-off-by: Patryk Duda <pdk@semihalf.com>
2023-05-26 19:47:08 +08:00
|
|
|
# Exclamation mark is printable character with lowest number in ASCII table.
|
|
|
|
# We are sure that this file will be included as a first.
|
|
|
|
zephyr_linker_sources(ROM_START SORT_KEY ! rom_start_address.ld)
|
2023-09-01 21:57:18 +08:00
|
|
|
# Some linkers fill unspecified region with pattern other than 0x00. Include
|
|
|
|
# fill_with_zeros.ld file which forces the linker to use 0x00 pattern. Please
|
|
|
|
# note that the pattern will affect empty spaces created after FILL(0x00).
|
|
|
|
zephyr_linker_sources(ROM_START SORT_KEY $ fill_with_zeros.ld)
|
2020-02-10 15:37:24 +08:00
|
|
|
zephyr_linker_sources(ROM_START SORT_KEY 0x0 rom_start_offset.ld)
|
2021-05-06 17:49:35 +08:00
|
|
|
# Handled in ld.cmake
|
2019-11-29 20:31:00 +08:00
|
|
|
endif()
|
2020-08-18 03:50:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
# isr_tables is a normal CMake library and not a zephyr_library because it
|
|
|
|
# should not be --whole-archive'd
|
|
|
|
if (CONFIG_GEN_ISR_TABLES)
|
|
|
|
add_library(isr_tables
|
|
|
|
isr_tables.c
|
|
|
|
)
|
|
|
|
|
|
|
|
add_dependencies(isr_tables zephyr_generated_headers)
|
|
|
|
target_link_libraries(isr_tables zephyr_interface)
|
|
|
|
zephyr_library_link_libraries(isr_tables)
|
|
|
|
endif()
|
2021-06-04 04:33:39 +08:00
|
|
|
|
|
|
|
if(CONFIG_COVERAGE)
|
|
|
|
zephyr_compile_options($<TARGET_PROPERTY:compiler,coverage>)
|
2023-06-07 16:39:48 +08:00
|
|
|
zephyr_link_libraries_ifndef(CONFIG_NATIVE_LIBRARY $<TARGET_PROPERTY:linker,coverage>)
|
2021-06-04 04:33:39 +08:00
|
|
|
endif()
|
2022-03-30 18:43:41 +08:00
|
|
|
|
2023-08-11 03:48:13 +08:00
|
|
|
zephyr_library_sources_ifdef(CONFIG_SEMIHOST semihost.c)
|