From ba92f8875272b3d30872644d5305868ff4d047b8 Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Fri, 12 Jul 2013 15:58:15 +0000 Subject: [PATCH] include/elf/ * mips.h (EF_MIPS_NAN2008): New macro. bfd/ * elfxx-mips.c (_bfd_mips_elf_merge_private_bfd_data): Handle EF_MIPS_NAN2008. (_bfd_mips_elf_print_private_bfd_data): Likewise. binutils/ * readelf.c (get_machine_flags): Handle EF_MIPS_NAN2008. gas/ * config/tc-mips.c (mips_flag_nan2008): New variable. (options): Add OPTION_NAN enum value. (md_longopts): Handle it. (md_parse_option): Likewise. (s_nan): New function. (mips_elf_final_processing): Handle EF_MIPS_NAN2008. (md_show_usage): Add -mnan. * doc/as.texinfo (Overview): Add -mnan. * doc/c-mips.texi (MIPS Opts): Document -mnan. (MIPS NaN Encodings): New node. Document .nan directive. (MIPS-Dependent): List the new node. gas/testsuite/ * gas/mips/nan-2008-1.d: New test. * gas/mips/nan-2008-2.d: New test. * gas/mips/nan-2008-3.d: New test. * gas/mips/nan-2008-4.d: New test. * gas/mips/nan-legacy-1.d: New test. * gas/mips/nan-legacy-2.d: New test. * gas/mips/nan-legacy-3.d: New test. * gas/mips/nan-legacy-4.d: New test. * gas/mips/nan-legacy-5.d: New test. * gas/mips/nan-error-1.l: New list test. * gas/mips/nan-error-2.l: New list test. * gas/mips/nan-2008-override.s: New test source. * gas/mips/nan-2008.s: New test source. * gas/mips/nan-legacy-override.s: New test source. * gas/mips/nan-legacy.s: New test source. * gas/mips/nan-error-1.s: New test source. * gas/mips/nan-error-2.s: New test source. * gas/mips/mips.exp: Run the new tests. ld/testsuite/ * ld-mips-elf/nan-2008.d: New test. * ld-mips-elf/nan-legacy.d: New test. * ld-mips-elf/nan-mixed-1.d: New test. * ld-mips-elf/nan-mixed-2.d: New test. * ld-mips-elf/nan-2008.s: New test source. * ld-mips-elf/nan-legacy.s: New test source. --- bfd/ChangeLog | 6 ++ bfd/elfxx-mips.c | 17 ++++++ binutils/ChangeLog | 4 ++ binutils/readelf.c | 3 + gas/ChangeLog | 15 +++++ gas/config/tc-mips.c | 58 +++++++++++++++++++- gas/doc/as.texinfo | 5 ++ gas/doc/c-mips.texi | 52 ++++++++++++++++++ gas/testsuite/ChangeLog | 21 +++++++ gas/testsuite/gas/mips/mips.exp | 14 +++++ gas/testsuite/gas/mips/nan-2008-1.d | 6 ++ gas/testsuite/gas/mips/nan-2008-2.d | 7 +++ gas/testsuite/gas/mips/nan-2008-3.d | 6 ++ gas/testsuite/gas/mips/nan-2008-4.d | 7 +++ gas/testsuite/gas/mips/nan-2008-override.s | 2 + gas/testsuite/gas/mips/nan-2008.s | 1 + gas/testsuite/gas/mips/nan-error-1.l | 2 + gas/testsuite/gas/mips/nan-error-1.s | 1 + gas/testsuite/gas/mips/nan-error-2.l | 2 + gas/testsuite/gas/mips/nan-error-2.s | 1 + gas/testsuite/gas/mips/nan-legacy-1.d | 7 +++ gas/testsuite/gas/mips/nan-legacy-2.d | 8 +++ gas/testsuite/gas/mips/nan-legacy-3.d | 7 +++ gas/testsuite/gas/mips/nan-legacy-4.d | 8 +++ gas/testsuite/gas/mips/nan-legacy-5.d | 7 +++ gas/testsuite/gas/mips/nan-legacy-override.s | 2 + gas/testsuite/gas/mips/nan-legacy.s | 1 + include/elf/ChangeLog | 4 ++ include/elf/mips.h | 3 + ld/testsuite/ChangeLog | 9 +++ ld/testsuite/ld-mips-elf/mips-elf.exp | 5 ++ ld/testsuite/ld-mips-elf/nan-2008.d | 7 +++ ld/testsuite/ld-mips-elf/nan-2008.s | 6 ++ ld/testsuite/ld-mips-elf/nan-legacy.d | 8 +++ ld/testsuite/ld-mips-elf/nan-legacy.s | 6 ++ ld/testsuite/ld-mips-elf/nan-mixed-1.d | 5 ++ ld/testsuite/ld-mips-elf/nan-mixed-2.d | 5 ++ 37 files changed, 326 insertions(+), 2 deletions(-) create mode 100644 gas/testsuite/gas/mips/nan-2008-1.d create mode 100644 gas/testsuite/gas/mips/nan-2008-2.d create mode 100644 gas/testsuite/gas/mips/nan-2008-3.d create mode 100644 gas/testsuite/gas/mips/nan-2008-4.d create mode 100644 gas/testsuite/gas/mips/nan-2008-override.s create mode 100644 gas/testsuite/gas/mips/nan-2008.s create mode 100644 gas/testsuite/gas/mips/nan-error-1.l create mode 100644 gas/testsuite/gas/mips/nan-error-1.s create mode 100644 gas/testsuite/gas/mips/nan-error-2.l create mode 100644 gas/testsuite/gas/mips/nan-error-2.s create mode 100644 gas/testsuite/gas/mips/nan-legacy-1.d create mode 100644 gas/testsuite/gas/mips/nan-legacy-2.d create mode 100644 gas/testsuite/gas/mips/nan-legacy-3.d create mode 100644 gas/testsuite/gas/mips/nan-legacy-4.d create mode 100644 gas/testsuite/gas/mips/nan-legacy-5.d create mode 100644 gas/testsuite/gas/mips/nan-legacy-override.s create mode 100644 gas/testsuite/gas/mips/nan-legacy.s create mode 100644 ld/testsuite/ld-mips-elf/nan-2008.d create mode 100644 ld/testsuite/ld-mips-elf/nan-2008.s create mode 100644 ld/testsuite/ld-mips-elf/nan-legacy.d create mode 100644 ld/testsuite/ld-mips-elf/nan-legacy.s create mode 100644 ld/testsuite/ld-mips-elf/nan-mixed-1.d create mode 100644 ld/testsuite/ld-mips-elf/nan-mixed-2.d diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 7c1f5920c79..0292400a7fc 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2013-07-12 Maciej W. Rozycki + + * elfxx-mips.c (_bfd_mips_elf_merge_private_bfd_data): Handle + EF_MIPS_NAN2008. + (_bfd_mips_elf_print_private_bfd_data): Likewise. + 2013-07-09 Tristan Gingold * vms-alpha.c (struct vms_private_data_struct): Remove diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 63fb508b873..b7138cfbfb8 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -14730,6 +14730,20 @@ _bfd_mips_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd) old_flags &= ~ EF_MIPS_ARCH_ASE; } + /* Compare NaN encodings. */ + if ((new_flags & EF_MIPS_NAN2008) != (old_flags & EF_MIPS_NAN2008)) + { + _bfd_error_handler (_("%B: linking %s module with previous %s modules"), + ibfd, + (new_flags & EF_MIPS_NAN2008 + ? "-mnan=2008" : "-mnan=legacy"), + (old_flags & EF_MIPS_NAN2008 + ? "-mnan=2008" : "-mnan=legacy")); + ok = FALSE; + new_flags &= ~EF_MIPS_NAN2008; + old_flags &= ~EF_MIPS_NAN2008; + } + /* Warn about any other mismatches */ if (new_flags != old_flags) { @@ -14921,6 +14935,9 @@ _bfd_mips_elf_print_private_bfd_data (bfd *abfd, void *ptr) if (elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH_ASE_MICROMIPS) fprintf (file, " [micromips]"); + if (elf_elfheader (abfd)->e_flags & EF_MIPS_NAN2008) + fprintf (file, " [nan2008]"); + if (elf_elfheader (abfd)->e_flags & EF_MIPS_32BITMODE) fprintf (file, " [32bitmode]"); else diff --git a/binutils/ChangeLog b/binutils/ChangeLog index fe84d2c0db1..0290e3f8242 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,7 @@ +2013-07-12 Maciej W. Rozycki + + * readelf.c (get_machine_flags): Handle EF_MIPS_NAN2008. + 2013-07-10 Tristan Gingold * od-xcoff.c (OPT_LDINFO): Define. diff --git a/binutils/readelf.c b/binutils/readelf.c index 6b75fac1bbe..f73bb2ff26d 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -2568,6 +2568,9 @@ get_machine_flags (unsigned e_flags, unsigned e_machine) if (e_flags & EF_MIPS_32BITMODE) strcat (buf, ", 32bitmode"); + if (e_flags & EF_MIPS_NAN2008) + strcat (buf, ", nan2008"); + switch ((e_flags & EF_MIPS_MACH)) { case E_MIPS_MACH_3900: strcat (buf, ", 3900"); break; diff --git a/gas/ChangeLog b/gas/ChangeLog index 480181fc0a8..10bcdda8b42 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,18 @@ +2013-07-12 Maciej W. Rozycki + + * config/tc-mips.c (mips_flag_nan2008): New variable. + (options): Add OPTION_NAN enum value. + (md_longopts): Handle it. + (md_parse_option): Likewise. + (s_nan): New function. + (mips_elf_final_processing): Handle EF_MIPS_NAN2008. + (md_show_usage): Add -mnan. + + * doc/as.texinfo (Overview): Add -mnan. + * doc/c-mips.texi (MIPS Opts): Document -mnan. + (MIPS NaN Encodings): New node. Document .nan directive. + (MIPS-Dependent): List the new node. + 2013-07-09 Tristan Gingold * configure.com: Define HAVE_SYS_TYPES_H and HAVE_UNISTD_H diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index 22ba44adedd..7fb870eaedd 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -272,6 +272,9 @@ static int file_mips_soft_float = 0; /* 1 if -msingle-float, 0 if -mdouble-float. The default is 0. */ static int file_mips_single_float = 0; +/* True if -mnan=2008, false if -mnan=legacy. */ +static bfd_boolean mips_flag_nan2008 = FALSE; + static struct mips_set_options mips_opts = { /* isa */ ISA_UNKNOWN, /* ase */ 0, /* mips16 */ -1, /* micromips */ -1, @@ -1310,6 +1313,7 @@ static void s_gpdword (int); static void s_ehword (int); static void s_cpadd (int); static void s_insn (int); +static void s_nan (int); static void md_obj_begin (void); static void md_obj_end (void); static void s_mips_ent (int); @@ -1441,6 +1445,7 @@ enum options OPTION_PDR, OPTION_NO_PDR, OPTION_MVXWORKS_PIC, + OPTION_NAN, OPTION_END_OF_ENUM }; @@ -1556,6 +1561,7 @@ struct option md_longopts[] = {"mpdr", no_argument, NULL, OPTION_PDR}, {"mno-pdr", no_argument, NULL, OPTION_NO_PDR}, {"mvxworks-pic", no_argument, NULL, OPTION_MVXWORKS_PIC}, + {"mnan", required_argument, NULL, OPTION_NAN}, {NULL, no_argument, NULL, 0} }; @@ -1680,6 +1686,7 @@ static const pseudo_typeS mips_pseudo_table[] = {"ehword", s_ehword, 0}, {"cpadd", s_cpadd, 0}, {"insn", s_insn, 0}, + {"nan", s_nan, 0}, /* Relatively generic pseudo-ops that happen to be used on MIPS chips. */ @@ -15262,6 +15269,18 @@ md_parse_option (int c, char *arg) mips_pic = VXWORKS_PIC; break; + case OPTION_NAN: + if (strcmp (arg, "2008") == 0) + mips_flag_nan2008 = TRUE; + else if (strcmp (arg, "legacy") == 0) + mips_flag_nan2008 = FALSE; + else + { + as_fatal (_("Invalid NaN setting -mnan=%s"), arg); + return 0; + } + break; + default: return 0; } @@ -17152,6 +17171,30 @@ s_insn (int ignore ATTRIBUTE_UNUSED) demand_empty_rest_of_line (); } +/* Handle the .nan pseudo-op. */ + +static void +s_nan (int ignore ATTRIBUTE_UNUSED) +{ + static const char str_legacy[] = "legacy"; + static const char str_2008[] = "2008"; + size_t i; + + for (i = 0; !is_end_of_line[(unsigned char) input_line_pointer[i]]; i++); + + if (i == sizeof (str_2008) - 1 + && memcmp (input_line_pointer, str_2008, i) == 0) + mips_flag_nan2008 = TRUE; + else if (i == sizeof (str_legacy) - 1 + && memcmp (input_line_pointer, str_legacy, i) == 0) + mips_flag_nan2008 = FALSE; + else + as_bad (_("Bad .nan directive")); + + input_line_pointer += i; + demand_empty_rest_of_line (); +} + /* Handle a .stab[snd] directive. Ideally these directives would be implemented in a transparent way, so that removing them would not have any effect on the generated instructions. However, s_stab @@ -18751,6 +18794,9 @@ mips_elf_final_processing (void) if (mips_32bitmode) elf_elfheader (stdoutput)->e_flags |= EF_MIPS_32BITMODE; + if (mips_flag_nan2008) + elf_elfheader (stdoutput)->e_flags |= EF_MIPS_NAN2008; + #if 0 /* XXX FIXME */ /* 32 bit code with 64 bit FP registers. */ if (!file_mips_fp32 && ABI_NEEDS_32BIT_REGS (mips_abi)) @@ -19588,8 +19634,16 @@ MIPS options:\n\ -msingle-float only allow 32-bit floating-point operations\n\ -mdouble-float allow 32-bit and 64-bit floating-point operations\n\ --[no-]construct-floats [dis]allow floating point values to be constructed\n\ ---[no-]relax-branch [dis]allow out-of-range branches to be relaxed\n" - )); +--[no-]relax-branch [dis]allow out-of-range branches to be relaxed\n\ +-mnan=ENCODING select an IEEE 754 NaN encoding convention, either of:\n")); + + first = 1; + + show (stream, "legacy", &column, &first); + show (stream, "2008", &column, &first); + + fputc ('\n', stream); + fprintf (stream, _("\ -KPIC, -call_shared generate SVR4 position independent code\n\ -call_nonpic generate non-PIC code that can operate with DSOs\n\ diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo index d1e397f8d37..a2771d7b277 100644 --- a/gas/doc/as.texinfo +++ b/gas/doc/as.texinfo @@ -402,6 +402,7 @@ gcc(1), ld(1), and the Info entries for @file{binutils} and @file{ld}. [@b{-mips3}] [@b{-mips4}] [@b{-mips5}] [@b{-mips32}] [@b{-mips32r2}] [@b{-mips64}] [@b{-mips64r2}] [@b{-construct-floats}] [@b{-no-construct-floats}] + [@b{-mnan=@var{encoding}}] [@b{-trap}] [@b{-no-break}] [@b{-break}] [@b{-no-trap}] [@b{-mips16}] [@b{-no-mips16}] [@b{-mmicromips}] [@b{-mno-micromips}] @@ -1363,6 +1364,10 @@ The @samp{--relax-branch} option enables the relaxation of out-of-range branches. By default @samp{--no-relax-branch} is selected, causing any out-of-range branches to produce an error. +@item -mnan=@var{encoding} +Select between the IEEE 754-2008 (@option{-mnan=2008}) or the legacy +(@option{-mnan=legacy}) NaN encoding format. The latter is the default. + @cindex emulation @item --emulation=@var{name} This option was formerly used to switch between ELF and ECOFF output diff --git a/gas/doc/c-mips.texi b/gas/doc/c-mips.texi index 741237acef4..8a25a7626a0 100644 --- a/gas/doc/c-mips.texi +++ b/gas/doc/c-mips.texi @@ -30,6 +30,7 @@ Assembly Language Programming'' in the same work. * MIPS assembly options:: Directives to control code generation * MIPS autoextend:: Directives for extending MIPS 16 bit instructions * MIPS insn:: Directive to mark data as an instruction +* MIPS NaN Encodings:: Directives to record which NaN encoding is being used * MIPS Option Stack:: Directives to save and restore options * MIPS ASE Instruction Generation Overrides:: Directives to control generation of MIPS ASE instructions @@ -416,6 +417,16 @@ Also no MIPS16 branches are ever relaxed. By default @samp{--no-relax-branch} is selected, causing any out-of-range branches to produce an error. +@cindex @option{-mnan=} command line option, MIPS +@item -mnan=@var{encoding} +This option indicates whether the source code uses the IEEE 2008 +NaN encoding (@option{-mnan=2008}) or the original MIPS encoding +(@option{-mnan=legacy}). It is equivalent to adding a @code{.nan} +directive to the beginning of the source file. @xref{MIPS NaN Encodings}. + +@option{-mnan=legacy} is the default if no @option{-mnan} option or +@code{.nan} directive is used. + @item --trap @itemx --no-break @c FIXME! (1) reflect these options (next item too) in option summaries; @@ -722,6 +733,47 @@ baz: @end example +@node MIPS NaN Encodings +@section Directives to record which NaN encoding is being used + +@cindex MIPS IEEE 754 NaN data encoding selection +@cindex @code{.nan} directive, MIPS +The IEEE 754 floating-point standard defines two types of not-a-number +(NaN) data: ``signalling'' NaNs and ``quiet'' NaNs. The original version +of the standard did not specify how these two types should be +distinguished. Most implementations followed the i387 model, in which +the first bit of the significand is set for quiet NaNs and clear for +signalling NaNs. However, the original MIPS implementation assigned the +opposite meaning to the bit, so that it was set for signalling NaNs and +clear for quiet NaNs. + +The 2008 revision of the standard formally suggested the i387 choice +and as from Sep 2012 the current release of the MIPS architecture +therefore optionally supports that form. Code that uses one NaN encoding +would usually be incompatible with code that uses the other NaN encoding, +so MIPS ELF objects have a flag (@code{EF_MIPS_NAN2008}) to record which +encoding is being used. + +Assembly files can use the @code{.nan} directive to select between the +two encodings. @samp{.nan 2008} says that the assembly file uses the +IEEE 754-2008 encoding while @samp{.nan legacy} says that the file uses +the original MIPS encoding. If several @code{.nan} directives are given, +the final setting is the one that is used. + +The command-line options @option{-mnan=legacy} and @option{-mnan=2008} +can be used instead of @samp{.nan legacy} and @samp{.nan 2008} +respectively. However, any @code{.nan} directive overrides the +command-line setting. + +@samp{.nan legacy} is the default if no @code{.nan} directive or +@option{-mnan} option is given. + +Note that @sc{gnu} @code{@value{AS}} does not produce NaNs itself and +therefore these directives do not affect code generation. They simply +control the setting of the @code{EF_MIPS_NAN2008} flag. + +Traditional MIPS assemblers do not support these directives. + @node MIPS Option Stack @section Directives to save and restore options diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index 8deb0d75693..882bcc60b11 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,24 @@ +2013-07-12 Maciej W. Rozycki + + * gas/mips/nan-2008-1.d: New test. + * gas/mips/nan-2008-2.d: New test. + * gas/mips/nan-2008-3.d: New test. + * gas/mips/nan-2008-4.d: New test. + * gas/mips/nan-legacy-1.d: New test. + * gas/mips/nan-legacy-2.d: New test. + * gas/mips/nan-legacy-3.d: New test. + * gas/mips/nan-legacy-4.d: New test. + * gas/mips/nan-legacy-5.d: New test. + * gas/mips/nan-error-1.l: New list test. + * gas/mips/nan-error-2.l: New list test. + * gas/mips/nan-2008-override.s: New test source. + * gas/mips/nan-2008.s: New test source. + * gas/mips/nan-legacy-override.s: New test source. + * gas/mips/nan-legacy.s: New test source. + * gas/mips/nan-error-1.s: New test source. + * gas/mips/nan-error-2.s: New test source. + * gas/mips/mips.exp: Run the new tests. + 2013-07-09 Richard Sandiford * gas/mips/la-reloc.s, gas/mips/la-reloc.d, gas/mips/dla-reloc.s, diff --git a/gas/testsuite/gas/mips/mips.exp b/gas/testsuite/gas/mips/mips.exp index 673b1d7a181..73127dd2e3c 100644 --- a/gas/testsuite/gas/mips/mips.exp +++ b/gas/testsuite/gas/mips/mips.exp @@ -915,6 +915,20 @@ if { [istarget mips*-*-vxworks*] } { run_dump_test_arches "loc-swap-2" [mips_arch_list_all] run_dump_test_arches "loc-swap-3" [mips_arch_list_all] + run_dump_test "nan-legacy-1" + run_dump_test "nan-legacy-2" + run_dump_test "nan-legacy-3" + run_dump_test "nan-legacy-4" + run_dump_test "nan-legacy-5" + + run_dump_test "nan-2008-1" + run_dump_test "nan-2008-2" + run_dump_test "nan-2008-3" + run_dump_test "nan-2008-4" + + run_list_test "nan-error-1" + run_list_test "nan-error-2" "-mnan=foo" + if $has_newabi { run_dump_test "n32-consec" } diff --git a/gas/testsuite/gas/mips/nan-2008-1.d b/gas/testsuite/gas/mips/nan-2008-1.d new file mode 100644 index 00000000000..3649fd23f62 --- /dev/null +++ b/gas/testsuite/gas/mips/nan-2008-1.d @@ -0,0 +1,6 @@ +#name: MIPS 2008 NaN setting 1 +#source: nan-2008.s +#objdump: -p + +.*:.*file format.*mips.* +private flags = [0-9a-f]*[4-7c-f]..: .*[[,]nan2008[],].* diff --git a/gas/testsuite/gas/mips/nan-2008-2.d b/gas/testsuite/gas/mips/nan-2008-2.d new file mode 100644 index 00000000000..e8a07cebbf6 --- /dev/null +++ b/gas/testsuite/gas/mips/nan-2008-2.d @@ -0,0 +1,7 @@ +#name: MIPS 2008 NaN setting 2 +#source: nan-2008.s +#objdump: -p +#as: -mnan=legacy + +.*:.*file format.*mips.* +private flags = [0-9a-f]*[4-7c-f]..: .*[[,]nan2008[],].* diff --git a/gas/testsuite/gas/mips/nan-2008-3.d b/gas/testsuite/gas/mips/nan-2008-3.d new file mode 100644 index 00000000000..7c3c4a3e058 --- /dev/null +++ b/gas/testsuite/gas/mips/nan-2008-3.d @@ -0,0 +1,6 @@ +#name: MIPS 2008 NaN setting 3 +#source: nan-2008-override.s +#objdump: -p + +.*:.*file format.*mips.* +private flags = [0-9a-f]*[4-7c-f]..: .*[[,]nan2008[],].* diff --git a/gas/testsuite/gas/mips/nan-2008-4.d b/gas/testsuite/gas/mips/nan-2008-4.d new file mode 100644 index 00000000000..22ba87ff49c --- /dev/null +++ b/gas/testsuite/gas/mips/nan-2008-4.d @@ -0,0 +1,7 @@ +#name: MIPS 2008 NaN setting 4 +#source: empty.s +#objdump: -p +#as: -mnan=2008 + +.*:.*file format.*mips.* +private flags = [0-9a-f]*[4-7c-f]..: .*[[,]nan2008[],].* diff --git a/gas/testsuite/gas/mips/nan-2008-override.s b/gas/testsuite/gas/mips/nan-2008-override.s new file mode 100644 index 00000000000..ec6d6b853b4 --- /dev/null +++ b/gas/testsuite/gas/mips/nan-2008-override.s @@ -0,0 +1,2 @@ + .nan legacy + .nan 2008 diff --git a/gas/testsuite/gas/mips/nan-2008.s b/gas/testsuite/gas/mips/nan-2008.s new file mode 100644 index 00000000000..9a3875eae56 --- /dev/null +++ b/gas/testsuite/gas/mips/nan-2008.s @@ -0,0 +1 @@ + .nan 2008 diff --git a/gas/testsuite/gas/mips/nan-error-1.l b/gas/testsuite/gas/mips/nan-error-1.l new file mode 100644 index 00000000000..470bf9ce4f5 --- /dev/null +++ b/gas/testsuite/gas/mips/nan-error-1.l @@ -0,0 +1,2 @@ +.*\.s: Assembler messages: +.*\.s:1: Error: Bad .nan directive diff --git a/gas/testsuite/gas/mips/nan-error-1.s b/gas/testsuite/gas/mips/nan-error-1.s new file mode 100644 index 00000000000..c6f64c3ec1f --- /dev/null +++ b/gas/testsuite/gas/mips/nan-error-1.s @@ -0,0 +1 @@ + .nan foo diff --git a/gas/testsuite/gas/mips/nan-error-2.l b/gas/testsuite/gas/mips/nan-error-2.l new file mode 100644 index 00000000000..2182615685c --- /dev/null +++ b/gas/testsuite/gas/mips/nan-error-2.l @@ -0,0 +1,2 @@ +Assembler messages: +Fatal error: Invalid NaN setting -mnan=foo diff --git a/gas/testsuite/gas/mips/nan-error-2.s b/gas/testsuite/gas/mips/nan-error-2.s new file mode 100644 index 00000000000..dc87e667596 --- /dev/null +++ b/gas/testsuite/gas/mips/nan-error-2.s @@ -0,0 +1 @@ +# No contents necessary. diff --git a/gas/testsuite/gas/mips/nan-legacy-1.d b/gas/testsuite/gas/mips/nan-legacy-1.d new file mode 100644 index 00000000000..4dcb93c4645 --- /dev/null +++ b/gas/testsuite/gas/mips/nan-legacy-1.d @@ -0,0 +1,7 @@ +#name: MIPS legacy NaN setting 1 +#source: nan-legacy.s +#objdump: -p + +.*:.*file format.*mips.* +#failif +private flags = [0-9a-f]*[4-7c-f]..: .*[[]nan2008[]].* diff --git a/gas/testsuite/gas/mips/nan-legacy-2.d b/gas/testsuite/gas/mips/nan-legacy-2.d new file mode 100644 index 00000000000..6ad4dce3082 --- /dev/null +++ b/gas/testsuite/gas/mips/nan-legacy-2.d @@ -0,0 +1,8 @@ +#name: MIPS legacy NaN setting 2 +#source: nan-legacy.s +#objdump: -p +#as: -mnan=2008 + +.*:.*file format.*mips.* +#failif +private flags = [0-9a-f]*[4-7c-f]..: .*[[]nan2008[]].* diff --git a/gas/testsuite/gas/mips/nan-legacy-3.d b/gas/testsuite/gas/mips/nan-legacy-3.d new file mode 100644 index 00000000000..649f0ee5927 --- /dev/null +++ b/gas/testsuite/gas/mips/nan-legacy-3.d @@ -0,0 +1,7 @@ +#name: MIPS legacy NaN setting 3 +#source: nan-legacy-override.s +#objdump: -p + +.*:.*file format.*mips.* +#failif +private flags = [0-9a-f]*[4-7c-f]..: .*[[]nan2008[]].* diff --git a/gas/testsuite/gas/mips/nan-legacy-4.d b/gas/testsuite/gas/mips/nan-legacy-4.d new file mode 100644 index 00000000000..3dc00cb2198 --- /dev/null +++ b/gas/testsuite/gas/mips/nan-legacy-4.d @@ -0,0 +1,8 @@ +#name: MIPS legacy NaN setting 4 +#source: empty.s +#objdump: -p +#as: -mnan=legacy + +.*:.*file format.*mips.* +#failif +private flags = [0-9a-f]*[4-7c-f]..: .*[[]nan2008[]].* diff --git a/gas/testsuite/gas/mips/nan-legacy-5.d b/gas/testsuite/gas/mips/nan-legacy-5.d new file mode 100644 index 00000000000..db3a954c65d --- /dev/null +++ b/gas/testsuite/gas/mips/nan-legacy-5.d @@ -0,0 +1,7 @@ +#name: MIPS legacy NaN setting 5 +#source: empty.s +#objdump: -p + +.*:.*file format.*mips.* +#failif +private flags = [0-9a-f]*[4-7c-f]..: .*[[]nan2008[]].* diff --git a/gas/testsuite/gas/mips/nan-legacy-override.s b/gas/testsuite/gas/mips/nan-legacy-override.s new file mode 100644 index 00000000000..64b2c82355f --- /dev/null +++ b/gas/testsuite/gas/mips/nan-legacy-override.s @@ -0,0 +1,2 @@ + .nan 2008 + .nan legacy diff --git a/gas/testsuite/gas/mips/nan-legacy.s b/gas/testsuite/gas/mips/nan-legacy.s new file mode 100644 index 00000000000..4c299f804be --- /dev/null +++ b/gas/testsuite/gas/mips/nan-legacy.s @@ -0,0 +1 @@ + .nan legacy diff --git a/include/elf/ChangeLog b/include/elf/ChangeLog index 2edd1dfcce8..6309d1c84d6 100644 --- a/include/elf/ChangeLog +++ b/include/elf/ChangeLog @@ -1,3 +1,7 @@ +2013-07-12 Maciej W. Rozycki + + * mips.h (EF_MIPS_NAN2008): New macro. + 2013-07-08 Tristan Gingold * ia64.h (STB_VMS_WEAK, STB_VMS_SYSTEM): Add. diff --git a/include/elf/mips.h b/include/elf/mips.h index f3be987a0ab..84700b4bdd7 100644 --- a/include/elf/mips.h +++ b/include/elf/mips.h @@ -191,6 +191,9 @@ END_RELOC_NUMBERS (R_MIPS_maxext) (regs are 32-bits wide). */ #define EF_MIPS_32BITMODE 0x00000100 +/* Code in file uses the IEEE 754-2008 NaN encoding convention. */ +#define EF_MIPS_NAN2008 0x00000400 + /* Architectural Extensions used by this file */ #define EF_MIPS_ARCH_ASE 0x0f000000 diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index a4635705f72..febe6910422 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2013-07-12 Maciej W. Rozycki + + * ld-mips-elf/nan-2008.d: New test. + * ld-mips-elf/nan-legacy.d: New test. + * ld-mips-elf/nan-mixed-1.d: New test. + * ld-mips-elf/nan-mixed-2.d: New test. + * ld-mips-elf/nan-2008.s: New test source. + * ld-mips-elf/nan-legacy.s: New test source. + 2013-07-03 Marcus Shawcroft * ld-aarch64/emit-relocs-309.s: Replace got_prel19 with got. diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp index e0ddac9edf8..24ecf956ca5 100644 --- a/ld/testsuite/ld-mips-elf/mips-elf.exp +++ b/ld/testsuite/ld-mips-elf/mips-elf.exp @@ -666,6 +666,11 @@ run_dump_test "attr-gnu-4-44" run_dump_test "attr-gnu-4-45" run_dump_test "attr-gnu-4-51" +run_dump_test "nan-legacy" +run_dump_test "nan-2008" +run_dump_test "nan-mixed-1" +run_dump_test "nan-mixed-2" + if { $linux_gnu } { run_ld_link_tests { {"GOT and versioning 1" diff --git a/ld/testsuite/ld-mips-elf/nan-2008.d b/ld/testsuite/ld-mips-elf/nan-2008.d new file mode 100644 index 00000000000..aa20049f68c --- /dev/null +++ b/ld/testsuite/ld-mips-elf/nan-2008.d @@ -0,0 +1,7 @@ +#source: nan-2008.s +#source: nan-2008.s +#ld: -r +#objdump: -p + +.*:.*file format.*mips.* +private flags = [0-9a-f]*[4-7c-f]..: .*[[,]nan2008[],].* diff --git a/ld/testsuite/ld-mips-elf/nan-2008.s b/ld/testsuite/ld-mips-elf/nan-2008.s new file mode 100644 index 00000000000..a87cbab9192 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/nan-2008.s @@ -0,0 +1,6 @@ + .nan 2008 + +# We need some section contents for the ELF header flag compatibility check +# to trigger. + .data + .byte 0 diff --git a/ld/testsuite/ld-mips-elf/nan-legacy.d b/ld/testsuite/ld-mips-elf/nan-legacy.d new file mode 100644 index 00000000000..081abcfd94a --- /dev/null +++ b/ld/testsuite/ld-mips-elf/nan-legacy.d @@ -0,0 +1,8 @@ +#source: nan-legacy.s +#source: nan-legacy.s +#ld: -r +#objdump: -p + +.*:.*file format.*mips.* +#failif +private flags = [0-9a-f]*[4-7c-f]..: .*[[]nan2008[]].* diff --git a/ld/testsuite/ld-mips-elf/nan-legacy.s b/ld/testsuite/ld-mips-elf/nan-legacy.s new file mode 100644 index 00000000000..b0c0c6760e7 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/nan-legacy.s @@ -0,0 +1,6 @@ + .nan legacy + +# We need some section contents for the ELF header flag compatibility check +# to trigger. + .data + .byte 0 diff --git a/ld/testsuite/ld-mips-elf/nan-mixed-1.d b/ld/testsuite/ld-mips-elf/nan-mixed-1.d new file mode 100644 index 00000000000..9bc524c5552 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/nan-mixed-1.d @@ -0,0 +1,5 @@ +#source: nan-legacy.s +#source: nan-2008.s +#ld: -r +#error: \A[^\n]*: [^\n]* linking -mnan=2008 module with previous -mnan=legacy modules\n +#error: [^\n]*: failed to merge target specific data of file [^\n]*\.o\Z diff --git a/ld/testsuite/ld-mips-elf/nan-mixed-2.d b/ld/testsuite/ld-mips-elf/nan-mixed-2.d new file mode 100644 index 00000000000..388d7709663 --- /dev/null +++ b/ld/testsuite/ld-mips-elf/nan-mixed-2.d @@ -0,0 +1,5 @@ +#source: nan-2008.s +#source: nan-legacy.s +#ld: -r +#error: \A[^\n]*: [^\n]* linking -mnan=legacy module with previous -mnan=2008 modules\n +#error: [^\n]*: failed to merge target specific data of file [^\n]*\.o\Z -- 2.30.2