From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5843 invoked by alias); 12 Jul 2013 16:23:38 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 5805 invoked by uid 89); 12 Jul 2013 16:23:38 -0000 X-Spam-SWARE-Status: No, score=0.8 required=5.0 tests=KHOP_RCVD_UNTRUST,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RDNS_NONE,TW_FX,URIBL_BLOCKED autolearn=no version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from Unknown (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 12 Jul 2013 16:23:37 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1Uxg81-0002dI-Hg from Maciej_Rozycki@mentor.com ; Fri, 12 Jul 2013 09:23:29 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 12 Jul 2013 09:23:29 -0700 Received: from [172.30.64.236] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.2.247.3; Fri, 12 Jul 2013 17:23:28 +0100 Date: Fri, 12 Jul 2013 16:23:00 -0000 From: "Maciej W. Rozycki" To: Richard Sandiford CC: , Subject: [PATCH] MIPS: Define descriptive names for GNU attribute values Message-ID: User-Agent: Alpine 1.10 (DEB 962 2008-03-14) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-SW-Source: 2013-07/txt/msg00335.txt.bz2 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 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 */