This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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] MIPS: Define descriptive names for GNU attribute values


Hi,

 Here's a part of the discarded original IEEE 754-2008 NaN change I would 
like to salvage.  It adds new descriptive names for values of the 
GNU_MIPS_ABI_FP attribute, both for better code readability/greppability 
and to help avoiding issues as one corrected a while ago where textual 
references to certain attribute values were swapped in warning messages.

 No regressions in binutils testing; the change makes no functional 
changes.  OK (for the binutils part) to apply?

2013-07-12  Maciej W. Rozycki  <macro@codesourcery.com>

	include/elf/
	* mips.h (Tag_GNU_MIPS_ABI_FP): Remove comment.
	(Val_GNU_MIPS_ABI_FP_ANY, Val_GNU_MIPS_ABI_FP_DOUBLE,
	Val_GNU_MIPS_ABI_FP_SINGLE, Val_GNU_MIPS_ABI_FP_SOFT,
	Val_GNU_MIPS_ABI_FP_64): New enum.

	bfd/
	* elfxx-mips.c (mips_elf_merge_obj_attributes): Replace hardcoded
	magic numbers with enum values.

	binutils/
	* readelf.c (display_mips_gnu_attribute): Replace hardcoded magic
	numbers with enum values.

	gdb/
	* mips-tdep.c (mips_gdbarch_init): Replace hardcoded magic
	numbers with enum values.

  Maciej

