1 From cebc89b9328eab994f6b0314c263f94e7949a553 Mon Sep 17 00:00:00 2001
2 From: Alan Modra <amodra@gmail.com>
3 Date: Mon, 21 Feb 2022 10:58:57 +1030
4 Subject: [PATCH] binutils 2.38 vs. ppc32 linux kernel
6 Commit b25f942e18d6 made .machine more strict. Weaken it again.
8 * config/tc-ppc.c (ppc_machine): Treat an early .machine specially,
9 keeping sticky options to work around gcc bugs.
11 gas/config/tc-ppc.c | 25 ++++++++++++++++++++++++-
12 1 file changed, 24 insertions(+), 1 deletion(-)
14 diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c
15 index 054f9c72161..89bc7d3f9b9 100644
16 --- a/gas/config/tc-ppc.c
17 +++ b/gas/config/tc-ppc.c
18 @@ -5965,7 +5965,30 @@ ppc_machine (int ignore ATTRIBUTE_UNUSED)
19 options do not count as a new machine, instead they add
20 to currently selected opcodes. */
21 ppc_cpu_t machine_sticky = 0;
22 - new_cpu = ppc_parse_cpu (ppc_cpu, &machine_sticky, cpu_string);
23 + /* Unfortunately, some versions of gcc emit a .machine
24 + directive very near the start of the compiler's assembly
25 + output file. This is bad because it overrides user -Wa
26 + cpu selection. Worse, there are versions of gcc that
27 + emit the *wrong* cpu, not even respecting the -mcpu given
28 + to gcc. See gcc pr101393. And to compound the problem,
29 + as of 20220222 gcc doesn't pass the correct cpu option to
30 + gas on the command line. See gcc pr59828. Hack around
31 + this by keeping sticky options for an early .machine. */
33 + for (sec = stdoutput->sections; sec != NULL; sec = sec->next)
35 + segment_info_type *info = seg_info (sec);
36 + /* Are the frags for this section perturbed from their
37 + initial state? Even .align will count here. */
39 + && (info->frchainP->frch_root != info->frchainP->frch_last
40 + || info->frchainP->frch_root->fr_type != rs_fill
41 + || info->frchainP->frch_root->fr_fix != 0))
44 + new_cpu = ppc_parse_cpu (ppc_cpu,
45 + sec == NULL ? &sticky : &machine_sticky,