055-Re-PowerPC64-pcrel-got-relocs-against-local-symbols.patch 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. From 010db38b54b589ca3e95b498aba2831064970171 Mon Sep 17 00:00:00 2001
  2. From: Alan Modra <[email protected]>
  3. Date: Wed, 21 Sep 2022 09:06:29 +0930
  4. Subject: [PATCH 055/160] Re: PowerPC64 pcrel got relocs against local symbols
  5. The last patch wasn't all that shiny. There are rather a lot more
  6. relocations that can hit the assertion in md_apply_fix if the symbol
  7. is local or absolute. Fix them all.
  8. * config/tc-ppc.c (ppc_force_relocation): Add all relocs that
  9. expect a symbol in md_apply_fix. Remove tls pcrel relocs
  10. already covered in general tls match range.
  11. (cherry picked from commit 8b168f1a1e09e337d2a970f204a0230c091bbe58)
  12. ---
  13. gas/config/tc-ppc.c | 58 ++++++++++++++++++++++++++++++++++++++++-----
  14. 1 file changed, 52 insertions(+), 6 deletions(-)
  15. --- a/gas/config/tc-ppc.c
  16. +++ b/gas/config/tc-ppc.c
  17. @@ -6666,8 +6666,6 @@ ppc_force_relocation (fixS *fix)
  18. int
  19. ppc_force_relocation (fixS *fix)
  20. {
  21. - /* Branch prediction relocations must force a relocation, as must
  22. - the vtable description relocs. */
  23. switch (fix->fx_r_type)
  24. {
  25. case BFD_RELOC_PPC_B16_BRTAKEN:
  26. @@ -6676,12 +6674,60 @@ ppc_force_relocation (fixS *fix)
  27. case BFD_RELOC_PPC_BA16_BRNTAKEN:
  28. case BFD_RELOC_24_PLT_PCREL:
  29. case BFD_RELOC_PPC64_TOC:
  30. + case BFD_RELOC_16_GOTOFF:
  31. + case BFD_RELOC_LO16_GOTOFF:
  32. + case BFD_RELOC_HI16_GOTOFF:
  33. + case BFD_RELOC_HI16_S_GOTOFF:
  34. + case BFD_RELOC_LO16_PLTOFF:
  35. + case BFD_RELOC_HI16_PLTOFF:
  36. + case BFD_RELOC_HI16_S_PLTOFF:
  37. + case BFD_RELOC_GPREL16:
  38. + case BFD_RELOC_16_BASEREL:
  39. + case BFD_RELOC_LO16_BASEREL:
  40. + case BFD_RELOC_HI16_BASEREL:
  41. + case BFD_RELOC_HI16_S_BASEREL:
  42. + case BFD_RELOC_PPC_TOC16:
  43. + case BFD_RELOC_PPC64_TOC16_LO:
  44. + case BFD_RELOC_PPC64_TOC16_HI:
  45. + case BFD_RELOC_PPC64_TOC16_HA:
  46. + case BFD_RELOC_PPC64_PLTGOT16:
  47. + case BFD_RELOC_PPC64_PLTGOT16_LO:
  48. + case BFD_RELOC_PPC64_PLTGOT16_HI:
  49. + case BFD_RELOC_PPC64_PLTGOT16_HA:
  50. + case BFD_RELOC_PPC64_GOT16_DS:
  51. + case BFD_RELOC_PPC64_GOT16_LO_DS:
  52. + case BFD_RELOC_PPC64_PLT16_LO_DS:
  53. + case BFD_RELOC_PPC64_SECTOFF_DS:
  54. + case BFD_RELOC_PPC64_SECTOFF_LO_DS:
  55. + case BFD_RELOC_PPC64_TOC16_DS:
  56. + case BFD_RELOC_PPC64_TOC16_LO_DS:
  57. + case BFD_RELOC_PPC64_PLTGOT16_DS:
  58. + case BFD_RELOC_PPC64_PLTGOT16_LO_DS:
  59. + case BFD_RELOC_PPC_EMB_NADDR16:
  60. + case BFD_RELOC_PPC_EMB_NADDR16_LO:
  61. + case BFD_RELOC_PPC_EMB_NADDR16_HI:
  62. + case BFD_RELOC_PPC_EMB_NADDR16_HA:
  63. + case BFD_RELOC_PPC_EMB_SDAI16:
  64. + case BFD_RELOC_PPC_EMB_SDA2I16:
  65. + case BFD_RELOC_PPC_EMB_SDA2REL:
  66. + case BFD_RELOC_PPC_EMB_SDA21:
  67. + case BFD_RELOC_PPC_EMB_MRKREF:
  68. + case BFD_RELOC_PPC_EMB_RELSEC16:
  69. + case BFD_RELOC_PPC_EMB_RELST_LO:
  70. + case BFD_RELOC_PPC_EMB_RELST_HI:
  71. + case BFD_RELOC_PPC_EMB_RELST_HA:
  72. + case BFD_RELOC_PPC_EMB_BIT_FLD:
  73. + case BFD_RELOC_PPC_EMB_RELSDA:
  74. + case BFD_RELOC_PPC_VLE_SDA21:
  75. + case BFD_RELOC_PPC_VLE_SDA21_LO:
  76. + case BFD_RELOC_PPC_VLE_SDAREL_LO16A:
  77. + case BFD_RELOC_PPC_VLE_SDAREL_LO16D:
  78. + case BFD_RELOC_PPC_VLE_SDAREL_HI16A:
  79. + case BFD_RELOC_PPC_VLE_SDAREL_HI16D:
  80. + case BFD_RELOC_PPC_VLE_SDAREL_HA16A:
  81. + case BFD_RELOC_PPC_VLE_SDAREL_HA16D:
  82. case BFD_RELOC_PPC64_PLT_PCREL34:
  83. case BFD_RELOC_PPC64_GOT_PCREL34:
  84. - case BFD_RELOC_PPC64_GOT_TLSGD_PCREL34:
  85. - case BFD_RELOC_PPC64_GOT_TLSLD_PCREL34:
  86. - case BFD_RELOC_PPC64_GOT_TPREL_PCREL34:
  87. - case BFD_RELOC_PPC64_GOT_DTPREL_PCREL34:
  88. return 1;
  89. case BFD_RELOC_PPC_B26:
  90. case BFD_RELOC_PPC_BA26: