1 From 22522f880a8e17a17c4f195796ec89caece7652b Mon Sep 17 00:00:00 2001
2 From: Maciej W. Rozycki <macro@imgtec.com>
3 Date: Fri, 22 Apr 2016 01:04:52 +0100
4 Subject: [PATCH] MIPS/GAS: Fix an ISA override not lifting ABI restrictions
6 Correct a regression introduced with commit 919731affbef ("Add MIPS
7 .module directive") causing code like:
10 dli $2, 0x9000000080000000
12 to fail assembly with the following error message produced:
14 Error: number (0x9000000080000000) larger than 32 bits
16 if built with `mips3' selected as the global ISA (e.g. `-march=mips3').
17 This is because a `.set' directive doing an ISA override does not lift
18 the ABI restriction on register sizes if the ISA remains unchanged.
19 Previously the directive always set register sizes from the ISA chosen,
20 which is what some code expects. Restore the old semantics then.
23 * config/tc-mips.c (code_option_type): New enum.
24 (parse_code_option): Return status indicating option type.
25 (s_mipsset): Update `parse_code_option' call site accordingly.
26 Always set register sizes from the ISA with ISA overrides.
27 (s_module): Update `parse_code_option' call site.
28 * testsuite/gas/mips/isa-override-1.d: New test.
29 * testsuite/gas/mips/micromips@isa-override-1.d: New test.
30 * testsuite/gas/mips/mips1@isa-override-1.d: New test.
31 * testsuite/gas/mips/mips2@isa-override-1.d: New test.
32 * testsuite/gas/mips/mips32@isa-override-1.d: New test.
33 * testsuite/gas/mips/mips32r2@isa-override-1.d: New test.
34 * testsuite/gas/mips/mips32r3@isa-override-1.d: New test.
35 * testsuite/gas/mips/mips32r5@isa-override-1.d: New test.
36 * testsuite/gas/mips/mips32r6@isa-override-1.d: New test.
37 * testsuite/gas/mips/mips64r2@isa-override-1.d: New test.
38 * testsuite/gas/mips/mips64r3@isa-override-1.d: New test.
39 * testsuite/gas/mips/mips64r5@isa-override-1.d: New test.
40 * testsuite/gas/mips/mips64r6@isa-override-1.d: New test.
41 * testsuite/gas/mips/r3000@isa-override-1.d: New test.
42 * testsuite/gas/mips/r3900@isa-override-1.d: New test.
43 * testsuite/gas/mips/r5900@isa-override-1.d: New test.
44 * testsuite/gas/mips/octeon@isa-override-1.d: New test.
45 * testsuite/gas/mips/octeon3@isa-override-1.d: New test.
46 * testsuite/gas/mips/isa-override-2.l: New list test.
47 * testsuite/gas/mips/mips1@isa-override-2.l: New list test.
48 * testsuite/gas/mips/mips2@isa-override-2.l: New list test.
49 * testsuite/gas/mips/mips32@isa-override-2.l: New list test.
50 * testsuite/gas/mips/mips32r2@isa-override-2.l: New list test.
51 * testsuite/gas/mips/mips32r3@isa-override-2.l: New list test.
52 * testsuite/gas/mips/mips32r5@isa-override-2.l: New list test.
53 * testsuite/gas/mips/mips32r6@isa-override-2.l: New list test.
54 * testsuite/gas/mips/r3000@isa-override-2.l: New list test.
55 * testsuite/gas/mips/r3900@isa-override-2.l: New list test.
56 * testsuite/gas/mips/octeon3@isa-override-2.l: New list test.
57 * testsuite/gas/mips/octeon3@isa-override-1.l: New stderr
59 * testsuite/gas/mips/isa-override-1.s: New test source.
60 * testsuite/gas/mips/r5900@isa-override-1.s: New test source.
61 * testsuite/gas/mips/isa-override-2.s: New test source.
62 * testsuite/gas/mips/mips1@isa-override-2.s: New test source.
63 * testsuite/gas/mips/mips2@isa-override-2.s: New test source.
64 * testsuite/gas/mips/mips32@isa-override-2.s: New test source.
65 * testsuite/gas/mips/mips32r2@isa-override-2.s: New test source.
66 * testsuite/gas/mips/mips32r3@isa-override-2.s: New test source.
67 * testsuite/gas/mips/mips32r5@isa-override-2.s: New test source.
68 * testsuite/gas/mips/mips32r6@isa-override-2.s: New test source.
69 * testsuite/gas/mips/r3000@isa-override-2.s: New test source.
70 * testsuite/gas/mips/r3900@isa-override-2.s: New test source.
71 * testsuite/gas/mips/octeon3@isa-override-2.s: New test source.
72 * testsuite/gas/mips/mips.exp: Run the new tests.
74 Upstream-Status: Backport
75 http://www.serverphorums.com/read.php?12,1466357
76 https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=22522f880a8e17a17c4f195796ec89caece7652b
78 gas/ChangeLog | 53 +++++++++++++++++++++
79 gas/config/tc-mips.c | 42 +++++++++++++---
80 gas/testsuite/gas/mips/isa-override-1.d | 49 +++++++++++++++++++
81 gas/testsuite/gas/mips/isa-override-1.s | 31 ++++++++++++
82 gas/testsuite/gas/mips/isa-override-2.l | 4 ++
83 gas/testsuite/gas/mips/isa-override-2.s | 18 +++++++
84 gas/testsuite/gas/mips/micromips@isa-override-1.d | 50 +++++++++++++++++++
85 gas/testsuite/gas/mips/mips.exp | 3 +
86 gas/testsuite/gas/mips/mips1@isa-override-1.d | 53 +++++++++++++++++++++
87 gas/testsuite/gas/mips/mips1@isa-override-2.l | 4 ++
88 gas/testsuite/gas/mips/mips1@isa-override-2.s | 18 +++++++
89 gas/testsuite/gas/mips/mips2@isa-override-1.d | 50 +++++++++++++++++++
90 gas/testsuite/gas/mips/mips2@isa-override-2.l | 4 ++
91 gas/testsuite/gas/mips/mips2@isa-override-2.s | 18 +++++++
92 gas/testsuite/gas/mips/mips32@isa-override-1.d | 5 ++
93 gas/testsuite/gas/mips/mips32@isa-override-2.l | 4 ++
94 gas/testsuite/gas/mips/mips32@isa-override-2.s | 18 +++++++
95 gas/testsuite/gas/mips/mips32r2@isa-override-1.d | 50 +++++++++++++++++++
96 gas/testsuite/gas/mips/mips32r2@isa-override-2.l | 4 ++
97 gas/testsuite/gas/mips/mips32r2@isa-override-2.s | 18 +++++++
98 gas/testsuite/gas/mips/mips32r3@isa-override-1.d | 5 ++
99 gas/testsuite/gas/mips/mips32r3@isa-override-2.l | 4 ++
100 gas/testsuite/gas/mips/mips32r3@isa-override-2.s | 18 +++++++
101 gas/testsuite/gas/mips/mips32r5@isa-override-1.d | 5 ++
102 gas/testsuite/gas/mips/mips32r5@isa-override-2.l | 4 ++
103 gas/testsuite/gas/mips/mips32r5@isa-override-2.s | 18 +++++++
104 gas/testsuite/gas/mips/mips32r6@isa-override-1.d | 5 ++
105 gas/testsuite/gas/mips/mips32r6@isa-override-2.l | 4 ++
106 gas/testsuite/gas/mips/mips32r6@isa-override-2.s | 18 +++++++
107 gas/testsuite/gas/mips/mips64r2@isa-override-1.d | 50 +++++++++++++++++++
108 gas/testsuite/gas/mips/mips64r3@isa-override-1.d | 5 ++
109 gas/testsuite/gas/mips/mips64r5@isa-override-1.d | 5 ++
110 gas/testsuite/gas/mips/mips64r6@isa-override-1.d | 5 ++
111 gas/testsuite/gas/mips/octeon3@isa-override-1.d | 6 ++
112 gas/testsuite/gas/mips/octeon3@isa-override-1.l | 2 +
113 gas/testsuite/gas/mips/octeon3@isa-override-2.l | 5 ++
114 gas/testsuite/gas/mips/octeon3@isa-override-2.s | 18 +++++++
115 gas/testsuite/gas/mips/octeon@isa-override-1.d | 5 ++
116 gas/testsuite/gas/mips/r3000@isa-override-1.d | 5 ++
117 gas/testsuite/gas/mips/r3000@isa-override-2.l | 4 ++
118 gas/testsuite/gas/mips/r3000@isa-override-2.s | 18 +++++++
119 gas/testsuite/gas/mips/r3900@isa-override-1.d | 5 ++
120 gas/testsuite/gas/mips/r3900@isa-override-2.l | 4 ++
121 gas/testsuite/gas/mips/r3900@isa-override-2.s | 18 +++++++
122 gas/testsuite/gas/mips/r5900@isa-override-1.d | 28 +++++++++++
123 gas/testsuite/gas/mips/r5900@isa-override-1.s | 23 +++++++++
124 46 files changed, 775 insertions(+), 8 deletions(-)
125 create mode 100644 gas/testsuite/gas/mips/isa-override-1.d
126 create mode 100644 gas/testsuite/gas/mips/isa-override-1.s
127 create mode 100644 gas/testsuite/gas/mips/isa-override-2.l
128 create mode 100644 gas/testsuite/gas/mips/isa-override-2.s
129 create mode 100644 gas/testsuite/gas/mips/micromips@isa-override-1.d
130 create mode 100644 gas/testsuite/gas/mips/mips1@isa-override-1.d
131 create mode 100644 gas/testsuite/gas/mips/mips1@isa-override-2.l
132 create mode 100644 gas/testsuite/gas/mips/mips1@isa-override-2.s
133 create mode 100644 gas/testsuite/gas/mips/mips2@isa-override-1.d
134 create mode 100644 gas/testsuite/gas/mips/mips2@isa-override-2.l
135 create mode 100644 gas/testsuite/gas/mips/mips2@isa-override-2.s
136 create mode 100644 gas/testsuite/gas/mips/mips32@isa-override-1.d
137 create mode 100644 gas/testsuite/gas/mips/mips32@isa-override-2.l
138 create mode 100644 gas/testsuite/gas/mips/mips32@isa-override-2.s
139 create mode 100644 gas/testsuite/gas/mips/mips32r2@isa-override-1.d
140 create mode 100644 gas/testsuite/gas/mips/mips32r2@isa-override-2.l
141 create mode 100644 gas/testsuite/gas/mips/mips32r2@isa-override-2.s
142 create mode 100644 gas/testsuite/gas/mips/mips32r3@isa-override-1.d
143 create mode 100644 gas/testsuite/gas/mips/mips32r3@isa-override-2.l
144 create mode 100644 gas/testsuite/gas/mips/mips32r3@isa-override-2.s
145 create mode 100644 gas/testsuite/gas/mips/mips32r5@isa-override-1.d
146 create mode 100644 gas/testsuite/gas/mips/mips32r5@isa-override-2.l
147 create mode 100644 gas/testsuite/gas/mips/mips32r5@isa-override-2.s
148 create mode 100644 gas/testsuite/gas/mips/mips32r6@isa-override-1.d
149 create mode 100644 gas/testsuite/gas/mips/mips32r6@isa-override-2.l
150 create mode 100644 gas/testsuite/gas/mips/mips32r6@isa-override-2.s
151 create mode 100644 gas/testsuite/gas/mips/mips64r2@isa-override-1.d
152 create mode 100644 gas/testsuite/gas/mips/mips64r3@isa-override-1.d
153 create mode 100644 gas/testsuite/gas/mips/mips64r5@isa-override-1.d
154 create mode 100644 gas/testsuite/gas/mips/mips64r6@isa-override-1.d
155 create mode 100644 gas/testsuite/gas/mips/octeon3@isa-override-1.d
156 create mode 100644 gas/testsuite/gas/mips/octeon3@isa-override-1.l
157 create mode 100644 gas/testsuite/gas/mips/octeon3@isa-override-2.l
158 create mode 100644 gas/testsuite/gas/mips/octeon3@isa-override-2.s
159 create mode 100644 gas/testsuite/gas/mips/octeon@isa-override-1.d
160 create mode 100644 gas/testsuite/gas/mips/r3000@isa-override-1.d
161 create mode 100644 gas/testsuite/gas/mips/r3000@isa-override-2.l
162 create mode 100644 gas/testsuite/gas/mips/r3000@isa-override-2.s
163 create mode 100644 gas/testsuite/gas/mips/r3900@isa-override-1.d
164 create mode 100644 gas/testsuite/gas/mips/r3900@isa-override-2.l
165 create mode 100644 gas/testsuite/gas/mips/r3900@isa-override-2.s
166 create mode 100644 gas/testsuite/gas/mips/r5900@isa-override-1.d
167 create mode 100644 gas/testsuite/gas/mips/r5900@isa-override-1.s
169 diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
170 index bfc639e..daceef1 100644
171 --- a/gas/config/tc-mips.c
172 +++ b/gas/config/tc-mips.c
173 @@ -15513,10 +15513,29 @@ struct mips_option_stack
175 static struct mips_option_stack *mips_opts_stack;
178 +/* Return status for .set/.module option handling. */
180 +enum code_option_type
182 + /* Unrecognized option. */
183 + OPTION_TYPE_BAD = -1,
185 + /* Ordinary option. */
186 + OPTION_TYPE_NORMAL,
188 + /* ISA changing option. */
192 +/* Handle common .set/.module options. Return status indicating option
195 +static enum code_option_type
196 parse_code_option (char * name)
198 + bfd_boolean isa_set = FALSE;
199 const struct mips_ase *ase;
201 if (strncmp (name, "at=", 3) == 0)
204 @@ -15589,6 +15608,7 @@ parse_code_option (char * name)
206 mips_opts.arch = p->cpu;
207 mips_opts.isa = p->isa;
211 else if (strncmp (name, "mips", 4) == 0)
212 @@ -15602,6 +15622,7 @@ parse_code_option (char * name)
214 mips_opts.arch = p->cpu;
215 mips_opts.isa = p->isa;
220 @@ -15620,8 +15641,9 @@ parse_code_option (char * name)
221 else if (strcmp (name, "nosym32") == 0)
222 mips_opts.sym32 = FALSE;
226 + return OPTION_TYPE_BAD;
228 + return isa_set ? OPTION_TYPE_ISA : OPTION_TYPE_NORMAL;
231 /* Handle the .set pseudo-op. */
232 @@ -15629,8 +15651,8 @@ parse_code_option (char * name)
234 s_mipsset (int x ATTRIBUTE_UNUSED)
236 + enum code_option_type type = OPTION_TYPE_NORMAL;
237 char *name = input_line_pointer, ch;
238 - int prev_isa = mips_opts.isa;
240 file_mips_check_options ();
242 @@ -15707,12 +15729,16 @@ s_mipsset (int x ATTRIBUTE_UNUSED)
246 - else if (!parse_code_option (name))
247 - as_warn (_("tried to set unrecognized symbol: %s\n"), name);
250 + type = parse_code_option (name);
251 + if (type == OPTION_TYPE_BAD)
252 + as_warn (_("tried to set unrecognized symbol: %s\n"), name);
255 /* The use of .set [arch|cpu]= historically 'fixes' the width of gp and fp
256 registers based on what is supported by the arch/cpu. */
257 - if (mips_opts.isa != prev_isa)
258 + if (type == OPTION_TYPE_ISA)
260 switch (mips_opts.isa)
262 @@ -15779,7 +15805,7 @@ s_module (int ignore ATTRIBUTE_UNUSED)
264 if (!file_mips_opts_checked)
266 - if (!parse_code_option (name))
267 + if (parse_code_option (name) == OPTION_TYPE_BAD)
268 as_bad (_(".module used with unrecognized symbol: %s\n"), name);
270 /* Update module level settings from mips_opts. */