This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: handle address overflow in objdump disassembly
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Tristan Gingold <gingold at adacore dot com>
- Cc: binutils at sourceware dot org
- Date: Mon, 10 Nov 2008 19:14:26 +1030
- Subject: Re: PATCH: handle address overflow in objdump disassembly
- References: <44EA31C9-99A7-44B2-AF33-69AD58837331@adacore.com>
On Thu, Nov 06, 2008 at 04:37:28PM +0100, Tristan Gingold wrote:
> * objdump.c (disassemble_bytes): Do not skip leadin zero in case of
> overflow.
Let's simplify this code while we're at it.
* objdump.c (disassemble_bytes): Don't skip leading zeros when
end of section calculation overflows.
Index: binutils/objdump.c
===================================================================
RCS file: /cvs/src/src/binutils/objdump.c,v
retrieving revision 1.146
diff -u -p -r1.146 objdump.c
--- binutils/objdump.c 28 Aug 2008 16:05:03 -0000 1.146
+++ binutils/objdump.c 10 Nov 2008 05:44:11 -0000
@@ -1372,19 +1372,18 @@ disassemble_bytes (struct disassemble_in
if (! prefix_addresses)
{
char buf[30];
- char *s;
- bfd_sprintf_vma
- (aux->abfd, buf,
- (section->vma
- + bfd_section_size (section->owner, section) / opb));
- s = buf;
- while (s[0] == '0' && s[1] == '0' && s[2] == '0' && s[3] == '0'
- && s[4] == '0')
- {
- skip_addr_chars += 4;
- s += 4;
- }
+ bfd_sprintf_vma (aux->abfd, buf, section->vma + section->size / opb);
+
+ while (buf[skip_addr_chars] == '0')
+ ++skip_addr_chars;
+
+ /* Don't discard zeros on overflow. */
+ if (buf[skip_addr_chars] == '\0' && section->vma != 0)
+ skip_addr_chars = 0;
+
+ if (skip_addr_chars != 0)
+ skip_addr_chars = (skip_addr_chars - 1) & -4;
}
info->insn_info_valid = 0;
--
Alan Modra
Australia Development Lab, IBM