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: Word size confusion in display_debug_ranges() in binutils-2.18/binutils/dwarf.c


On Mon, Jan 28, 2008 at 10:23:12PM +0100, Julian Seward wrote:
> Looking at binutils-2.18/binutils/dwarf.c:2780 it's obvious why:
> 
>               /* Check base address specifiers.  */
>               if (begin == -1UL && end != -1UL)
>                 {
>                   base_address = end;
>                   printf ("    %8.8lx %8.8lx %8.8lx (base address)\n",
>                           offset, begin, end);
>                   continue;
>                 }
> 
> Comparison against -1UL is at the host's word size.  But the DWARF3 spec
> sec 2.17.3 ("Non-Contiguous Address Ranges") gives the impression, although
> does not make it absolutely clear, that said values (begin, end) have a word 
> size appropriate for the object file, not the host.

Yes, you're correct.  A 64-bit readelf will fail dumping a 32-bit
object.

> It would also mean that lines 2769, 2771 are bogus:

Yes.  There are many places where a 32-bit readelf can fail to dump a
64-bit object file correctly.  This patch doesn't even attempt to fix
them..

	* dwarf.c (display_debug_loc): Correct test for base address
	entry when 64-bit host dumping 32-bit object.

Index: binutils/dwarf.c
===================================================================
RCS file: /cvs/src/src/binutils/dwarf.c,v
retrieving revision 1.27
diff -u -p -r1.27 dwarf.c
--- binutils/dwarf.c	28 Jan 2008 15:15:32 -0000	1.27
+++ binutils/dwarf.c	29 Jan 2008 02:41:43 -0000
@@ -2618,6 +2618,7 @@ display_debug_loc (struct dwarf_section 
     {
       unsigned long begin;
       unsigned long end;
+      unsigned long minus_one;
       unsigned short length;
       unsigned long offset;
       unsigned int pointer_size;
@@ -2678,7 +2679,10 @@ display_debug_loc (struct dwarf_section 
 		}
 
 	      /* Check base address specifiers.  */
-	      if (begin == -1UL && end != -1UL)
+	      minus_one = -1;
+	      if (pointer_size < sizeof (minus_one))
+		minus_one = (1L << (pointer_size * 8)) - 1;
+	      if (begin == minus_one && end != minus_one)
 		{
 		  base_address = end;
 		  printf (_("    %8.8lx %8.8lx %8.8lx (base address)\n"),

-- 
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]