[PATCH] libstdc++: add unwind instructions within arm __cxa_end_cleanup
Jonathan Wakely
jwakely@redhat.com
Wed Jul 29 13:34:37 GMT 2026
On Tue, 28 Jul 2026 at 15:07, Clément Chigot <chigot@adacore.com> 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
I'm not qualified to review this, but if no arm maintainer objects
then it's OK for trunk.
> 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
>
More information about the Libstdc++
mailing list