This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: handle address overflow in objdump disassembly


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]