NationalSecurityAgency / ghidra

Ghidra is a software reverse engineering (SRE) framework
https://www.nsa.gov/ghidra
Apache License 2.0
51.84k stars 5.89k forks source link

Bug while disasm PIC16 iHex file #1555

Open MalumK opened 4 years ago

MalumK commented 4 years ago

Hello, I loaded my PIC16F program to Ghidra and saw, function addresses doesn't match with addresses in iHex file. There is address fields in iHex records but ghidra ignores them and puts addresses one by one in disassembler listing.

P.S. line 7 in file Address: 0x4C in disasm: 0x26 BinProto.hex.txt

GhidorahRex commented 4 years ago

Intel Hex files don't use addresses. Instead, they use byte offsets, which Ghidra does respect (see lines 1 and 2 after importing the file). In the PIC16 case, since the wordsize=2, each address is two bytes. 0x4c = 2 * 0x26.

As a double-check, the first instruction in the code is 0x28b1, which results in a GOTO 0xb1. In the hex file this is located on line 27, at byte offset 0x162, which is 2 * 0xb1.