You may specify for "Debug" and for "Release" version of your project different settings for compiler-options, linker, optimizer etc which WILL result in different hex-files.
Any Major difference between the two....and also If I am to program my device for the last time is it the release version which has to be programmed??? What if there comes a problem later and need to debug my device then does my relese code support debugging??
The relese built is usually programmed into devices that are shipped to production -> customer. Any reverse engeneering as reading the code, debugging and other things are unwanted to protect your design from beeing copied etc.
So there are some features for us designers built into the PSoCs to help us. If you do not need protections like that, do not use them.
Compiler's optimizing of code may disturb debugging. While the value of a variable is hold within a register to save code space and MIPs, any changes to its value will not be displayed during debugging until the register is written back to memory.
Complete lines of code may be taken out of a loop when the optimizer decides to do so (we can trust to the rightfulness of such deep intrusion, it will work correctly) but the debugging will look awfull and when not prepared for it may look like an error in code but it isn't.
So usually the debug settings allow just for a minimal optimization, while the release settings are much stronger and even may prevent any debugging at all.
Usually I do not guess, but Hex files have specific formats, and device programmers in
turn have their "layout" when perfroming chip programming. Like the Motorola S record
hex file option in so many tools.
I suspect (guess) GNU has a doc that calls out their specifics in the release vs debug
file generation that you can consult.