(reply to send it correctly to gcc-patches and not gc-patches...)

On Tue, Jul 28, 2026 at 4:06 PM Clément Chigot <[email protected]> wrote:
>
> .ARM.extab and .ARM.exidx unwinding sections for a symbol are only
> created by the GNU assembler when explicit .fnstart and .fnend
> directives are present for that symbol.
>
> When the linker doesn't find any exidx entry for a given function,
> it adds an EXIDX_CANTUNWIND note to the last .ARM.exidx section
> it has created. This section could be attached to a totally
> unrelated symbol, causing a lot of misguided processing down the
> line.
>
> While some of this probably should be addressed in the linker,
> (see binutils/PR33489), being explicit in assembly sources is useful
> in any case. This patch adds directives to asm functions exposed by
> libsupc++/eh_arm.cc
>
> libstdc++-v3:
>
>         * libsupc++/eh_arm.cc (__cxa_end_cleanup): Add unwind directives.
> ---
>  libstdc++-v3/libsupc++/eh_arm.cc | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/libstdc++-v3/libsupc++/eh_arm.cc 
> b/libstdc++-v3/libsupc++/eh_arm.cc
> index 7008ce60f6d..1a11a6e419d 100644
> --- a/libstdc++-v3/libsupc++/eh_arm.cc
> +++ b/libstdc++-v3/libsupc++/eh_arm.cc
> @@ -205,21 +205,27 @@ asm ("  .pushsection .text.__cxa_end_cleanup\n"
>  "      .global __cxa_end_cleanup\n"
>  "      .type __cxa_end_cleanup, \"function\"\n"
>  "      .thumb_func\n"
> +"      .fnstart\n"
>  "__cxa_end_cleanup:\n"
>  "      push\t{r1, r2, r3, r4}\n"
>  "      bl\t__gnu_end_cleanup\n"
>  "      pop\t{r1, r2, r3, r4}\n"
>  "      bl\t_Unwind_Resume @ Never returns\n"
> +"      .cantunwind\n"
> +"      .fnend\n"
>  "      .popsection\n");
>  #else
>  asm ("  .pushsection .text.__cxa_end_cleanup\n"
>  "      .global __cxa_end_cleanup\n"
>  "      .type __cxa_end_cleanup, \"function\"\n"
> +"      .fnstart\n"
>  "__cxa_end_cleanup:\n"
>  "      stmfd\tsp!, {r1, r2, r3, r4}\n"
>  "      bl\t__gnu_end_cleanup\n"
>  "      ldmfd\tsp!, {r1, r2, r3, r4}\n"
>  "      bl\t_Unwind_Resume @ Never returns\n"
> +"      .cantunwind\n"
> +"      .fnend\n"
>  "      .popsection\n");
>  #endif
>  #endif
> --
> 2.43.0
>

Reply via email to