@@ -57,6 +57,7 @@ class ARMV7ABSLongThunk final : public Thunk {
57
57
uint32_t size () const override { return 12 ; }
58
58
void writeTo (uint8_t *Buf, ThunkSection &IS) const override ;
59
59
void addSymbols (ThunkSection &IS) override ;
60
+ bool isCompatibleWith (uint32_t RelocType) const override ;
60
61
};
61
62
62
63
class ARMV7PILongThunk final : public Thunk {
@@ -66,6 +67,7 @@ class ARMV7PILongThunk final : public Thunk {
66
67
uint32_t size () const override { return 16 ; }
67
68
void writeTo (uint8_t *Buf, ThunkSection &IS) const override ;
68
69
void addSymbols (ThunkSection &IS) override ;
70
+ bool isCompatibleWith (uint32_t RelocType) const override ;
69
71
};
70
72
71
73
class ThumbV7ABSLongThunk final : public Thunk {
@@ -77,6 +79,7 @@ class ThumbV7ABSLongThunk final : public Thunk {
77
79
uint32_t size () const override { return 10 ; }
78
80
void writeTo (uint8_t *Buf, ThunkSection &IS) const override ;
79
81
void addSymbols (ThunkSection &IS) override ;
82
+ bool isCompatibleWith (uint32_t RelocType) const override ;
80
83
};
81
84
82
85
class ThumbV7PILongThunk final : public Thunk {
@@ -88,6 +91,7 @@ class ThumbV7PILongThunk final : public Thunk {
88
91
uint32_t size () const override { return 12 ; }
89
92
void writeTo (uint8_t *Buf, ThunkSection &IS) const override ;
90
93
void addSymbols (ThunkSection &IS) override ;
94
+ bool isCompatibleWith (uint32_t RelocType) const override ;
91
95
};
92
96
93
97
// MIPS LA25 thunk
@@ -128,6 +132,11 @@ void ARMV7ABSLongThunk::addSymbols(ThunkSection &IS) {
128
132
addSyntheticLocal (" $a" , STT_NOTYPE, Offset, 0 , &IS);
129
133
}
130
134
135
+ bool ARMV7ABSLongThunk::isCompatibleWith (uint32_t RelocType) const {
136
+ // Thumb branch relocations can't use BLX
137
+ return RelocType != R_ARM_THM_JUMP19 && RelocType != R_ARM_THM_JUMP24;
138
+ }
139
+
131
140
void ThumbV7ABSLongThunk::writeTo (uint8_t *Buf, ThunkSection &IS) const {
132
141
const uint8_t Data[] = {
133
142
0x40 , 0xf2 , 0x00 , 0x0c , // movw ip, :lower16:S
@@ -147,6 +156,12 @@ void ThumbV7ABSLongThunk::addSymbols(ThunkSection &IS) {
147
156
addSyntheticLocal (" $t" , STT_NOTYPE, Offset, 0 , &IS);
148
157
}
149
158
159
+ bool ThumbV7ABSLongThunk::isCompatibleWith (uint32_t RelocType) const {
160
+ // ARM branch relocations can't use BLX
161
+ return RelocType != R_ARM_JUMP24 && RelocType != R_ARM_PC24 &&
162
+ RelocType != R_ARM_PLT32;
163
+ }
164
+
150
165
void ARMV7PILongThunk::writeTo (uint8_t *Buf, ThunkSection &IS) const {
151
166
const uint8_t Data[] = {
152
167
0xf0 , 0xcf , 0x0f , 0xe3 , // P: movw ip,:lower16:S - (P + (L1-P) +8)
@@ -168,6 +183,11 @@ void ARMV7PILongThunk::addSymbols(ThunkSection &IS) {
168
183
addSyntheticLocal (" $a" , STT_NOTYPE, Offset, 0 , &IS);
169
184
}
170
185
186
+ bool ARMV7PILongThunk::isCompatibleWith (uint32_t RelocType) const {
187
+ // Thumb branch relocations can't use BLX
188
+ return RelocType != R_ARM_THM_JUMP19 && RelocType != R_ARM_THM_JUMP24;
189
+ }
190
+
171
191
void ThumbV7PILongThunk::writeTo (uint8_t *Buf, ThunkSection &IS) const {
172
192
const uint8_t Data[] = {
173
193
0x4f , 0xf6 , 0xf4 , 0x7c , // P: movw ip,:lower16:S - (P + (L1-P) + 4)
@@ -189,6 +209,12 @@ void ThumbV7PILongThunk::addSymbols(ThunkSection &IS) {
189
209
addSyntheticLocal (" $t" , STT_NOTYPE, Offset, 0 , &IS);
190
210
}
191
211
212
+ bool ThumbV7PILongThunk::isCompatibleWith (uint32_t RelocType) const {
213
+ // ARM branch relocations can't use BLX
214
+ return RelocType != R_ARM_JUMP24 && RelocType != R_ARM_PC24 &&
215
+ RelocType != R_ARM_PLT32;
216
+ }
217
+
192
218
// Write MIPS LA25 thunk code to call PIC function from the non-PIC one.
193
219
void MipsThunk::writeTo (uint8_t *Buf, ThunkSection &) const {
194
220
uint64_t S = Destination.getVA ();
0 commit comments