target/image: fix undefined behaviour when loading with GDB