From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14928 invoked by alias); 26 Dec 2004 00:42:35 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 14909 invoked from network); 26 Dec 2004 00:42:30 -0000 Received: from unknown (HELO rwcrmhc12.comcast.net) (216.148.227.85) by sourceware.org with SMTP; 26 Dec 2004 00:42:30 -0000 Received: from lucon.org ([24.6.212.230]) by comcast.net (rwcrmhc12) with ESMTP id <20041226004229014000bac2e>; Sun, 26 Dec 2004 00:42:29 +0000 Received: by lucon.org (Postfix, from userid 1000) id 462CB63DD3; Sat, 25 Dec 2004 16:42:29 -0800 (PST) Date: Sun, 26 Dec 2004 00:42:00 -0000 From: "H. J. Lu" To: binutils@sources.redhat.com Subject: PATCH: Fix read_leb128 in readelf for 64bit host Message-ID: <20041226004229.GA6483@lucon.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i X-SW-Source: 2004-12/txt/msg00307.txt.bz2 read_leb128 in readelf assumes long == int == 32bit. It doesn't work with 64bit host. Does this patch look right? H.J. --- 2004-12-25 H.J. Lu * readelf.c (read_leb128): Support 64bit host. --- binutils/readelf.c.leb 2004-12-10 14:20:22.000000000 -0800 +++ binutils/readelf.c 2004-12-25 16:16:54.615198445 -0800 @@ -6933,7 +6933,7 @@ read_leb128 (unsigned char *data, int *l { unsigned long int result = 0; unsigned int num_read = 0; - int shift = 0; + unsigned int shift = 0; unsigned char byte; do @@ -6951,8 +6951,8 @@ read_leb128 (unsigned char *data, int *l 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; }