@@ -161,6 +161,33 @@ TEST_P(BinaryContextTester, FlushPendingRelocJUMP26) {
161
161
<< " Wrong forward branch value\n " ;
162
162
}
163
163
164
+ // TODO: BOLT currently asserts when a relocation is out of range.
165
+ TEST_P (BinaryContextTester, FlushOptionalOutOfRangePendingRelocCALL26) {
166
+ if (GetParam () != Triple::aarch64)
167
+ GTEST_SKIP ();
168
+
169
+ // This test checks that flushPendingRelocations skips flushing any optional
170
+ // pending relocations that cannot be encoded.
171
+
172
+ BinarySection &BS = BC->registerOrUpdateSection (
173
+ " .text" , ELF::SHT_PROGBITS, ELF::SHF_EXECINSTR | ELF::SHF_ALLOC);
174
+ MCSymbol *RelSymbol = BC->getOrCreateGlobalSymbol (4 , " Func" );
175
+ ASSERT_TRUE (RelSymbol);
176
+ BS.addPendingRelocation (
177
+ Relocation{8 , RelSymbol, ELF::R_AARCH64_CALL26, 0 , 0 });
178
+
179
+ SmallVector<char > Vect;
180
+ raw_svector_ostream OS (Vect);
181
+
182
+ // FIXME: bolt must be able to skip pending relocs that are out of range.
183
+ EXPECT_DEBUG_DEATH (
184
+ // Resolve relocation symbol to a high value so encoding will be out of
185
+ // range.
186
+ BS.flushPendingRelocations (OS,
187
+ [&](const MCSymbol *S) { return 0x800000F ; }),
188
+ " .*only PC \\ +/- 128MB is allowed for direct call" );
189
+ }
190
+
164
191
#endif
165
192
166
193
TEST_P (BinaryContextTester, BaseAddress) {
0 commit comments