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]

[PATCH] Properly sign-extend DWARF address ranges


This is a simple follow-up to
http://sourceware.org/ml/binutils/2007-08/msg00344.html.

addr2line is not working on a MIPS64 -msym32 Linux kernel that uses ranges to
describe compilation units.

read_address already knows how to sign-extend addresses if the bfd target
prescribes that.  read_address is already used for DW_FORM_addr
i.e. DW_AT_{low,high}_pc but not for ranges.  The patch below adjusts that.

Tested with mipsisa664r2-elfoabi with gas, ld and binutils.

OK to install?

Adam

	* dwarf2.c: Update copyright year.
	(read_rangelist): Use read_address to read low_pc and high_pc in order
	to properly sign-extend VMAs.

Index: dwarf2.c
===================================================================
RCS file: /cvs/src/src/bfd/dwarf2.c,v
retrieving revision 1.116
diff -u -p -r1.116 dwarf2.c
--- dwarf2.c	18 Nov 2008 14:05:00 -0000	1.116
+++ dwarf2.c	30 Jan 2009 00:16:32 -0000
@@ -1,6 +1,6 @@
 /* DWARF 2 support.
    Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-   2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 
    Adapted from gdb/dwarf2read.c by Gavin Koch of Cygnus Solutions
    (gavin@cygnus.com).
@@ -1803,20 +1803,11 @@ read_rangelist (struct comp_unit *unit, 
       bfd_vma low_pc;
       bfd_vma high_pc;
 
-      if (unit->addr_size == 4)
-	{
-	  low_pc = read_4_bytes (unit->abfd, ranges_ptr);
-	  ranges_ptr += 4;
-	  high_pc = read_4_bytes (unit->abfd, ranges_ptr);
-	  ranges_ptr += 4;
-	}
-      else
-	{
-	  low_pc = read_8_bytes (unit->abfd, ranges_ptr);
-	  ranges_ptr += 8;
-	  high_pc = read_8_bytes (unit->abfd, ranges_ptr);
-	  ranges_ptr += 8;
-	}
+      low_pc = read_address (unit, ranges_ptr);
+      ranges_ptr += unit->addr_size;
+      high_pc = read_address (unit, ranges_ptr);
+      ranges_ptr += unit->addr_size;
+
       if (low_pc == 0 && high_pc == 0)
 	break;
       if (low_pc == -1UL && high_pc != -1UL)


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