What are the stack and heap set in the GCC linker script used for?

If you are sure that you application does not use malloc (directly or indirectly), then yes, you can set it to 0.