zephyr/include/linker/cplusplus-ram.ld
Stephanos Ioannidis 9881ce0a11 linker: cpp: Disable sorting of C++ exception handling info sections
The `CONFIG_LINKER_SORT_BY_ALIGNMENT` config, which is enabled by
default, causes the sections containing C++ exception handling
information to be re-ordered for certain targets (in particular, the
64-bit arch targets). This effectively breaks the required "crtbegin.o
-> others -> crtend.o" order and causes the address of the
__EH_FRAME_BEGIN__ symbol to be invalid; thereby, causing C++
exception unwinding to fail.

This commit adds SORT_NONE property to these sections in order to
ensure that the linking order specified in the linker command line is
maintained.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2021-05-27 14:36:13 -05:00

33 lines
815 B
Plaintext

/*
* Copyright (c) 2019 Jan Van Winkel <jan.van_winkel@dxplore.eu>
*
* SPDX-License-Identifier: Apache-2.0
*/
#if defined (CONFIG_CPLUSPLUS)
SECTION_DATA_PROLOGUE(.gcc_except_table,,ONLY_IF_RW)
{
*(.gcc_except_table .gcc_except_table.*)
} 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)))
KEEP (*(SORT_NONE(.tm_clone_table)))
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
#endif /* CONFIG_EXCEPTIONS */
#endif /* CONFIG_CPLUSPLUS */