Skip to content

Commit

Permalink
linker: common-rom: Keep z_shared_isr regardless of dynamic interrupts
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
LaurentiuM1234 authored and carlescufi committed Oct 24, 2023
1 parent b598106 commit 4974bc0
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions include/zephyr/linker/common-rom/common-rom-kernel-devices.ld
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@

ITERABLE_SECTION_ROM_NUMERIC(device, 4)

#if defined(CONFIG_GEN_SW_ISR_TABLE) && defined(CONFIG_SHARED_INTERRUPTS)
/* since z_shared_isr() is not referenced anywhere when
* zephyr_pre0.elf is built, the linker will end up dropping it.
* Later on, during the second linking stage (when zephyr.elf is
* built), the symbol will be added to the text section since it's
* now being referenced (thanks to isr_tables.c). This is very
* problematic because adding the z_shared_isr symbol between
* the linking stages will end up shifting the addresses of the
* functions, which, in turn, will end up messing the ISR table
* (as the entries from _sw_isr_table will end up pointing to
* old addresses of the registered ISRs). To prevent this from
* happening, instruct the linker to avoid dropping z_shared_isr
* if it's not being referenced anywhere.
*/
SECTION_PROLOGUE(.text.z_shared_isr,,)
{
KEEP(*(.text.z_shared_isr))
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
#endif

#if defined(CONFIG_GEN_SW_ISR_TABLE) && !defined(CONFIG_DYNAMIC_INTERRUPTS)
SECTION_PROLOGUE(sw_isr_table,,)
{
Expand All @@ -40,11 +60,6 @@
/* TODO: does this section require alignment? */
KEEP(*(_SHARED_SW_ISR_TABLE_SECTION_SYMS))
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)

SECTION_PROLOGUE(.text.z_shared_isr,,)
{
KEEP(*(.text.z_shared_isr))
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
#endif

#endif
Expand Down

0 comments on commit 4974bc0

Please sign in to comment.