This is the mail archive of the binutils@sources.redhat.com 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: fix dwarf2 handling of signed addresses


I reported yesterday that addr2line doesn't work correctly for MIPS
kernel addresses because sign extending of addresses is done
inconsistently.

The attached patch fixes that problem.  I can't apply it (no write
privs -- but I do have a copyright assignment in place).

      paul

2005-07-08  Paul Koning  <pkoning@equallogic.com>

	* dwarf2.c (read_address): Check sign_extend_vma to handle targets
	where addresses are sign extended.

Index: dwarf2.c
===================================================================
RCS file: /cvs/src/src/bfd/dwarf2.c,v
retrieving revision 1.75
diff -u -r1.75 dwarf2.c
--- dwarf2.c	6 Jul 2005 13:43:21 -0000	1.75
+++ dwarf2.c	8 Jul 2005 15:36:38 -0000
@@ -347,16 +347,35 @@
 static bfd_uint64_t
 read_address (struct comp_unit *unit, bfd_byte *buf)
 {
-  switch (unit->addr_size)
+  int signed_vma = get_elf_backend_data (unit->abfd)->sign_extend_vma;
+
+  if (signed_vma)
     {
-    case 8:
-      return bfd_get_64 (unit->abfd, buf);
-    case 4:
-      return bfd_get_32 (unit->abfd, buf);
-    case 2:
-      return bfd_get_16 (unit->abfd, buf);
-    default:
-      abort ();
+      switch (unit->addr_size)
+	{
+	case 8:
+	  return bfd_get_signed_64 (unit->abfd, buf);
+	case 4:
+	  return bfd_get_signed_32 (unit->abfd, buf);
+	case 2:
+	  return bfd_get_signed_16 (unit->abfd, buf);
+	default:
+	  abort ();
+	}
+    }
+  else
+    {
+      switch (unit->addr_size)
+	{
+	case 8:
+	  return bfd_get_64 (unit->abfd, buf);
+	case 4:
+	  return bfd_get_32 (unit->abfd, buf);
+	case 2:
+	  return bfd_get_16 (unit->abfd, buf);
+	default:
+	  abort ();
+	}
     }
 }
 


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