From 14ea44241722a937f66911454a0b59f3924d5f1d Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Mon, 1 Aug 2005 04:06:27 +0000 Subject: [PATCH] * dwarf2-frame.c (read_signed_leb128): Handle values that do not fit in 32 bits. * dwarf2read.c (read_signed_leb128): Likewise. --- gdb/ChangeLog | 6 ++++++ gdb/dwarf2-frame.c | 4 ++-- gdb/dwarf2read.c | 9 +++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 18a2451258..7f17909736 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2005-08-01 Daniel Jacobowitz + + * dwarf2-frame.c (read_signed_leb128): Handle values that do not + fit in 32 bits. + * dwarf2read.c (read_signed_leb128): Likewise. + 2005-07-31 Daniel Jacobowitz From Josef Ezra : diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c index 945d21647f..ef0d6266fd 100644 --- a/gdb/dwarf2-frame.c +++ b/gdb/dwarf2-frame.c @@ -1105,8 +1105,8 @@ read_signed_leb128 (bfd *abfd, gdb_byte *buf, unsigned int *bytes_read_ptr) } while (byte & 0x80); - if ((shift < 32) && (byte & 0x40)) - result |= -(1 << shift); + if (shift < 8 * sizeof (result) && (byte & 0x40)) + result |= -(((LONGEST)1) << shift); *bytes_read_ptr = num_read; diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index eb6cec91f6..ae85ef3554 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -6032,12 +6032,11 @@ static long read_signed_leb128 (bfd *abfd, char *buf, unsigned int *bytes_read_ptr) { long result; - int i, shift, size, num_read; + int i, shift, num_read; unsigned char byte; result = 0; shift = 0; - size = 32; num_read = 0; i = 0; while (1) @@ -6052,10 +6051,8 @@ read_signed_leb128 (bfd *abfd, char *buf, unsigned int *bytes_read_ptr) break; } } - if ((shift < size) && (byte & 0x40)) - { - result |= -(1 << shift); - } + if ((shift < 8 * sizeof (result)) && (byte & 0x40)) + result |= -(((long)1) << shift); *bytes_read_ptr = num_read; return result; } -- 2.11.0