@@ -15,6 +15,10 @@ use crate::{
1515 } ,
1616} ;
1717
18+ // ARM relocation types not defined in the `object` crate
19+ const R_ARM_THM_JUMP11 : u32 = 102 ;
20+ const R_ARM_THM_JUMP8 : u32 = 103 ;
21+
1822#[ derive( Debug ) ]
1923pub struct ArchArm {
2024 /// Maps section index, to list of disasm modes (arm, thumb or data) sorted by address
@@ -366,6 +370,22 @@ impl Arch for ArchArm {
366370 ( imm22 << 1 ) << 9 >> 9
367371 }
368372
373+ // Thumb unconditional branch (B, 11-bit offset)
374+ R_ARM_THM_JUMP11 => {
375+ let data = section_data[ address..address + 2 ] . try_into ( ) ?;
376+ let insn = self . endianness . read_u16_bytes ( data) as i32 ;
377+ let imm11 = insn & 0x7ff ;
378+ ( imm11 << 1 ) << 20 >> 20
379+ }
380+
381+ // Thumb conditional branch (B<cond>, 8-bit offset)
382+ R_ARM_THM_JUMP8 => {
383+ let data = section_data[ address..address + 2 ] . try_into ( ) ?;
384+ let insn = self . endianness . read_u16_bytes ( data) as i32 ;
385+ let imm8 = insn & 0xff ;
386+ ( imm8 << 1 ) << 23 >> 23
387+ }
388+
369389 // Data
370390 elf:: R_ARM_ABS32 => {
371391 let data = section_data[ address..address + 4 ] . try_into ( ) ?;
@@ -399,6 +419,8 @@ impl Arch for ArchArm {
399419 elf:: R_ARM_PC24 => Some ( "R_ARM_PC24" ) ,
400420 elf:: R_ARM_XPC25 => Some ( "R_ARM_XPC25" ) ,
401421 elf:: R_ARM_CALL => Some ( "R_ARM_CALL" ) ,
422+ R_ARM_THM_JUMP11 => Some ( "R_ARM_THM_JUMP11" ) ,
423+ R_ARM_THM_JUMP8 => Some ( "R_ARM_THM_JUMP8" ) ,
402424 _ => None ,
403425 } ,
404426 _ => None ,
@@ -418,6 +440,8 @@ impl Arch for ArchArm {
418440 elf:: R_ARM_PC24 => 4 ,
419441 elf:: R_ARM_XPC25 => 4 ,
420442 elf:: R_ARM_CALL => 4 ,
443+ R_ARM_THM_JUMP11 => 2 ,
444+ R_ARM_THM_JUMP8 => 2 ,
421445 _ => 1 ,
422446 } ,
423447 _ => 1 ,
@@ -544,7 +568,9 @@ impl unarm::FormatIns for ArgsFormatter<'_> {
544568 | RelocationFlags :: Elf ( elf:: R_ARM_THM_PC22 )
545569 | RelocationFlags :: Elf ( elf:: R_ARM_PC24 )
546570 | RelocationFlags :: Elf ( elf:: R_ARM_XPC25 )
547- | RelocationFlags :: Elf ( elf:: R_ARM_CALL ) => {
571+ | RelocationFlags :: Elf ( elf:: R_ARM_CALL )
572+ | RelocationFlags :: Elf ( R_ARM_THM_JUMP11 )
573+ | RelocationFlags :: Elf ( R_ARM_THM_JUMP8 ) => {
548574 return self . write ( InstructionPart :: reloc ( ) ) ;
549575 }
550576 _ => { }
0 commit comments