From: "H. J. Lu" <hjl@lucon.org>
To: binutils@sources.redhat.com
Subject: PATCH: Fix read_leb128 in readelf for 64bit host
Date: Sun, 26 Dec 2004 00:42:00 -0000 [thread overview]
Message-ID: <20041226004229.GA6483@lucon.org> (raw)
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 <hongjiu.lu@intel.com>
* 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;
}
next reply other threads:[~2004-12-26 0:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-26 0:42 H. J. Lu [this message]
2004-12-27 19:01 ` H. J. Lu
2004-12-28 13:15 ` Dave Korn
2004-12-28 14:57 ` Daniel Jacobowitz
2004-12-28 20:48 ` Dave Korn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20041226004229.GA6483@lucon.org \
--to=hjl@lucon.org \
--cc=binutils@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).