@@ -355,18 +355,6 @@ patch_aarch64_12(unsigned char *location, uint64_t value)
355355 set_bits (loc32 , 10 , value , shift , 12 );
356356}
357357
358- // Relaxable 12-bit low part of an absolute address. Pairs nicely with
359- // patch_aarch64_21rx (below).
360- void
361- patch_aarch64_12x (unsigned char * location , uint64_t value )
362- {
363- // This can *only* be relaxed if it occurs immediately before a matching
364- // patch_aarch64_21rx. If that happens, the JIT build step will replace both
365- // calls with a single call to patch_aarch64_33rx. Otherwise, we end up
366- // here, and the instruction is patched normally:
367- patch_aarch64_12 (location , value );
368- }
369-
370358// 16-bit low part of an absolute address.
371359void
372360patch_aarch64_16a (unsigned char * location , uint64_t value )
@@ -427,18 +415,6 @@ patch_aarch64_21r(unsigned char *location, uint64_t value)
427415 set_bits (loc32 , 5 , value , 2 , 19 );
428416}
429417
430- // Relaxable 21-bit count of pages between this page and an absolute address's
431- // page. Pairs nicely with patch_aarch64_12x (above).
432- void
433- patch_aarch64_21rx (unsigned char * location , uint64_t value )
434- {
435- // This can *only* be relaxed if it occurs immediately before a matching
436- // patch_aarch64_12x. If that happens, the JIT build step will replace both
437- // calls with a single call to patch_aarch64_33rx. Otherwise, we end up
438- // here, and the instruction is patched normally:
439- patch_aarch64_21r (location , value );
440- }
441-
442418// 21-bit relative branch.
443419void
444420patch_aarch64_19r (unsigned char * location , uint64_t value )
@@ -469,55 +445,6 @@ patch_aarch64_26r(unsigned char *location, uint64_t value)
469445 set_bits (loc32 , 0 , value , 2 , 26 );
470446}
471447
472- // A pair of patch_aarch64_21rx and patch_aarch64_12x.
473- void
474- patch_aarch64_33rx (unsigned char * location , uint64_t value )
475- {
476- uint32_t * loc32 = (uint32_t * )location ;
477- // Try to relax the pair of GOT loads into an immediate value:
478- assert (IS_AARCH64_ADRP (* loc32 ));
479- unsigned char reg = get_bits (loc32 [0 ], 0 , 5 );
480- assert (IS_AARCH64_LDR_OR_STR (loc32 [1 ]));
481- // There should be only one register involved:
482- assert (reg == get_bits (loc32 [1 ], 0 , 5 )); // ldr's output register.
483- assert (reg == get_bits (loc32 [1 ], 5 , 5 )); // ldr's input register.
484- uint64_t relaxed = * (uint64_t * )value ;
485- if (relaxed < (1UL << 16 )) {
486- // adrp reg, AAA; ldr reg, [reg + BBB] -> movz reg, XXX; nop
487- loc32 [0 ] = 0xD2800000 | (get_bits (relaxed , 0 , 16 ) << 5 ) | reg ;
488- loc32 [1 ] = 0xD503201F ;
489- return ;
490- }
491- if (relaxed < (1ULL << 32 )) {
492- // adrp reg, AAA; ldr reg, [reg + BBB] -> movz reg, XXX; movk reg, YYY
493- loc32 [0 ] = 0xD2800000 | (get_bits (relaxed , 0 , 16 ) << 5 ) | reg ;
494- loc32 [1 ] = 0xF2A00000 | (get_bits (relaxed , 16 , 16 ) << 5 ) | reg ;
495- return ;
496- }
497- int64_t page_delta = (relaxed >> 12 ) - ((uintptr_t )location >> 12 );
498- if (page_delta >= - (1L << 20 ) &&
499- page_delta < (1L << 20 ))
500- {
501- // adrp reg, AAA; ldr reg, [reg + BBB] -> adrp reg, AAA; add reg, reg, BBB
502- patch_aarch64_21rx (location , relaxed );
503- loc32 [1 ] = 0x91000000 | get_bits (relaxed , 0 , 12 ) << 10 | reg << 5 | reg ;
504- return ;
505- }
506- relaxed = value - (uintptr_t )location ;
507- if ((relaxed & 0x3 ) == 0 &&
508- (int64_t )relaxed >= - (1L << 19 ) &&
509- (int64_t )relaxed < (1L << 19 ))
510- {
511- // adrp reg, AAA; ldr reg, [reg + BBB] -> ldr reg, XXX; nop
512- loc32 [0 ] = 0x58000000 | (get_bits (relaxed , 2 , 19 ) << 5 ) | reg ;
513- loc32 [1 ] = 0xD503201F ;
514- return ;
515- }
516- // Couldn't do it. Just patch the two instructions normally:
517- patch_aarch64_21rx (location , value );
518- patch_aarch64_12x (location + 4 , value );
519- }
520-
521448// Relaxable 32-bit relative address.
522449void
523450patch_x86_64_32rx (unsigned char * location , uint64_t value )
0 commit comments