Hi,
Both hex and bin files are generated from the ELF file using the arm-none-objcopy.exe tool. The .bin file will fill the empty areas with 00’s, while the hex file will actually skip them (that translates of 0xFFs when erasing and programming FLASH). If you are using MSBuild, you can configure VisualGDB to fill the .bin files with 0xFF’s via MSBuild Project Properties -> Embedded Project -> Fill gaps in .bin file with.
For other project types (e.g. CMake) there is no easy setting to do that, but you can still run arm-none-objcopy.exe manually as a post-build step, passing it the –gap-fill argument with the desired value. You can find more information in the documentation for the objcopy tool.