@@ -220,18 +220,6 @@ patch_aarch64_12(unsigned char *location, uint64_t value)
220220 set_bits (loc32 , 10 , value , shift , 12 );
221221}
222222
223- // Relaxable 12-bit low part of an absolute address. Pairs nicely with
224- // patch_aarch64_21rx (below).
225- void
226- patch_aarch64_12x (unsigned char * location , uint64_t value )
227- {
228- // This can *only* be relaxed if it occurs immediately before a matching
229- // patch_aarch64_21rx. If that happens, the JIT build step will replace both
230- // calls with a single call to patch_aarch64_33rx. Otherwise, we end up
231- // here, and the instruction is patched normally:
232- patch_aarch64_12 (location , value );
233- }
234-
235223// 16-bit low part of an absolute address.
236224void
237225patch_aarch64_16a (unsigned char * location , uint64_t value )
@@ -292,18 +280,6 @@ patch_aarch64_21r(unsigned char *location, uint64_t value)
292280 set_bits (loc32 , 5 , value , 2 , 19 );
293281}
294282
295- // Relaxable 21-bit count of pages between this page and an absolute address's
296- // page. Pairs nicely with patch_aarch64_12x (above).
297- void
298- patch_aarch64_21rx (unsigned char * location , uint64_t value )
299- {
300- // This can *only* be relaxed if it occurs immediately before a matching
301- // patch_aarch64_12x. If that happens, the JIT build step will replace both
302- // calls with a single call to patch_aarch64_33rx. Otherwise, we end up
303- // here, and the instruction is patched normally:
304- patch_aarch64_21r (location , value );
305- }
306-
307283// 28-bit relative branch.
308284void
309285patch_aarch64_26r (unsigned char * location , uint64_t value )
@@ -319,46 +295,6 @@ patch_aarch64_26r(unsigned char *location, uint64_t value)
319295 set_bits (loc32 , 0 , value , 2 , 26 );
320296}
321297
322- // A pair of patch_aarch64_21rx and patch_aarch64_12x.
323- void
324- patch_aarch64_33rx (unsigned char * location , uint64_t value )
325- {
326- uint32_t * loc32 = (uint32_t * )location ;
327- // Try to relax the pair of GOT loads into an immediate value:
328- assert (IS_AARCH64_ADRP (* loc32 ));
329- unsigned char reg = get_bits (loc32 [0 ], 0 , 5 );
330- assert (IS_AARCH64_LDR_OR_STR (loc32 [1 ]));
331- // There should be only one register involved:
332- assert (reg == get_bits (loc32 [1 ], 0 , 5 )); // ldr's output register.
333- assert (reg == get_bits (loc32 [1 ], 5 , 5 )); // ldr's input register.
334- uint64_t relaxed = * (uint64_t * )value ;
335- if (relaxed < (1UL << 16 )) {
336- // adrp reg, AAA; ldr reg, [reg + BBB] -> movz reg, XXX; nop
337- loc32 [0 ] = 0xD2800000 | (get_bits (relaxed , 0 , 16 ) << 5 ) | reg ;
338- loc32 [1 ] = 0xD503201F ;
339- return ;
340- }
341- if (relaxed < (1ULL << 32 )) {
342- // adrp reg, AAA; ldr reg, [reg + BBB] -> movz reg, XXX; movk reg, YYY
343- loc32 [0 ] = 0xD2800000 | (get_bits (relaxed , 0 , 16 ) << 5 ) | reg ;
344- loc32 [1 ] = 0xF2A00000 | (get_bits (relaxed , 16 , 16 ) << 5 ) | reg ;
345- return ;
346- }
347- relaxed = value - (uintptr_t )location ;
348- if ((relaxed & 0x3 ) == 0 &&
349- (int64_t )relaxed >= - (1L << 19 ) &&
350- (int64_t )relaxed < (1L << 19 ))
351- {
352- // adrp reg, AAA; ldr reg, [reg + BBB] -> ldr reg, XXX; nop
353- loc32 [0 ] = 0x58000000 | (get_bits (relaxed , 2 , 19 ) << 5 ) | reg ;
354- loc32 [1 ] = 0xD503201F ;
355- return ;
356- }
357- // Couldn't do it. Just patch the two instructions normally:
358- patch_aarch64_21rx (location , value );
359- patch_aarch64_12x (location + 4 , value );
360- }
361-
362298// Relaxable 32-bit relative address.
363299void
364300patch_x86_64_32rx (unsigned char * location , uint64_t value )
0 commit comments