@@ -376,6 +376,7 @@ impl FormatterOutput for InstructionFormatterOutput<'_> {
376376 ( NumberKind :: Int8 | NumberKind :: UInt8 , 1 )
377377 | ( NumberKind :: Int16 | NumberKind :: UInt16 , 2 )
378378 | ( NumberKind :: Int32 | NumberKind :: UInt32 , 4 )
379+ | ( NumberKind :: Int64 | NumberKind :: UInt64 , 4 ) // x86_64
379380 | ( NumberKind :: Int64 | NumberKind :: UInt64 , 8 ) => true ,
380381 _ => false ,
381382 }
@@ -658,4 +659,74 @@ mod test {
658659 InstructionPart :: basic( "]" ) ,
659660 ] ) ;
660661 }
662+
663+ #[ test]
664+ fn test_process_x86_64_instruction_with_reloc_1 ( ) {
665+ let arch = ArchX86 { arch : Architecture :: X86_64 , endianness : object:: Endianness :: Little } ;
666+ let code = [ 0x48 , 0x8b , 0x05 , 0x00 , 0x00 , 0x00 , 0x00 ] ;
667+ let opcode = iced_x86:: Mnemonic :: Mov as u16 ;
668+ let mut parts = Vec :: new ( ) ;
669+ arch. display_instruction (
670+ ResolvedInstructionRef {
671+ ins_ref : InstructionRef { address : 0x1234 , size : 7 , opcode } ,
672+ code : & code,
673+ relocation : Some ( ResolvedRelocation {
674+ relocation : & Relocation {
675+ flags : RelocationFlags :: Coff ( pe:: IMAGE_REL_AMD64_REL32 ) ,
676+ address : 0x1234 + 3 ,
677+ target_symbol : 0 ,
678+ addend : 0 ,
679+ } ,
680+ symbol : & Default :: default ( ) ,
681+ } ) ,
682+ ..Default :: default ( )
683+ } ,
684+ & DiffObjConfig :: default ( ) ,
685+ & mut |part| {
686+ parts. push ( part. into_static ( ) ) ;
687+ Ok ( ( ) )
688+ } ,
689+ )
690+ . unwrap ( ) ;
691+ assert_eq ! ( parts, & [
692+ InstructionPart :: opcode( "mov" , opcode) ,
693+ InstructionPart :: opaque( "rax" ) ,
694+ InstructionPart :: basic( "," ) ,
695+ InstructionPart :: basic( " " ) ,
696+ InstructionPart :: basic( "[" ) ,
697+ InstructionPart :: reloc( ) ,
698+ InstructionPart :: basic( "]" ) ,
699+ ] ) ;
700+ }
701+
702+ #[ test]
703+ fn test_process_x86_64_instruction_with_reloc_2 ( ) {
704+ let arch = ArchX86 { arch : Architecture :: X86_64 , endianness : object:: Endianness :: Little } ;
705+ let code = [ 0xe8 , 0x00 , 0x00 , 0x00 , 0x00 ] ;
706+ let opcode = iced_x86:: Mnemonic :: Call as u16 ;
707+ let mut parts = Vec :: new ( ) ;
708+ arch. display_instruction (
709+ ResolvedInstructionRef {
710+ ins_ref : InstructionRef { address : 0x1234 , size : 5 , opcode } ,
711+ code : & code,
712+ relocation : Some ( ResolvedRelocation {
713+ relocation : & Relocation {
714+ flags : RelocationFlags :: Coff ( pe:: IMAGE_REL_AMD64_REL32 ) ,
715+ address : 0x1234 + 1 ,
716+ target_symbol : 0 ,
717+ addend : 0 ,
718+ } ,
719+ symbol : & Default :: default ( ) ,
720+ } ) ,
721+ ..Default :: default ( )
722+ } ,
723+ & DiffObjConfig :: default ( ) ,
724+ & mut |part| {
725+ parts. push ( part. into_static ( ) ) ;
726+ Ok ( ( ) )
727+ } ,
728+ )
729+ . unwrap ( ) ;
730+ assert_eq ! ( parts, & [ InstructionPart :: opcode( "call" , opcode) , InstructionPart :: reloc( ) ] ) ;
731+ }
661732}
0 commit comments