diff --git a/arch/common/CMakeLists.txt b/arch/common/CMakeLists.txt index 291e55686f..edeb9c2c30 100644 --- a/arch/common/CMakeLists.txt +++ b/arch/common/CMakeLists.txt @@ -15,6 +15,10 @@ zephyr_sources_ifdef( timing_info_bench.c ) +zephyr_linker_sources_ifdef(CONFIG_GEN_ISR_TABLES + SECTIONS + isr_tables.ld +) zephyr_linker_sources_ifdef(CONFIG_ARCH_HAS_RAMFUNC_SUPPORT RAM_SECTIONS diff --git a/arch/common/isr_tables.ld b/arch/common/isr_tables.ld new file mode 100644 index 0000000000..549fd925aa --- /dev/null +++ b/arch/common/isr_tables.ld @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2019 Nordic Semiconductor ASA + * Copyright (c) 2019 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* Copied from linker.ld */ + +/* This creates a special section which is not included by the final binary, + * instead it is consumed by the gen_isr_tables.py script. + * + * What we create here is a data structure: + * + * struct { + * u32_t num_vectors; <- typically CONFIG_NUM_IRQS + * struct _isr_list isrs[]; <- Usually of smaller size than num_vectors + * } + * + * Which indicates the memory address of the number of isrs that were + * defined, the total number of IRQ lines in the system, followed by + * an appropriate number of instances of struct _isr_list. See + * include/sw_isr_table.h + * + * You will need to declare a bogus memory region for IDT_LIST. It doesn't + * matter where this region goes as it is stripped from the final ELF image. + * The address doesn't even have to be valid on the target. However, it + * shouldn't overlap any other regions. On most arches the following should be + * fine: + * + * MEMORY { + * .. other regions .. + * IDT_LIST : ORIGIN = 0xfffff7ff, LENGTH = 2K + * } + */ +#ifndef LINKER_PASS2 +SECTION_PROLOGUE(.intList,,) +{ + KEEP(*(.irq_info)) + KEEP(*(.intList)) +} GROUP_LINK_IN(IDT_LIST) +#else +/DISCARD/ : +{ + KEEP(*(.irq_info)) + KEEP(*(.intList)) +} +#endif diff --git a/include/arch/arc/v2/linker.ld b/include/arch/arc/v2/linker.ld index fc2d6c0037..c2113e54aa 100644 --- a/include/arch/arc/v2/linker.ld +++ b/include/arch/arc/v2/linker.ld @@ -250,10 +250,6 @@ SECTIONS { */ #include -#ifdef CONFIG_GEN_ISR_TABLES -#include -#endif - #include diff --git a/include/arch/arm/cortex_m/scripts/linker.ld b/include/arch/arm/cortex_m/scripts/linker.ld index 54c805a6b8..f74de0c6cb 100644 --- a/include/arch/arm/cortex_m/scripts/linker.ld +++ b/include/arch/arm/cortex_m/scripts/linker.ld @@ -462,10 +462,6 @@ SECTIONS */ #include -#ifdef CONFIG_GEN_ISR_TABLES -#include -#endif - #include SECTION_PROLOGUE(.ARM.attributes, 0,) diff --git a/include/arch/nios2/linker.ld b/include/arch/nios2/linker.ld index b56c7f4652..f4e07bb173 100644 --- a/include/arch/nios2/linker.ld +++ b/include/arch/nios2/linker.ld @@ -295,10 +295,6 @@ SECTIONS */ #include -#ifdef CONFIG_GEN_ISR_TABLES -#include -#endif - #include } diff --git a/include/arch/riscv32/common/linker.ld b/include/arch/riscv32/common/linker.ld index e4bbe2367f..b1fb8e2991 100644 --- a/include/arch/riscv32/common/linker.ld +++ b/include/arch/riscv32/common/linker.ld @@ -204,10 +204,6 @@ SECTIONS */ #include -#ifdef CONFIG_GEN_ISR_TABLES -#include -#endif - GROUP_END(RAMABLE_REGION) #include