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 to implement ISA numbers for GAS



This patch implements ISA numbers for powerpc GAS.  I don't think it's
quite ready to be committed yet, and in any case there's not yet
anything that can read the information it puts out; I'm posting it
so that people can comment.

[It also won't work with GCC because GCC on powerpc doesn't let GAS
output line number information.  I'll fix that just as soon as powerpc
GCC stops being broken.]

The ISA numbers I made up.  I'm not sure what values will be needed;
the collection I chose are just enough for the disassembler.  I've
only ported powerpc to output the new information; the patch won't
generate the new information (and thus be incompatible with old GDB
versions) unless dwarf2_set_isa is called in tc-*.

The idea behind dwarf2_set_isa is that it gets called from pseudo-ops
like .cpu, which it happens that the powerpc assembler doesn't have,
and at startup.

-- 
- Geoffrey Keating <geoffk@geoffk.org> <geoffk@redhat.com>

===File ~/patches/cygnus/gas-dwarfisa.patch=================
Index: include/elf/ChangeLog
2001-11-13  Geoff Keating  <geoffk@redhat.com>

	* ppc.h: Define some local DWARF 3 ISA numbers.

Index: gas/ChangeLog
2001-11-13  Geoff Keating  <geoffk@redhat.com>

	* config/tc-ppc.c (md_begin) [OBJ_ELF]: Call dwarf2_set_isa.

	* dwarf2dbg.h (struct dwarf2_line_info): Add 'isa' field.
	(dwarf2_set_isa): New prototype.
	* dwarf2dbg.c (DWARF2_LINE_OPCODE_BASE): Increase to 13.
	(dwarf2_where): Save the current ISA.
	(dwarf2_set_isa): New function.
	(process_entries): Output DW_LNS_set_isa if we have ISA information.
	(out_debug_line): Output the standard opcode lengths using
	a loop.

Index: binutils/ChangeLog
2001-11-13  Geoff Keating  <geoffk@redhat.com>

	* readelf.c (display_debug_lines): Print ISA value in hex.

Index: include/elf/ppc.h
===================================================================
RCS file: /cvs/src/src/include/elf/ppc.h,v
retrieving revision 1.6
diff -p -u -u -p -r1.6 ppc.h
--- ppc.h	2001/08/27 10:26:34	1.6
+++ ppc.h	2001/11/14 03:24:40
@@ -194,4 +194,16 @@ END_RELOC_NUMBERS (R_PPC_max)
 						   builds when those objects \
 						   are not to be furhter \
 						   relocated.  */
+
+/* DWARF3 ISA numbers (local to the GNU tools).  */
+enum {
+  /* The base PPC ISA plus Altivec, 403, 601, and anything else that
+     doesn't clash.  */
+  DW_ISA_PPCGNU_PPC_DEFAULT = 0xd50000,
+  /* The POWER ISA. */
+  DW_ISA_PPCGNU_POWER,
+  /* The base PPC ISA plus Book E.  */
+  DW_ISA_PPCGNU_BOOKE
+};
+
 #endif /* _ELF_PPC_H */
Index: gas/dwarf2dbg.c
===================================================================
RCS file: /cvs/src/src/gas/dwarf2dbg.c,v
retrieving revision 1.42
diff -p -u -u -p -r1.42 dwarf2dbg.c
--- dwarf2dbg.c	2001/09/18 10:08:14	1.42
+++ dwarf2dbg.c	2001/11/14 03:24:48
@@ -56,11 +56,8 @@
 #define DL_FILES	1
 #define DL_BODY		2
 
-/* First special line opcde - leave room for the standard opcodes.
-   Note: If you want to change this, you'll have to update the
-   "standard_opcode_lengths" table that is emitted below in
-   dwarf2_finish().  */
-#define DWARF2_LINE_OPCODE_BASE		10
+/* First special line opcde - leave room for the standard opcodes.  */
+#define DWARF2_LINE_OPCODE_BASE		13
 
 #ifndef DWARF2_LINE_BASE
   /* Minimum line offset in a special line info. opcode.  This value
@@ -257,6 +254,7 @@ dwarf2_where (line)
       line->filenum = get_filenum (filename);
       line->column = 0;
       line->flags = DWARF2_FLAG_BEGIN_STMT;
+      line->isa = current.isa;
     }
   else
     *line = current;
@@ -404,6 +402,22 @@ dwarf2_directive_loc (dummy)
     listing_source_line (line);
 #endif
 }
+
+/* Set the current ISA.  This is called in two situations:
+   - Before the start of assembly, when the assembler has finished
+     processing its arguments, to set the ISA at the start of the
+     assembly; and
+   - When the assembler encounters a directive which changes the
+     ISA in use.
+*/
+
+void 
+dwarf2_set_isa (new_isa)
+     unsigned long new_isa;
+{
+  current.isa = new_isa;
+  loc_directive_seen = true;
+}
 
 static struct frag *
 first_frag_for_seg (seg)
@@ -833,6 +847,7 @@ process_entries (seg, e)
   unsigned filenum = 1;
   unsigned line = 1;
   unsigned column = 0;
