From: Richard Earnshaw <rearnsha@arm.com>
To: Nathan Sidwell <nathan@codesourcery.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [ARM] fix C++ EH interoperability
Date: Wed, 29 Jun 2011 13:52:00 -0000 [thread overview]
Message-ID: <4E0B2B5A.1010400@arm.com> (raw)
In-Reply-To: <4DDA82AB.3060805@codesourcery.com>
On 23/05/11 16:52, Nathan Sidwell wrote:
> This patch fixes an interoperability issue with code generated by ARM's
> EABI compiler.
>
> Unlike the generic C++ ABI, which always catches pointers by value,
> ARM's ABI only catches pointers by value when there's the possibility of
> derived->base conversion happening. The ARM __cxa_type_matcher can
> return one of 3 values to indicate the three possibilities. GCC was
> returning the success value when a pointer matched exactly, but
> returning the pointer by value. This is incompatible with EABI
> compliant code, which expects a reference to the thrown pointer in such
> cases.
>
> However, we cannot simply change the GCC type matcher to return a
> reference in such cases, as then it will be incompatible with existing
> GCC-compiled code. GCC compiled code expects the pointer value at the
> landing pad, ARM-compiled code expects a reference to the pointer
> value. Hence ARM-compiled code (usually) inserts an additional
> dereference.
>
> Note that the compiler generating the catching code, specifies the
> personality routine (unwinder), but the code doing the type-matching
> could come from any compliant library.
>
> In discussion with ARM, I developed the attached patch, which changes
> __cxa_type_match to return the succeeded_with_ptr_to_base enum value
> whenever a pointer is caught (rather than only when a pointer-to-derived
> is converted to a pointer-to-base). This value indicates to the (ARM)
> unwinding machinery that the pointer value is being returned. And makes
> the type matcher work with the ARM unwinder. We do not change the
> conditions under which _cxa_type_match performs the pointer indirection.
>
> At the other side of the interface, we have to make GCC's implementation
> of the EABI unwinder work with an ARM-provided type matcher. Here, the
> unwinder notes the return value from _cxa_match_type, and inserts an
> additional indirection by using a spare field in the barrier_cache
> structure. Fortunately GCC-generated code doesn't use the common
> unwinder, but uses a gnu personality routine, which is unchanged.
>
> This patch results has been tested for arm-linux, and independently
> tested by ARM with mixed RVCT-generated code confirming the defect has
> been fixed.
>
> ok?
>
> nathan
>
>
> arm-eh.patch
>
>
> 2011-05-23 Nathan Sidwell <nathan@codesourcery.com>
>
> gcc/
> * config/arm/unwind-arm.c (enum __cxa_type_match_result): New.
> (cxa_type_match): Correct declaration.
> (__gnu_unwind_pr_common): Reconstruct
> additional indirection when __cxa_type_match returns
> succeeded_with_ptr_to_base.
>
> libstdc++/
> * libsupc++/eh_arm.c (__cxa_type_match): Construct address of
> thrown object here. Return succeded_with_ptr_to_base for all
> pointer cases.
>
OK.
R.
prev parent reply other threads:[~2011-06-29 13:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-23 16:52 Nathan Sidwell
2011-05-23 16:56 ` Andrew Haley
2011-05-25 14:18 ` Nathan Sidwell
2011-06-15 14:15 ` Nathan Sidwell
2011-06-29 13:52 ` Richard Earnshaw [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E0B2B5A.1010400@arm.com \
--to=rearnsha@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=nathan@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).