This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [ARM] fix C++ EH interoperability


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.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]