2#error "ELF_RELOC must be defined"
5// These types and values are from the LoongArch ELF psABI which can be found at
6// https://github.com/loongson/LoongArch-Documentation
7// and these definitions has been adopted by binutils (include/elf/loongarch.h).
8// The commit hash (main branch) we reference is:
9// 9b3bd9f4a497115913c22f1a2a47863798fbc02a
11ELF_RELOC(LARCH_NONE, 0)
14ELF_RELOC(LARCH_RELATIVE, 3)
15ELF_RELOC(LARCH_COPY, 4)
16ELF_RELOC(LARCH_JUMP_SLOT, 5)
17ELF_RELOC(LARCH_TLS_DTPMOD32, 6)
18ELF_RELOC(LARCH_TLS_DTPMOD64, 7)
19ELF_RELOC(LARCH_TLS_DTPREL32, 8)
20ELF_RELOC(LARCH_TLS_DTPREL64, 9)
21ELF_RELOC(LARCH_TLS_TPREL32, 10)
22ELF_RELOC(LARCH_TLS_TPREL64, 11)
23ELF_RELOC(LARCH_IRELATIVE, 12)
24ELF_RELOC(LARCH_MARK_LA, 20)
25ELF_RELOC(LARCH_MARK_PCREL, 21)
26ELF_RELOC(LARCH_SOP_PUSH_PCREL, 22)
27ELF_RELOC(LARCH_SOP_PUSH_ABSOLUTE, 23)
28ELF_RELOC(LARCH_SOP_PUSH_DUP, 24)
29ELF_RELOC(LARCH_SOP_PUSH_GPREL, 25)
30ELF_RELOC(LARCH_SOP_PUSH_TLS_TPREL, 26)
31ELF_RELOC(LARCH_SOP_PUSH_TLS_GOT, 27)
32ELF_RELOC(LARCH_SOP_PUSH_TLS_GD, 28)
33ELF_RELOC(LARCH_SOP_PUSH_PLT_PCREL, 29)
34ELF_RELOC(LARCH_SOP_ASSERT, 30)
35ELF_RELOC(LARCH_SOP_NOT, 31)
36ELF_RELOC(LARCH_SOP_SUB, 32)
37ELF_RELOC(LARCH_SOP_SL, 33)
38ELF_RELOC(LARCH_SOP_SR, 34)
39ELF_RELOC(LARCH_SOP_ADD, 35)
40ELF_RELOC(LARCH_SOP_AND, 36)
41ELF_RELOC(LARCH_SOP_IF_ELSE, 37)
42ELF_RELOC(LARCH_SOP_POP_32_S_10_5, 38)
43ELF_RELOC(LARCH_SOP_POP_32_U_10_12, 39)
44ELF_RELOC(LARCH_SOP_POP_32_S_10_12, 40)
45ELF_RELOC(LARCH_SOP_POP_32_S_10_16, 41)
46ELF_RELOC(LARCH_SOP_POP_32_S_10_16_S2, 42)
47ELF_RELOC(LARCH_SOP_POP_32_S_5_20, 43)
48ELF_RELOC(LARCH_SOP_POP_32_S_0_5_10_16_S2, 44)
49ELF_RELOC(LARCH_SOP_POP_32_S_0_10_10_16_S2, 45)
50ELF_RELOC(LARCH_SOP_POP_32_U, 46)
51ELF_RELOC(LARCH_ADD8, 47)
52ELF_RELOC(LARCH_ADD16, 48)
53ELF_RELOC(LARCH_ADD24, 49)
54ELF_RELOC(LARCH_ADD32, 50)
55ELF_RELOC(LARCH_ADD64, 51)
56ELF_RELOC(LARCH_SUB8, 52)
57ELF_RELOC(LARCH_SUB16, 53)
58ELF_RELOC(LARCH_SUB24, 54)
59ELF_RELOC(LARCH_SUB32, 55)
60ELF_RELOC(LARCH_SUB64, 56)
61ELF_RELOC(LARCH_GNU_VTINHERIT, 57)
62ELF_RELOC(LARCH_GNU_VTENTRY, 58)
64// Relocs whose processing do not require a stack machine.
66// Spec addition: https://github.com/loongson/LoongArch-Documentation/pull/57
67// Binutils commit 6d13722a97cee3fd397e116bde3bcedbb1e220be
68// and commit 9801120721c3a702ce3bd50433ef920f92a83502
69ELF_RELOC(LARCH_B16, 64)
70ELF_RELOC(LARCH_B21, 65)
71ELF_RELOC(LARCH_B26, 66)
72ELF_RELOC(LARCH_ABS_HI20, 67)
73ELF_RELOC(LARCH_ABS_LO12, 68)
74ELF_RELOC(LARCH_ABS64_LO20, 69)
75ELF_RELOC(LARCH_ABS64_HI12, 70)
76ELF_RELOC(LARCH_PCALA_HI20, 71)
77ELF_RELOC(LARCH_PCALA_LO12, 72)
78ELF_RELOC(LARCH_PCALA64_LO20, 73)
79ELF_RELOC(LARCH_PCALA64_HI12, 74)
80ELF_RELOC(LARCH_GOT_PC_HI20, 75)
81ELF_RELOC(LARCH_GOT_PC_LO12, 76)
82ELF_RELOC(LARCH_GOT64_PC_LO20, 77)
83ELF_RELOC(LARCH_GOT64_PC_HI12, 78)
84ELF_RELOC(LARCH_GOT_HI20, 79)
85ELF_RELOC(LARCH_GOT_LO12, 80)
86ELF_RELOC(LARCH_GOT64_LO20, 81)
87ELF_RELOC(LARCH_GOT64_HI12, 82)
88ELF_RELOC(LARCH_TLS_LE_HI20, 83)
89ELF_RELOC(LARCH_TLS_LE_LO12, 84)
90ELF_RELOC(LARCH_TLS_LE64_LO20, 85)
91ELF_RELOC(LARCH_TLS_LE64_HI12, 86)
92ELF_RELOC(LARCH_TLS_IE_PC_HI20, 87)
93ELF_RELOC(LARCH_TLS_IE_PC_LO12, 88)
94ELF_RELOC(LARCH_TLS_IE64_PC_LO20, 89)
95ELF_RELOC(LARCH_TLS_IE64_PC_HI12, 90)
96ELF_RELOC(LARCH_TLS_IE_HI20, 91)
97ELF_RELOC(LARCH_TLS_IE_LO12, 92)
98ELF_RELOC(LARCH_TLS_IE64_LO20, 93)
99ELF_RELOC(LARCH_TLS_IE64_HI12, 94)
100ELF_RELOC(LARCH_TLS_LD_PC_HI20, 95)
101ELF_RELOC(LARCH_TLS_LD_HI20, 96)
102ELF_RELOC(LARCH_TLS_GD_PC_HI20, 97)
103ELF_RELOC(LARCH_TLS_GD_HI20, 98)
104ELF_RELOC(LARCH_32_PCREL, 99)
105ELF_RELOC(LARCH_RELAX, 100)
107// Relocs added in ELF for the LoongArchâ„¢ Architecture v20230519, part of the
108// v2.10 LoongArch ABI specs.
110// Spec addition: https://github.com/loongson/la-abi-specs/pull/1
111// Binutils commit 57a930e3bfe4b2c7fd6463ed39311e1938513138
112// Note that the 101 and 104 relocation numbers are defined as R_LARCH_DELETE
113// and R_LARCH_CFA respectively in psABI 2.10. But they are marked as reserved
114// in psABI v2.20 because they were proved not necessary to be exposed outside
116ELF_RELOC(LARCH_ALIGN, 102)
117ELF_RELOC(LARCH_PCREL20_S2, 103)
118ELF_RELOC(LARCH_ADD6, 105)
119ELF_RELOC(LARCH_SUB6, 106)
120ELF_RELOC(LARCH_ADD_ULEB128, 107)
121ELF_RELOC(LARCH_SUB_ULEB128, 108)
122ELF_RELOC(LARCH_64_PCREL, 109)
124// Relocs added in ELF for the LoongArchâ„¢ Architecture v20231102, part of the
125// v2.20 LoongArch ABI specs.
127// Spec addition: https://github.com/loongson/la-abi-specs/pull/4
128ELF_RELOC(LARCH_CALL36, 110)
130// Relocs added in ELF for the LoongArchâ„¢ Architecture v20231219, part of the
131// v2.30 LoongArch ABI specs.
133// Spec addition: https://github.com/loongson/la-abi-specs/pull/5
134ELF_RELOC(LARCH_TLS_DESC32, 13)
135ELF_RELOC(LARCH_TLS_DESC64, 14)
136ELF_RELOC(LARCH_TLS_DESC_PC_HI20, 111)
137ELF_RELOC(LARCH_TLS_DESC_PC_LO12, 112)
138ELF_RELOC(LARCH_TLS_DESC64_PC_LO20, 113)
139ELF_RELOC(LARCH_TLS_DESC64_PC_HI12, 114)
140ELF_RELOC(LARCH_TLS_DESC_HI20, 115)
141ELF_RELOC(LARCH_TLS_DESC_LO12, 116)
142ELF_RELOC(LARCH_TLS_DESC64_LO20, 117)
143ELF_RELOC(LARCH_TLS_DESC64_HI12, 118)
144ELF_RELOC(LARCH_TLS_DESC_LD, 119)
145ELF_RELOC(LARCH_TLS_DESC_CALL, 120)
146ELF_RELOC(LARCH_TLS_LE_HI20_R, 121)
147ELF_RELOC(LARCH_TLS_LE_ADD_R, 122)
148ELF_RELOC(LARCH_TLS_LE_LO12_R, 123)
149ELF_RELOC(LARCH_TLS_LD_PCREL20_S2, 124)
150ELF_RELOC(LARCH_TLS_GD_PCREL20_S2, 125)
151ELF_RELOC(LARCH_TLS_DESC_PCREL20_S2, 126)