[Bug target/125803] [14,15,16,17][powerpc64 FreeBSD ELFv2] frob_update_context in freebsd-unwind.h uses the ELFv1 TOC save-slot offset (40), so r2 is not restored when unwinding and C++ exceptions crash
gerald at pfeifer dot com via Gcc-bugs <[email protected]>
| Newsgroups | gmane.comp.gcc.bugs |
|---|---|
| Message-ID | <[email protected]/bugzilla/> |
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125803
Gerald Pfeifer <gerald at pfeifer dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2026-08-12
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
--- Comment #4 from Gerald Pfeifer <gerald at pfeifer dot com> ---
(In reply to Piotr Kubaj from comment #0)
> The problem is that the code assumes ELFv1 and sets TOC save slot offset of
> 40 bytes:
> std r2,40(r1) == 0xF8410028
> ld r2,40(r1) == 0xE8410028
> context->cfa + 40 , sp + 40
>
> But ELFv2 saves the TOC at offset 24 (std r2,24(r1) / ld r2,24(r1)), so
> none of the checks ever match, r2 is never restored, and the handler
> runs with the wrong TOC.
Very nice detective work, Piotr, by the way!