binutils-mips-attribute-names.diff
Index: binutils-fsf-trunk-quilt/bfd/elfxx-mips.c
===================================================================
--- binutils-fsf-trunk-quilt.orig/bfd/elfxx-mips.c	2013-07-12 01:44:13.000000000 +0100
+++ binutils-fsf-trunk-quilt/bfd/elfxx-mips.c	2013-07-12 17:04:04.220393180 +0100
@@ -14316,7 +14316,7 @@ mips_elf_merge_obj_attributes (bfd *ibfd
 
   abi_fp_bfd = mips_elf_tdata (obfd)->abi_fp_bfd;
   in_attr = elf_known_obj_attributes (ibfd)[OBJ_ATTR_GNU];
-  if (!abi_fp_bfd && in_attr[Tag_GNU_MIPS_ABI_FP].i != 0)
+  if (!abi_fp_bfd && in_attr[Tag_GNU_MIPS_ABI_FP].i != Val_GNU_MIPS_ABI_FP_ANY)
     mips_elf_tdata (obfd)->abi_fp_bfd = ibfd;
 
   if (!elf_known_obj_attributes_proc (obfd)[0].i)
@@ -14337,27 +14337,27 @@ mips_elf_merge_obj_attributes (bfd *ibfd
   if (in_attr[Tag_GNU_MIPS_ABI_FP].i != out_attr[Tag_GNU_MIPS_ABI_FP].i)
     {
       out_attr[Tag_GNU_MIPS_ABI_FP].type = 1;
-      if (out_attr[Tag_GNU_MIPS_ABI_FP].i == 0)
+      if (out_attr[Tag_GNU_MIPS_ABI_FP].i == Val_GNU_MIPS_ABI_FP_ANY)
 	out_attr[Tag_GNU_MIPS_ABI_FP].i = in_attr[Tag_GNU_MIPS_ABI_FP].i;
-      else if (in_attr[Tag_GNU_MIPS_ABI_FP].i != 0)
+      else if (in_attr[Tag_GNU_MIPS_ABI_FP].i != Val_GNU_MIPS_ABI_FP_ANY)
 	switch (out_attr[Tag_GNU_MIPS_ABI_FP].i)
 	  {
-	  case 1:
+	  case Val_GNU_MIPS_ABI_FP_DOUBLE:
 	    switch (in_attr[Tag_GNU_MIPS_ABI_FP].i)
 	      {
-	      case 2:
+	      case Val_GNU_MIPS_ABI_FP_SINGLE:
 		_bfd_error_handler
 		  (_("Warning: %B uses %s (set by %B), %B uses %s"),
 		   obfd, abi_fp_bfd, ibfd, "-mdouble-float", "-msingle-float");
 		break;
 
-	      case 3:
+	      case Val_GNU_MIPS_ABI_FP_SOFT:
 		_bfd_error_handler
 		  (_("Warning: %B uses %s (set by %B), %B uses %s"),
 		   obfd, abi_fp_bfd, ibfd, "-mhard-float", "-msoft-float");
 		break;
 
-	      case 4:
+	      case Val_GNU_MIPS_ABI_FP_64:
 		_bfd_error_handler
 		  (_("Warning: %B uses %s (set by %B), %B uses %s"),
 		   obfd, abi_fp_bfd, ibfd,
@@ -14374,22 +14374,22 @@ mips_elf_merge_obj_attributes (bfd *ibfd
 	      }
 	    break;
 
-	  case 2:
+	  case Val_GNU_MIPS_ABI_FP_SINGLE:
 	    switch (in_attr[Tag_GNU_MIPS_ABI_FP].i)
 	      {
-	      case 1:
+	      case Val_GNU_MIPS_ABI_FP_DOUBLE:
 		_bfd_error_handler
 		  (_("Warning: %B uses %s (set by %B), %B uses %s"),
 		   obfd, abi_fp_bfd, ibfd, "-msingle-float", "-mdouble-float");
 		break;
 
-	      case 3:
+	      case Val_GNU_MIPS_ABI_FP_SOFT:
 		_bfd_error_handler
 		  (_("Warning: %B uses %s (set by %B), %B uses %s"),
 		   obfd, abi_fp_bfd, ibfd, "-mhard-float", "-msoft-float");
 		break;
 
-	      case 4:
+	      case Val_GNU_MIPS_ABI_FP_64:
 		_bfd_error_handler
 		  (_("Warning: %B uses %s (set by %B), %B uses %s"),
 		   obfd, abi_fp_bfd, ibfd,
@@ -14406,12 +14406,12 @@ mips_elf_merge_obj_attributes (bfd *ibfd
 	      }
 	    break;
 
-	  case 3:
+	  case Val_GNU_MIPS_ABI_FP_SOFT:
 	    switch (in_attr[Tag_GNU_MIPS_ABI_FP].i)
 	      {
-	      case 1:
-	      case 2:
-	      case 4:
+	      case Val_GNU_MIPS_ABI_FP_DOUBLE:
+	      case Val_GNU_MIPS_ABI_FP_SINGLE:
+	      case Val_GNU_MIPS_ABI_FP_64:
 		_bfd_error_handler
 		  (_("Warning: %B uses %s (set by %B), %B uses %s"),
 		   obfd, abi_fp_bfd, ibfd, "-msoft-float", "-mhard-float");
@@ -14427,24 +14427,24 @@ mips_elf_merge_obj_attributes (bfd *ibfd
 	      }
 	    break;
 
-	  case 4:
+	  case Val_GNU_MIPS_ABI_FP_64:
 	    switch (in_attr[Tag_GNU_MIPS_ABI_FP].i)
 	      {
-	      case 1:
+	      case Val_GNU_MIPS_ABI_FP_DOUBLE:
 		_bfd_error_handler
 		  (_("Warning: %B uses %s (set by %B), %B uses %s"),
 		   obfd, abi_fp_bfd, ibfd,
 		   "-mips32r2 -mfp64", "-mdouble-float");
 		break;
 
-	      case 2:
+	      case Val_GNU_MIPS_ABI_FP_SINGLE:
 		_bfd_error_handler
 		  (_("Warning: %B uses %s (set by %B), %B uses %s"),
 		   obfd, abi_fp_bfd, ibfd,
 		   "-mips32r2 -mfp64", "-msingle-float");
 		break;
 
-	      case 3:
+	      case Val_GNU_MIPS_ABI_FP_SOFT:
 		_bfd_error_handler
 		  (_("Warning: %B uses %s (set by %B), %B uses %s"),
 		   obfd, abi_fp_bfd, ibfd, "-mhard-float", "-msoft-float");
@@ -14463,7 +14463,7 @@ mips_elf_merge_obj_attributes (bfd *ibfd
 	  default:
 	    switch (in_attr[Tag_GNU_MIPS_ABI_FP].i)
 	      {
-	      case 1:
+	      case Val_GNU_MIPS_ABI_FP_DOUBLE:
 		_bfd_error_handler
 		  (_("Warning: %B uses unknown floating point ABI %d "
 		     "(set by %B), %B uses %s"),
@@ -14471,7 +14471,7 @@ mips_elf_merge_obj_attributes (bfd *ibfd
 		   out_attr[Tag_GNU_MIPS_ABI_FP].i, "-mdouble-float");
 		break;
 
-	      case 2:
+	      case Val_GNU_MIPS_ABI_FP_SINGLE:
 		_bfd_error_handler
 		  (_("Warning: %B uses unknown floating point ABI %d "
 		     "(set by %B), %B uses %s"),
@@ -14479,7 +14479,7 @@ mips_elf_merge_obj_attributes (bfd *ibfd
 		   out_attr[Tag_GNU_MIPS_ABI_FP].i, "-msingle-float");
 		break;
 
-	      case 3:
+	      case Val_GNU_MIPS_ABI_FP_SOFT:
 		_bfd_error_handler
 		  (_("Warning: %B uses unknown floating point ABI %d "
 		     "(set by %B), %B uses %s"),
@@ -14487,7 +14487,7 @@ mips_elf_merge_obj_attributes (bfd *ibfd
 		   out_attr[Tag_GNU_MIPS_ABI_FP].i, "-msoft-float");
 		break;
 
-	      case 4:
+	      case Val_GNU_MIPS_ABI_FP_64:
 		_bfd_error_handler
 		  (_("Warning: %B uses unknown floating point ABI %d "
 		     "(set by %B), %B uses %s"),
Index: binutils-fsf-trunk-quilt/binutils/readelf.c
===================================================================
--- binutils-fsf-trunk-quilt.orig/binutils/readelf.c	2013-07-12 01:44:13.000000000 +0100
+++ binutils-fsf-trunk-quilt/binutils/readelf.c	2013-07-12 17:04:04.220393180 +0100
@@ -11735,19 +11735,19 @@ display_mips_gnu_attribute (unsigned cha
 
       switch (val)
 	{
-	case 0:
+	case Val_GNU_MIPS_ABI_FP_ANY:
 	  printf (_("Hard or soft float\n"));
 	  break;
-	case 1:
+	case Val_GNU_MIPS_ABI_FP_DOUBLE:
 	  printf (_("Hard float (double precision)\n"));
 	  break;
-	case 2:
+	case Val_GNU_MIPS_ABI_FP_SINGLE:
 	  printf (_("Hard float (single precision)\n"));
 	  break;
-	case 3:
+	case Val_GNU_MIPS_ABI_FP_SOFT:
 	  printf (_("Soft float\n"));
 	  break;
-	case 4:
+	case Val_GNU_MIPS_ABI_FP_64:
 	  printf (_("Hard float (MIPS32r2 64-bit FPU)\n"));
 	  break;
 	default:
Index: binutils-fsf-trunk-quilt/gdb/mips-tdep.c
===================================================================
--- binutils-fsf-trunk-quilt.orig/gdb/mips-tdep.c	2013-07-12 01:44:13.000000000 +0100
+++ binutils-fsf-trunk-quilt/gdb/mips-tdep.c	2013-07-12 17:15:00.250967443 +0100
@@ -7909,7 +7909,7 @@ mips_gdbarch_init (struct gdbarch_info i
   int i, num_regs;
   enum mips_fpu_type fpu_type;
   struct tdesc_arch_data *tdesc_data = NULL;
-  int elf_fpu_type = 0;
+  int elf_fpu_type = Val_GNU_MIPS_ABI_FP_ANY;
   const char **reg_names;
   struct mips_regnum mips_regnum, *regnum;
   enum mips_isa mips_isa;
@@ -8234,17 +8234,17 @@ mips_gdbarch_init (struct gdbarch_info i
 
   if (!mips_fpu_type_auto)
     fpu_type = mips_fpu_type;
-  else if (elf_fpu_type != 0)
+  else if (elf_fpu_type != Val_GNU_MIPS_ABI_FP_ANY)
     {
       switch (elf_fpu_type)
 	{
-	case 1:
+	case Val_GNU_MIPS_ABI_FP_DOUBLE:
 	  fpu_type = MIPS_FPU_DOUBLE;
 	  break;
-	case 2:
+	case Val_GNU_MIPS_ABI_FP_SINGLE:
 	  fpu_type = MIPS_FPU_SINGLE;
 	  break;
-	case 3:
+	case Val_GNU_MIPS_ABI_FP_SOFT:
 	default:
 	  /* Soft float or unknown.  */
 	  fpu_type = MIPS_FPU_NONE;
Index: binutils-fsf-trunk-quilt/include/elf/mips.h
===================================================================
--- binutils-fsf-trunk-quilt.orig/include/elf/mips.h	2013-07-12 01:44:13.000000000 +0100
+++ binutils-fsf-trunk-quilt/include/elf/mips.h	2013-07-12 17:04:04.220393180 +0100
@@ -1129,11 +1129,30 @@ extern void bfd_mips_elf64_swap_reginfo_
 enum
 {
   /* 0-3 are generic.  */
-  Tag_GNU_MIPS_ABI_FP = 4, /* Value 1 for hard-float -mdouble-float, 2
-			      for hard-float -msingle-float, 3 for
-			      soft-float, 4 for -mips32r2 -mfp64; 0 for
-			      not tagged or not using any ABIs affected
-			      by the differences.  */
+
+  /* Floating-point ABI used by this object file.  */
+  Tag_GNU_MIPS_ABI_FP = 4,
+};
+
+/* Object attribute values.  */
+enum
+{
+  /* Values defined for Tag_GNU_MIPS_ABI_FP.  */
+
+  /* Not tagged or not using any ABIs affected by the differences.  */
+  Val_GNU_MIPS_ABI_FP_ANY = 0,
+
+  /* Using hard-float -mdouble-float.  */
+  Val_GNU_MIPS_ABI_FP_DOUBLE = 1,
+
+  /* Using hard-float -msingle-float.  */
+  Val_GNU_MIPS_ABI_FP_SINGLE = 2,
+
+  /* Using soft-float.  */
+  Val_GNU_MIPS_ABI_FP_SOFT = 3,
+
+  /* Using -mips32r2 -mfp64.  */
+  Val_GNU_MIPS_ABI_FP_64 = 4,
 };
 
 #endif /* _ELF_MIPS_H */


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