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