Skip to content

Commit

Permalink
linker: cpp: Fix C++ exception handling info section linking
Browse files Browse the repository at this point in the history
The `.eh_frame_hdr` and `.eh_frame` ROM sections, which contain read-
only C++ exception handling information, are currently specified in
`cplusplus-ram.ld`, and this can cause the linker output location
counter to take a ROM region address while in the RAM region.

This commit relocates these sections to `cplusplus-rom.ld` in order to
prevent the linker output location counter from getting corrupted.

For more details, refer to the issue #35972.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
  • Loading branch information
stephanosio authored and github-actions[bot] committed Jun 8, 2021
1 parent 4a564cd commit 0076e19
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
11 changes: 0 additions & 11 deletions include/linker/cplusplus-ram.ld
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,6 @@
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)

#if defined (CONFIG_EXCEPTIONS)
SECTION_PROLOGUE(.eh_frame_hdr,,)
{
*(.eh_frame_hdr)
}

SECTION_PROLOGUE(.eh_frame,,)
{
KEEP (*(SORT_NONE(EXCLUDE_FILE (*crtend.o) .eh_frame)))
KEEP (*(SORT_NONE(.eh_frame)))
} GROUP_LINK_IN(ROMABLE_REGION)

SECTION_PROLOGUE(.tm_clone_table,,)
{
KEEP (*(SORT_NONE(EXCLUDE_FILE (*crtend.o) .tm_clone_table)))
Expand Down
16 changes: 15 additions & 1 deletion include/linker/cplusplus-rom.ld
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,18 @@
{
*(.gcc_except_table .gcc_except_table.*)
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
#endif

#if defined (CONFIG_EXCEPTIONS)
SECTION_PROLOGUE(.eh_frame_hdr,,)
{
*(.eh_frame_hdr)
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)

SECTION_PROLOGUE(.eh_frame,,)
{
KEEP (*(SORT_NONE(EXCLUDE_FILE (*crtend.o) .eh_frame)))
KEEP (*(SORT_NONE(.eh_frame)))
} GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
#endif /* CONFIG_EXCEPTIONS */

#endif /* CONFIG_CPLUSPLUS */

0 comments on commit 0076e19

Please sign in to comment.