Permalink
Browse files

[dwarf] The sword() function in Gexpr.c doesn't do what's intended.

Yes, it casts to signed, but then converts right back to
unsigned via the return type.  Fixed thus.

Signed-off-by: Richard Henderson <rth@redhat.com>
Signed-off-by: Arun Sharma <arun.sharma@google.com>
  • Loading branch information...
1 parent cdb96f3 commit 11ea1275bd188ea48f5d834ca504f8d84d751983 Arun Sharma committed with David Mosberger-Tang Jul 27, 2006
Showing with 5 additions and 12 deletions.
  1. +1 −0 include/libunwind-hppa.h
  2. +1 −0 include/libunwind-ia64.h
  3. +1 −0 include/libunwind-x86.h
  4. +1 −0 include/libunwind-x86_64.h
  5. +1 −12 src/dwarf/Gexpr.c
View
@@ -45,6 +45,7 @@ extern "C" {
#define UNW_TDEP_CURSOR_LEN 511
typedef uint32_t unw_word_t;
+typedef int32_t unw_sword_t;
typedef union
{
View
@@ -67,6 +67,7 @@ extern "C" {
#define UNW_PI_FLAG_IA64_RBS_SWITCH (1 << UNW_PI_FLAG_IA64_RBS_SWITCH_BIT)
typedef uint64_t unw_word_t;
+typedef int64_t unw_sword_t;
/* On IA-64, we want to access the contents of floating-point
registers as a pair of "words", but to ensure 16-byte alignment, we
View
@@ -46,6 +46,7 @@ extern "C" {
#define UNW_TDEP_CURSOR_LEN 127
typedef uint32_t unw_word_t;
+typedef int32_t unw_sword_t;
typedef long double unw_tdep_fpreg_t;
@@ -48,6 +48,7 @@ extern "C" {
#define UNW_TDEP_CURSOR_LEN 127
typedef uint64_t unw_word_t;
+typedef int64_t unw_sword_t;
typedef long double unw_tdep_fpreg_t;
View
@@ -106,18 +106,7 @@ static uint8_t operands[256] =
[DW_OP_call_ref] = OPND1 (OFFSET)
};
-static inline unw_word_t
-sword (unw_word_t val)
-{
- switch (sizeof (unw_word_t))
- {
- case 1: return (int8_t) val;
- case 2: return (int16_t) val;
- case 4: return (int32_t) val;
- case 8: return (int64_t) val;
- default: abort ();
- }
-}
+#define sword(X) ((unw_sword_t) (X))
static inline unw_word_t
read_operand (unw_addr_space_t as, unw_accessors_t *a,

0 comments on commit 11ea127

Please sign in to comment.