+  unsigned long isa = 0;
   unsigned flags = DWARF2_LINE_DEFAULT_IS_STMT ? DWARF2_FLAG_BEGIN_STMT : 0;
   fragS *frag = NULL;
   fragS *last_frag;
@@ -844,6 +859,14 @@ process_entries (seg, e)
     {
       int changed = 0;
 
+      if (isa != e->loc.isa)
+	{
+	  isa = e->loc.isa;
+	  out_opcode (DW_LNS_set_isa);
+	  out_uleb128 (isa);
+	  changed = 1;
+	}
+
       if (filenum != e->loc.filenum)
 	{
 	  filenum = e->loc.filenum;
@@ -961,6 +984,7 @@ out_debug_line (line_seg)
   symbolS *prologue_end;
   symbolS *line_end;
   struct line_seg *s;
+  int opc;
 
   subseg_set (line_seg, 0);
 
@@ -993,15 +1017,23 @@ out_debug_line (line_seg)
   out_byte (DWARF2_LINE_OPCODE_BASE);
 
   /* Standard opcode lengths.  */
-  out_byte (0);			/* DW_LNS_copy */
-  out_byte (1);			/* DW_LNS_advance_pc */
-  out_byte (1);			/* DW_LNS_advance_line */
-  out_byte (1);			/* DW_LNS_set_file */
-  out_byte (1);			/* DW_LNS_set_column */
-  out_byte (0);			/* DW_LNS_negate_stmt */
-  out_byte (0);			/* DW_LNS_set_basic_block */
-  out_byte (0);			/* DW_LNS_const_add_pc */
-  out_byte (1);			/* DW_LNS_fixed_advance_pc */
+  for (opc = 1; opc < DWARF2_LINE_OPCODE_BASE; ++opc)
+    {
+      switch (opc)
+	{
+	case DW_LNS_advance_pc:
+	case DW_LNS_advance_line:
+	case DW_LNS_set_file:
+	case DW_LNS_set_column:
+	case DW_LNS_fixed_advance_pc:
+	case DW_LNS_set_isa:
+	  out_byte (1);
+	  break;
+	default:
+	  out_byte (0);
+	  break;
+	}
+    }
 
   out_file_list ();
 
Index: gas/dwarf2dbg.h
===================================================================
RCS file: /cvs/src/src/gas/dwarf2dbg.h,v
retrieving revision 1.10
diff -p -u -u -p -r1.10 dwarf2dbg.h
--- dwarf2dbg.h	2001/03/08 23:24:22	1.10
+++ dwarf2dbg.h	2001/11/14 03:24:48
@@ -31,6 +31,7 @@ struct dwarf2_line_info {
   unsigned int line;
   unsigned int column;
   unsigned int flags;
+  unsigned long isa;
 };
 
 /* Implements the .file FILENO "FILENAME" directive.  FILENO can be 0
@@ -45,6 +46,15 @@ extern void dwarf2_directive_file PARAMS
    specified by the textually most recent .file directive should be
    used.  */
 extern void dwarf2_directive_loc PARAMS ((int dummy));
+
+/* Set the current ISA.  This is called in two situations:
+   - Before the start of assembly, when the assembler has finished
+     processing its arguments, to set the ISA at the start of the
+     assembly; and
+   - When the assembler encounters a directive which changes the
+     ISA in use.
+*/
+extern void dwarf2_set_isa PARAMS ((unsigned long new_isa));
 
 /* Returns the current source information.  If .file directives have
    been encountered, the info for the corresponding source file is
Index: gas/config/tc-ppc.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-ppc.c,v
retrieving revision 1.38
diff -p -u -u -p -r1.38 tc-ppc.c
--- tc-ppc.c	2001/10/17 13:13:15	1.38
+++ tc-ppc.c	2001/11/14 03:24:50
@@ -1157,6 +1157,14 @@ md_begin ()
   /* Set the ELF flags if desired.  */
   if (ppc_flags && !msolaris)
     bfd_set_private_flags (stdoutput, ppc_flags);
+
+  /* Set the DWARF3 ISA number.  */
+  if ((ppc_cpu & PPC_OPCODE_POWER) && ! (ppc_cpu & PPC_OPCODE_PPC) )
+    dwarf2_set_isa (DW_ISA_PPCGNU_POWER);
+  else if (ppc_cpu & PPC_OPCODE_BOOKE)
+    dwarf2_set_isa (DW_ISA_PPCGNU_BOOKE);
+  else
+    dwarf2_set_isa (DW_ISA_PPCGNU_PPC_DEFAULT);
 #endif
 
   /* Insert the opcodes into a hash table.  */
Index: binutils/readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.133
diff -p -u -u -p -r1.133 readelf.c
--- readelf.c	2001/11/13 23:36:38	1.133
+++ readelf.c	2001/11/14 03:24:56
@@ -5980,9 +5980,9 @@ display_debug_lines (section, start, fil
 	      break;
 	      
 	    case DW_LNS_set_isa:
-	      adv = read_leb128 (data, & bytes_read, 0);
+	      printf (_("  Set ISA to 0x%lx\n"), 
+		      read_leb128 (data, & bytes_read, 0));
 	      data += bytes_read;
-	      printf (_("  Set ISA to %d\n"), adv);
 	      break;
 	      
 	    default:
============================================================


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