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

Patrick Wildt mail at patrick-wildt.de
Fri Apr 11 05:24:34 PDT 2014


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)



More information about the cfe-commits mailing list