From 42c0794e961fd7922ad1358bd7221a8c85278ccc Mon Sep 17 00:00:00 2001 From: James Cowgill Date: Fri, 22 Sep 2017 00:54:19 +0100 Subject: [PATCH] PR gas/21762: MIPS: Fix .stabs directive marking labels as MIPS16 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 | 11 +++++++++++ gas/config/tc-mips.c | 1 + gas/testsuite/gas/mips/micromips@stabs-symbol-type.d | 11 +++++++++++ gas/testsuite/gas/mips/mips.exp | 2 ++ gas/testsuite/gas/mips/mips16@stabs-symbol-type.d | 11 +++++++++++ gas/testsuite/gas/mips/stabs-symbol-type.d | 10 ++++++++++ gas/testsuite/gas/mips/stabs-symbol-type.s | 3 +++ 7 files changed, 49 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/ChangeLog b/gas/ChangeLog index c5f19ff53c..7c9e61fe71 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,14 @@ +2017-09-21 James Cowgill + + 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 * config/tc-ppc.h (EH_FRAME_ALIGNMENT): Define. 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..c93efe5b8f --- /dev/null +++ b/gas/testsuite/gas/mips/micromips@stabs-symbol-type.d @@ -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 diff --git a/gas/testsuite/gas/mips/mips.exp b/gas/testsuite/gas/mips/mips.exp index c71dca4351..0f259d3ada 100644 --- a/gas/testsuite/gas/mips/mips.exp +++ b/gas/testsuite/gas/mips/mips.exp @@ -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 index 0000000000..b37aa1ebc0 --- /dev/null +++ b/gas/testsuite/gas/mips/mips16@stabs-symbol-type.d @@ -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 index 0000000000..4f8501d952 --- /dev/null +++ b/gas/testsuite/gas/mips/stabs-symbol-type.d @@ -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 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.34.1