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]

[PATCH] Support DWARF 2.1 extensions in readelf


DWARF V2.1 (see http://www.eagercon.com/dwarf2std.htm ) adds a number
of new tags and attributes to DWARF 2.

Here are patches for readelf.c and dwarf2.h (against 2.11.2) to
support dumping these new attributes in readable form.

These DWARF 2.1 features are already in use in some compilers; for
instance Intel's Linux compilers use them...

Enjoy

-- Jim 

James Cownie	<jcownie@etnus.com>
Etnus, LLC.     +44 117 9071438
http://www.etnus.com


jcownie@pc2: diff -u ~/binutils-2.11.2/binutils/readelf.c readelf.c 
--- /home1/jim/binutils-2.11.2/binutils/readelf.c	Mon May 28 19:34:24 2001
+++ readelf.c	Fri Jun 29 10:29:38 2001
@@ -5896,6 +5896,20 @@
     case DW_AT_variable_parameter: return "DW_AT_variable_parameter";
     case DW_AT_virtuality: return "DW_AT_virtuality";
     case DW_AT_vtable_elem_location: return "DW_AT_vtable_elem_location";
+    /* DWARF 2.1 values */
+    case DW_AT_allocated: return "DW_AT_allocated";
+    case DW_AT_associated: return "DW_AT_associated";
+    case DW_AT_data_location: return "DW_AT_data_location";
+    case DW_AT_stride: return "DW_AT_stride";
+    case DW_AT_entry_pc: return "DW_AT_entry_pc";
+    case DW_AT_use_UTF8: return "DW_AT_use_UTF8";
+    case DW_AT_extension: return "DW_AT_extension";
+    case DW_AT_ranges: return "DW_AT_ranges";
+    case DW_AT_trampoline: return "DW_AT_trampoline";
+    case DW_AT_call_column: return "DW_AT_call_column";
+    case DW_AT_call_file: return "DW_AT_call_file";
+    case DW_AT_call_line: return "DW_AT_call_line";
+
     case DW_AT_MIPS_fde: return "DW_AT_MIPS_fde";
     case DW_AT_MIPS_loop_begin: return "DW_AT_MIPS_loop_begin";
     case DW_AT_MIPS_tail_loop_begin: return "DW_AT_MIPS_tail_loop_begin";
@@ -6471,7 +6485,20 @@
 	case DW_OP_nop:
 	  printf ("DW_OP_nop");
 	  break;
-
+	case DW_OP_push_object_address:
+	  printf ("DW_OP_push_object_address");
+	  break;
+	case DW_OP_call2:
+	  printf ("DW_OP_call2: <%lx>", (long) byte_get (data, 2));
+	  data += 2;
+	  break;
+	case DW_OP_call4:
+	  printf ("DW_OP_call4: <%lx>", (long) byte_get (data, 4));
+	  data += 4;
+	  break;
+	case DW_OP_calli:
+	  printf ("DW_OP_calli");
+	  break;
 	default:
 	  if (op >= DW_OP_lo_user
 	      && op <= DW_OP_hi_user)
@@ -6481,6 +6508,7 @@
 	  /* No way to tell where the next op is, so just bail.  */
 	  return;
 	}
+      printf ("; ");				/* Separate the ops ! */
     }
 }
 
@@ -6725,10 +6753,25 @@
 	}
       break;
 
+    case DW_AT_ordering:
+      switch (uvalue)
+	{
+	case -1: printf ("(undefined)"); break;
+	case 0:  printf ("(row major)"); break;
+	case 1:  printf ("(column major)"); break;
+	}
+      break;
+
     case DW_AT_frame_base:
     case DW_AT_location:
     case DW_AT_data_member_location:
     case DW_AT_vtable_elem_location:
+    case DW_AT_allocated:
+    case DW_AT_associated:
+    case DW_AT_data_location:
+    case DW_AT_stride:
+    case DW_AT_upper_bound:
+    case DW_AT_lower_bound:
       if (block_start)
 	{
 	  printf ("(");
jcownie@pc2: diff -u ~/binutils-2.11.2/include/elf/dwarf2.h ../include/elf/dwarf2.h
--- /home1/jim/binutils-2.11.2/include/elf/dwarf2.h	Thu Jun  7 04:21:39 2001
+++ ../include/elf/dwarf2.h	Fri Jun 29 10:17:15 2001
@@ -279,6 +279,19 @@
     DW_AT_variable_parameter = 0x4b,
     DW_AT_virtuality = 0x4c,
     DW_AT_vtable_elem_location = 0x4d,
+    /* DWARF 2.1 values */
+    DW_AT_allocated     = 0x4e,
+    DW_AT_associated    = 0x4f,
+    DW_AT_data_location = 0x50,
+    DW_AT_stride        = 0x51,
+    DW_AT_entry_pc      = 0x52,
+    DW_AT_use_UTF8      = 0x53,
+    DW_AT_extension     = 0x54,
+    DW_AT_ranges        = 0x55,
+    DW_AT_trampoline    = 0x56,
+    DW_AT_call_column   = 0x57,
+    DW_AT_call_file     = 0x58,
+    DW_AT_call_line     = 0x59,
     /* SGI/MIPS Extensions */
     DW_AT_MIPS_fde = 0x2001,
     DW_AT_MIPS_loop_begin = 0x2002,
@@ -451,7 +464,11 @@
     DW_OP_piece = 0x93,
     DW_OP_deref_size = 0x94,
     DW_OP_xderef_size = 0x95,
-    DW_OP_nop = 0x96
+    DW_OP_nop = 0x96,
+    DW_OP_push_object_address = 0x97, /* 0 */
+    DW_OP_call2   = 0x98, /* 1 2-byte offset of DIE */
+    DW_OP_call4   = 0x99, /* 1 4-byte offset of DIE */
+    DW_OP_calli   = 0x9a /* 0 */
   };
 
 #define DW_OP_lo_user	0x80	/* implementation-defined range start */
jcownie@pc2: 


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