From 0c548fce692d32ea292cd72ff8266005f758e316 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Mon, 27 Dec 2004 19:08:31 +0000 Subject: [PATCH] 2004-12-27 H.J. Lu * readelf.c (read_leb128): Support 64bit host. --- binutils/ChangeLog | 4 ++++ binutils/readelf.c | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index f418f997926..80fe241662b 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,7 @@ +2004-12-27 H.J. Lu + + * readelf.c (read_leb128): Support 64bit host. + 2004-12-22 Nick Clifton * readelf.c (last_pointer_size, warned_about_missing_comp_units): diff --git a/binutils/readelf.c b/binutils/readelf.c index 36103765da9..6cecdc34804 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -6933,7 +6933,7 @@ read_leb128 (unsigned char *data, int *length_return, int sign) { unsigned long int result = 0; unsigned int num_read = 0; - int shift = 0; + unsigned int shift = 0; unsigned char byte; do @@ -6941,7 +6941,7 @@ read_leb128 (unsigned char *data, int *length_return, int sign) byte = *data++; num_read++; - result |= (byte & 0x7f) << shift; + result |= ((unsigned long int) (byte & 0x7f)) << shift; shift += 7; @@ -6951,8 +6951,8 @@ read_leb128 (unsigned char *data, int *length_return, int sign) if (length_return != NULL) *length_return = num_read; - if (sign && (shift < 32) && (byte & 0x40)) - result |= -1 << shift; + if (sign && (shift < 8 * sizeof (result)) && (byte & 0x40)) + result |= -1L << shift; return result; } -- 2.30.2