Research Article

Determining the Image Base of ARM Firmware by Matching Function Addresses

Algorithm 2

FIND-Thumb-LDR algorithm.
Input: binaryFile
Output: The addressees loaded by LDR instruction in Thumb state.
function Find_Thumb_LDR(binaryFile)
  bin[fileSize] ⟵ binaryFile
  offset ⟵0
   while(0 ≤ offset < fileSize) do
     opcode ⟵ bin[offset+1]
     opcodeopcode & (11111000)2
     if( opcode == (01001000)2)
      PCoffset +4
      immed_8 ⟵ bit[7,…,0]
      address ⟵ (PC & 0xFFFFFFFC) + (immed_84)
      Rd ⟵ Memory[address, 4]
      Output: Rd
     end if
     offsetoffset +2
   end while
end function