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