[PATCH] MIPS/GAS: Fix .stabs directive marking labels as MIPS16

James Cowgill James.Cowgill@imgtec.com
Wed Sep 13 10:29:00 GMT 2017


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.
---
 Note I need someone to commit this for me.

 gas/config/tc-mips.c                                 |  1 +
 gas/testsuite/gas/mips/micromips@stabs-symbol-type.d | 10 ++++++++++
 gas/testsuite/gas/mips/mips.exp                      |  2 ++
 gas/testsuite/gas/mips/mips16@stabs-symbol-type.d    | 10 ++++++++++
 gas/testsuite/gas/mips/stabs-symbol-type.d           |  9 +++++++++
 gas/testsuite/gas/mips/stabs-symbol-type.s           |  3 +++
 6 files changed, 35 insertions(+)
 create mode 100644 gas/testsuite/gas/mips/micromips@stabs-symbol-type.d
 create mode 100644 gas/testsuite/gas/mips/mips16@stabs-symbol-type.d
 create mode 100644 gas/testsuite/gas/mips/stabs-symbol-type.d
 create mode 100644 gas/testsuite/gas/mips/stabs-symbol-type.s

diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index 43a703307e..e4351f7a49 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -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
index 0000000000..0b00a3ef8c
--- /dev/null
+++ b/gas/testsuite/gas/mips/micromips@stabs-symbol-type.d
@@ -0,0 +1,10 @@
+#PROG: readelf
+#readelf: -s
+#name: MIPS .stab symbol type
+#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
diff --git a/gas/testsuite/gas/mips/mips.exp b/gas/testsuite/gas/mips/mips.exp
index c71dca4351..1a73cfff7b 100644
--- a/gas/testsuite/gas/mips/mips.exp
+++ b/gas/testsuite/gas/mips/mips.exp
@@ -2047,4 +2047,6 @@ if { [istarget mips*-*-vxworks*] } {
 
     run_list_test_arches "r6-branch-constraints"  "-32" \
 			[mips_arch_list_matching mips32r6]
+
+    run_dump_test_arches "stabs-symbol-type" [mips_arch_list_all]
 }
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
index 0000000000..63070b6a65
--- /dev/null
+++ b/gas/testsuite/gas/mips/mips16@stabs-symbol-type.d
@@ -0,0 +1,10 @@
+#PROG: readelf
+#readelf: -s
+#name: MIPS .stab symbol type
+#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
index 0000000000..66a664f5c2
--- /dev/null
+++ b/gas/testsuite/gas/mips/stabs-symbol-type.d
@@ -0,0 +1,9 @@
+#PROG: readelf
+#readelf: -s
+#name: MIPS .stab symbol type
+
+# 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
index 0000000000..26b46f4572
--- /dev/null
+++ b/gas/testsuite/gas/mips/stabs-symbol-type.s
@@ -0,0 +1,3 @@
+	.text
+foo:
+	.stabd 0, 0, 0
-- 
2.14.1



More information about the Binutils mailing list