PR gas/21762: MIPS: Fix .stabs directive marking labels as MIPS16
authorJames Cowgill <James.Cowgill@imgtec.com>
Thu, 21 Sep 2017 23:54:19 +0000 (00:54 +0100)
committerMaciej W. Rozycki <macro@imgtec.com>
Thu, 21 Sep 2017 23:54:19 +0000 (00:54 +0100)
If a .stabs directive was used before another .set directive in a MIPS
source file, s_mips_stab would call mips_mark_labels without having
initialized the mips_opts structure yet.  Fix this by calling
file_mips_check_options which will initialize mips_opts if necessary.

gas/
PR gas/21762
* config/tc-mips.c (s_mips_stab): Insert call to
file_mips_check_options.
* testsuite/gas/mips/micromips@stabs-symbol-type.d: New test.
* testsuite/gas/mips/mips.exp: Run the new tests.
* testsuite/gas/mips/mips16@stabs-symbol-type.d: New test.
* testsuite/gas/mips/stabs-symbol-type.d: New test.
* testsuite/gas/mips/stabs-symbol-type.s: New test source.

gas/ChangeLog
gas/config/tc-mips.c
gas/testsuite/gas/mips/micromips@stabs-symbol-type.d [new file with mode: 0644]
gas/testsuite/gas/mips/mips.exp
gas/testsuite/gas/mips/mips16@stabs-symbol-type.d [new file with mode: 0644]
gas/testsuite/gas/mips/stabs-symbol-type.d [new file with mode: 0644]
gas/testsuite/gas/mips/stabs-symbol-type.s [new file with mode: 0644]

index c5f19ff53c46c4eb043b2a05b50958beca302bf3..7c9e61fe71c49b01c7f31428bfbaa901566a9799 100644 (file)
@@ -1,3 +1,14 @@
+2017-09-21  James Cowgill  <James.Cowgill@imgtec.com>
+
+       PR gas/21762
+       * config/tc-mips.c (s_mips_stab): Insert call to
+       file_mips_check_options.
+       * testsuite/gas/mips/micromips@stabs-symbol-type.d: New test.
+       * testsuite/gas/mips/mips.exp: Run the new tests.
+       * testsuite/gas/mips/mips16@stabs-symbol-type.d: New test.
+       * testsuite/gas/mips/stabs-symbol-type.d: New test.
+       * testsuite/gas/mips/stabs-symbol-type.s: New test source.
+
 2017-09-21  Alan Modra  <amodra@gmail.com>
 
        * config/tc-ppc.h (EH_FRAME_ALIGNMENT): Define.
index 43a703307e15cc91b01e259595ac69ef34fe9837..e4351f7a490bb792281240f0edc721f6673d29a5 100644 (file)
@@ -17149,6 +17149,7 @@ s_nan (int ignore ATTRIBUTE_UNUSED)
 static void
 s_mips_stab (int type)
 {
+  file_mips_check_options ();
   mips_mark_labels ();
   s_stab (type);
 }
diff --git a/gas/testsuite/gas/mips/micromips@stabs-symbol-type.d b/gas/testsuite/gas/mips/micromips@stabs-symbol-type.d
new file mode 100644 (file)
index 0000000..c93efe5
--- /dev/null
@@ -0,0 +1,11 @@
+#PROG: readelf
+#readelf: -s
+#name: MIPS .stab symbol type
+#as: -32
+#source: stabs-symbol-type.s
+
+# Verify the symbol type when emitting a .stab directive.
+# In this case, it should be MICROMIPS.
+#...
+ *[0-9]+: +[0-9]+ +[0-9]+ +NOTYPE +LOCAL +DEFAULT +\[MICROMIPS\] +[0-9]+ foo
+#pass
index c71dca4351d75b7abd746d3a252dd955fbd0836c..0f259d3adac2fbab9e194cb4681399e861ebb527 100644 (file)
@@ -2034,6 +2034,8 @@ if { [istarget mips*-*-vxworks*] } {
     run_dump_test "org-11"
     run_dump_test "org-12"
 
+    run_dump_test_arches "stabs-symbol-type" [mips_arch_list_all]
+
     run_dump_test_arches "r6"          [mips_arch_list_matching mips32r6]
     if $has_newabi {
        run_dump_test_arches "r6-n32"   [mips_arch_list_matching mips64r6]
diff --git a/gas/testsuite/gas/mips/mips16@stabs-symbol-type.d b/gas/testsuite/gas/mips/mips16@stabs-symbol-type.d
new file mode 100644 (file)
index 0000000..b37aa1e
--- /dev/null
@@ -0,0 +1,11 @@
+#PROG: readelf
+#readelf: -s
+#name: MIPS .stab symbol type
+#as: -32
+#source: stabs-symbol-type.s
+
+# Verify the symbol type when emitting a .stab directive.
+# In this case, it should be MIPS16.
+#...
+ *[0-9]+: +[0-9]+ +[0-9]+ +NOTYPE +LOCAL +DEFAULT +\[MIPS16\] +[0-9]+ foo
+#pass
diff --git a/gas/testsuite/gas/mips/stabs-symbol-type.d b/gas/testsuite/gas/mips/stabs-symbol-type.d
new file mode 100644 (file)
index 0000000..4f8501d
--- /dev/null
@@ -0,0 +1,10 @@
+#PROG: readelf
+#readelf: -s
+#name: MIPS .stab symbol type
+#as: -32
+
+# Verify the symbol type when emitting a .stab directive.
+# In this case, it should not be MIPS16 or MICROMIPS.
+#...
+ *[0-9]+: +[0-9]+ +[0-9]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ foo
+#pass
diff --git a/gas/testsuite/gas/mips/stabs-symbol-type.s b/gas/testsuite/gas/mips/stabs-symbol-type.s
new file mode 100644 (file)
index 0000000..26b46f4
--- /dev/null
@@ -0,0 +1,3 @@
+       .text
+foo:
+       .stabd 0, 0, 0