@@ -15,6 +15,7 @@ use crate::{
1515 } ,
1616} ;
1717
18+
1819#[ derive( Debug ) ]
1920pub struct ArchArm {
2021 /// Maps section index, to list of disasm modes (arm, thumb or data) sorted by address
@@ -366,6 +367,22 @@ impl Arch for ArchArm {
366367 ( imm22 << 1 ) << 9 >> 9
367368 }
368369
370+ // Thumb unconditional branch (B, 11-bit offset)
371+ elf:: R_ARM_THM_PC11 => {
372+ let data = section_data[ address..address + 2 ] . try_into ( ) ?;
373+ let insn = self . endianness . read_u16_bytes ( data) as i32 ;
374+ let imm11 = insn & 0x7ff ;
375+ ( imm11 << 1 ) << 20 >> 20
376+ }
377+
378+ // Thumb conditional branch (B<cond>, 8-bit offset)
379+ elf:: R_ARM_THM_PC9 => {
380+ let data = section_data[ address..address + 2 ] . try_into ( ) ?;
381+ let insn = self . endianness . read_u16_bytes ( data) as i32 ;
382+ let imm8 = insn & 0xff ;
383+ ( imm8 << 1 ) << 23 >> 23
384+ }
385+
369386 // Data
370387 elf:: R_ARM_ABS32 => {
371388 let data = section_data[ address..address + 4 ] . try_into ( ) ?;
@@ -399,6 +416,8 @@ impl Arch for ArchArm {
399416 elf:: R_ARM_PC24 => Some ( "R_ARM_PC24" ) ,
400417 elf:: R_ARM_XPC25 => Some ( "R_ARM_XPC25" ) ,
401418 elf:: R_ARM_CALL => Some ( "R_ARM_CALL" ) ,
419+ elf:: R_ARM_THM_PC11 => Some ( "R_ARM_THM_PC11" ) ,
420+ elf:: R_ARM_THM_PC9 => Some ( "R_ARM_THM_PC9" ) ,
402421 _ => None ,
403422 } ,
404423 _ => None ,
@@ -418,6 +437,8 @@ impl Arch for ArchArm {
418437 elf:: R_ARM_PC24 => 4 ,
419438 elf:: R_ARM_XPC25 => 4 ,
420439 elf:: R_ARM_CALL => 4 ,
440+ elf:: R_ARM_THM_PC11 => 2 ,
441+ elf:: R_ARM_THM_PC9 => 2 ,
421442 _ => 1 ,
422443 } ,
423444 _ => 1 ,
@@ -544,7 +565,9 @@ impl unarm::FormatIns for ArgsFormatter<'_> {
544565 | RelocationFlags :: Elf ( elf:: R_ARM_THM_PC22 )
545566 | RelocationFlags :: Elf ( elf:: R_ARM_PC24 )
546567 | RelocationFlags :: Elf ( elf:: R_ARM_XPC25 )
547- | RelocationFlags :: Elf ( elf:: R_ARM_CALL ) => {
568+ | RelocationFlags :: Elf ( elf:: R_ARM_CALL )
569+ | RelocationFlags :: Elf ( elf:: R_ARM_THM_PC11 )
570+ | RelocationFlags :: Elf ( elf:: R_ARM_THM_PC9 ) => {
548571 return self . write ( InstructionPart :: reloc ( ) ) ;
549572 }
550573 _ => { }
0 commit comments