[PATCH][cxxabi] Properly sign-extend encoded sdata.

Nick Kledzik kledzik at apple.com
Sat Apr 12 16:31:39 PDT 2014


LGTM.

Committed in r206122.

-Nick


On Apr 11, 2014, at 5:24 AM, Patrick Wildt <mail at patrick-wildt.de> wrote:
> Hi,
> 
> In the case of sdata, the returned number has to be properly sign
> extended, otherwise subtractions don't work.
> 
> In sdata8, the result might have to be casted to sint_t instead of
> pint_t to be visually correct.  It probably doesn't do any harm
> as it is now.
> 
> \Patrick
> 
> From d802fee6f399cf1f5f767b1fd78f07a555b77eef Mon Sep 17 00:00:00 2001
> From: Patrick Wildt <patrick at blueri.se>
> Date: Fri, 11 Apr 2014 14:17:40 +0200
> Subject: [PATCH] Properly sign extend sdata.
> 
> ---
> src/Unwind/AddressSpace.hpp | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/src/Unwind/AddressSpace.hpp b/src/Unwind/AddressSpace.hpp
> index aac8b7f..ce95459 100644
> --- a/src/Unwind/AddressSpace.hpp
> +++ b/src/Unwind/AddressSpace.hpp
> @@ -196,12 +196,14 @@ inline LocalAddressSpace::pint_t LocalAddressSpace::getEncodedP(pint_t &addr,
>     result = (pint_t)getSLEB128(addr, end);
>     break;
>   case DW_EH_PE_sdata2:
> -    result = (uint16_t)get16(addr);
> +    /* signed so that it extends negative numbers */
> +    result = (int16_t)get16(addr);
>     p += 2;
>     addr = (pint_t) p;
>     break;
>   case DW_EH_PE_sdata4:
> -    result = (uint32_t)get32(addr);
> +    /* signed so that it extends negative numbers */
> +    result = (int32_t)get32(addr);
>     p += 4;
>     addr = (pint_t) p;
>     break;
> -- 
> 1.8.5.2 (Apple Git-48)
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list