Elf file location

where can I find elf file which is generated before program upload ? On Linux

Ok I think I have found it. Its under project folder
.pioenvs/megaatmega2560/firmware.elf

Yes, it will be under:

.pioenvs/ environment name /firmware.elf

(no spaces)

Environment name of course being whatever you have specified. In your case:

[env:megaatmega2560]

in your platformio.ini file