Skip to content

Commit 4974bc0

Browse files
LaurentiuM1234carlescufi
authored andcommitted
linker: common-rom: Keep z_shared_isr regardless of dynamic interrupts
Currently, the z_shared_isr symbol is only kept if CONFIG_DYNAMIC_INTERRUPTS=n. Whenever CONFG_DYNAMIC_INTERRUPTS is set to 'y', said symbol gets dropped when zephyr_pre0.elf is created. This is wrong because dropping/keeping z_shared_isr shouldn't be influenced by enabling/disabling support for the dynamic interrupts. This commit fixes the aforementioned issue by removing the dependency on CONFIG_DYNAMIC_INTERRUPTS. Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
1 parent b598106 commit 4974bc0

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

include/zephyr/linker/common-rom/common-rom-kernel-devices.ld

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,26 @@
2222

2323
ITERABLE_SECTION_ROM_NUMERIC(device, 4)
2424

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+
2545
#if defined(CONFIG_GEN_SW_ISR_TABLE) && !defined(CONFIG_DYNAMIC_INTERRUPTS)
2646
SECTION_PROLOGUE(sw_isr_table,,)
2747
{
@@ -40,11 +60,6 @@
4060
/* TODO: does this section require alignment? */
4161
KEEP(*(_SHARED_SW_ISR_TABLE_SECTION_SYMS))
4262
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
43-
44-
SECTION_PROLOGUE(.text.z_shared_isr,,)
45-
{
46-
KEEP(*(.text.z_shared_isr))
47-
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
4863
#endif
4964

5065
#endif

0 commit comments

Comments
 (0)