From 9881ce0a11b5044d0bc5910efeb3b4e0ec354fdf Mon Sep 17 00:00:00 2001 From: Stephanos Ioannidis Date: Fri, 28 May 2021 01:51:47 +0900 Subject: [PATCH] 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 --- include/linker/cplusplus-ram.ld | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linker/cplusplus-ram.ld b/include/linker/cplusplus-ram.ld index 43d3ef1ce04..7a98e12997c 100644 --- a/include/linker/cplusplus-ram.ld +++ b/include/linker/cplusplus-ram.ld @@ -18,14 +18,14 @@ SECTION_PROLOGUE(.eh_frame,,) { - KEEP (*(EXCLUDE_FILE (*crtend.o) .eh_frame)) - KEEP (*(.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 (*(EXCLUDE_FILE (*crtend.o) .tm_clone_table)) - KEEP (*(.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 */