aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Vogt <vogt@linux.vnet.ibm.com>2015-11-17 10:56:32 +0100
committerAndreas Krebbel <krebbel@linux.vnet.ibm.com>2015-11-17 10:56:32 +0100
commit66c6502d7a457057683f56fd6d606fd9b2da0655 (patch)
tree522410682e2dd98ce2a28f630d98759eb41a1f34
parent146b80ff180c0490fa920c183d665f536f2a4b0b (diff)
downloadgdb-66c6502d7a457057683f56fd6d606fd9b2da0655.zip
gdb-66c6502d7a457057683f56fd6d606fd9b2da0655.tar.gz
gdb-66c6502d7a457057683f56fd6d606fd9b2da0655.tar.bz2
gdb: Fix left shift of negative value.
This patch fixes all occurences of left-shifting negative constants in C cod which is undefined by the C standard. gdb/ChangeLog: * hppa-tdep.c (hppa_sign_extend, hppa_low_hppa_sign_extend) (prologue_inst_adjust_sp, hppa_frame_cache): Fix left shift of negative value. * dwarf2read.c (read_subrange_type): Likewise.
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/dwarf2read.c2
-rw-r--r--gdb/hppa-tdep.c8
3 files changed, 12 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index fd2ac45..20a62c2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2015-11-17 Dominik Vogt <vogt@linux.vnet.ibm.com>
+
+ * hppa-tdep.c (hppa_sign_extend, hppa_low_hppa_sign_extend)
+ (prologue_inst_adjust_sp, hppa_frame_cache): Fix left shift of negative
+ value.
+ * dwarf2read.c (read_subrange_type): Likewise.
+
2015-11-16 Yao Qi <yao.qi@linaro.org>
* aarch64-tdep.c (aarch64_extract_return_value): Change array
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 87dc8b4..48921e7 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -15048,7 +15048,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
the bounds as signed, and thus sign-extend their values, when
the base type is signed. */
negative_mask =
- (LONGEST) -1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1);
+ -((LONGEST) 1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1));
if (low.kind == PROP_CONST
&& !TYPE_UNSIGNED (base_type) && (low.data.const_val & negative_mask))
low.data.const_val |= negative_mask;
diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index ba7f946..3206729 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -104,7 +104,7 @@ static const struct objfile_data *hppa_objfile_priv_data = NULL;
static int
hppa_sign_extend (unsigned val, unsigned bits)
{
- return (int) (val >> (bits - 1) ? (-1 << bits) | val : val);
+ return (int) (val >> (bits - 1) ? (-(1 << bits)) | val : val);
}
/* For many immediate values the sign bit is the low bit! */
@@ -112,7 +112,7 @@ hppa_sign_extend (unsigned val, unsigned bits)
static int
hppa_low_hppa_sign_extend (unsigned val, unsigned bits)
{
- return (int) ((val & 0x1 ? (-1 << (bits - 1)) : 0) | val >> 1);
+ return (int) ((val & 0x1 ? (-(1 << (bits - 1))) : 0) | val >> 1);
}
/* Extract the bits at positions between FROM and TO, using HP's numbering
@@ -1357,7 +1357,7 @@ prologue_inst_adjust_sp (unsigned long inst)
/* std,ma X,D(sp) */
if ((inst & 0xffe00008) == 0x73c00008)
- return (inst & 0x1 ? -1 << 13 : 0) | (((inst >> 4) & 0x3ff) << 3);
+ return (inst & 0x1 ? -(1 << 13) : 0) | (((inst >> 4) & 0x3ff) << 3);
/* addil high21,%r30; ldo low11,(%r1),%r30)
save high bits in save_high21 for later use. */
@@ -2066,7 +2066,7 @@ hppa_frame_cache (struct frame_info *this_frame, void **this_cache)
CORE_ADDR offset;
if ((inst >> 26) == 0x1c)
- offset = (inst & 0x1 ? -1 << 13 : 0)
+ offset = (inst & 0x1 ? -(1 << 13) : 0)
| (((inst >> 4) & 0x3ff) << 3);
else if ((inst >> 26) == 0x03)
offset = hppa_low_hppa_sign_extend (inst & 0x1f, 5);