0001-binutils-2.38-vs.-ppc32-linux-kernel.patch 2.2 KB

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