This is the mail archive of the binutils-cvs@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]

[binutils-gdb] binutils/riscv: Register names in DWARF output


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5bb0830d10b19230f9615694fa3c1230b32794b9

commit 5bb0830d10b19230f9615694fa3c1230b32794b9
Author: Andrew Burgess <andrew.burgess@embecosm.com>
Date:   Fri Feb 2 15:25:31 2018 +0000

    binutils/riscv: Register names in DWARF output
    
    Adds a register name table for RiscV so that objdump and readelf can
    both use better register names.
    
    binutils/ChangeLog:
    
    	* dwarf.c (dwarf_regnames_riscv): New register name table.
    	(init_dwarf_regnames_riscv): New function.
    	(init_dwarf_regnames): Add call to initialise RiscV register
    	names.
    	* dwarf.h (init_dwarf_regnames_riscv): Declare.
    	* objdump.c (dump_dwarf): Add call to initialise RiscV register
    	names.

Diff:
---
 binutils/ChangeLog | 10 ++++++++++
 binutils/dwarf.c   | 25 +++++++++++++++++++++++++
 binutils/dwarf.h   |  1 +
 binutils/objdump.c |  4 ++++
 4 files changed, 40 insertions(+)

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 5f47273..80b4acc 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,13 @@
+2018-02-02  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+	* dwarf.c (dwarf_regnames_riscv): New register name table.
+	(init_dwarf_regnames_riscv): New function.
+	(init_dwarf_regnames): Add call to initialise RiscV register
+	names.
+	* dwarf.h (init_dwarf_regnames_riscv): Declare.
+	* objdump.c (dump_dwarf): Add call to initialise RiscV register
+	names.
+
 2018-02-01  Alan Modra  <amodra@gmail.com>
 
 	PR 22769
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 6dee8aa..71fdf39 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -7065,6 +7065,27 @@ init_dwarf_regnames_s390 (void)
   dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_s390);
 }
 
+static const char *const dwarf_regnames_riscv[] =
+{
+ "zero", "ra",   "sp",   "gp",  "tp",  "t0",  "t1",  "t2",  /* 0  - 7 */
+ "s0",   "s1",   "a0",   "a1",  "a2",  "a3",  "a4",  "a5",  /* 8  - 15 */
+ "a6",   "a7",   "s2",   "s3",  "s4",  "s5",  "s6",  "s7",  /* 16 - 23 */
+ "s8",   "s9",   "s10",  "s11", "t3",  "t4",  "t5",  "t6",  /* 24 - 31 */
+ "ft0",  "ft1",  "ft2",  "ft3", "ft4", "ft5", "ft6", "ft7", /* 32 - 39 */
+ "fs0",  "fs1",                                             /* 40 - 41 */
+ "fa0",  "fa1",  "fa2",  "fa3", "fa4", "fa5", "fa6", "fa7", /* 42 - 49 */
+ "fs2",  "fs3",  "fs4",  "fs5", "fs6", "fs7", "fs8", "fs9", /* 50 - 57 */
+ "fs10", "fs11",                                            /* 58 - 59 */
+ "ft8",  "ft9",  "ft10", "ft11"                             /* 60 - 63 */
+};
+
+void
+init_dwarf_regnames_riscv (void)
+{
+  dwarf_regnames = dwarf_regnames_riscv;
+  dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_riscv);
+}
+
 void
 init_dwarf_regnames (unsigned int e_machine)
 {
@@ -7092,6 +7113,10 @@ init_dwarf_regnames (unsigned int e_machine)
       init_dwarf_regnames_s390 ();
       break;
 
+    case EM_RISCV:
+      init_dwarf_regnames_riscv ();
+      break;
+
     default:
       break;
     }
diff --git a/binutils/dwarf.h b/binutils/dwarf.h
index 7f7c79d..34c2f5f 100644
--- a/binutils/dwarf.h
+++ b/binutils/dwarf.h
@@ -221,6 +221,7 @@ extern void init_dwarf_regnames_iamcu (void);
 extern void init_dwarf_regnames_x86_64 (void);
 extern void init_dwarf_regnames_aarch64 (void);
 extern void init_dwarf_regnames_s390 (void);
+extern void init_dwarf_regnames_riscv (void);
 
 extern bfd_boolean  load_debug_section (enum dwarf_section_display_enum, void *);
 extern void         free_debug_section (enum dwarf_section_display_enum);
diff --git a/binutils/objdump.c b/binutils/objdump.c
index d8dca90..37a9f0d 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -2732,6 +2732,10 @@ dump_dwarf (bfd *abfd)
       init_dwarf_regnames_s390 ();
       break;
 
+    case bfd_arch_riscv:
+      init_dwarf_regnames_riscv ();
+      break;
+
     default:
       break;
     }


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