Gcc adds path to the source code to the final compilation

Hello EveryOne!

I use PIO for compiling for STM32. Everything works well but bin (as well as elf) file contains information to a location of the source files.
How to remove this information from the compiled files?

That the ELF has meta information containing paths is OK.

If the bin has it, it has to compiled in by the code. With what framework are you working? Do you or any of the code you use, use the __FILE__ macro?

That is for bin.

I use stm32duino. No FILE macro is used in my project (but I’m not sure about the framework)

What string do you see in the .bin? To which source code file is it pointing? Yours or somewhere in the framework?

It seems that there are links to framework libs:

Makes sense, because the code calls the Error_Handler() macro in various places

Which evaluates to…

So everywhere where the Error_Handler() is called you do have the __FILE__ reference as I have foreseen.

You can modify the stm32_def.h to make ErrorHandler() an empty macro and see if the strings are gone, to confirm.

Maximilian, I changed #define Error_Handler() _Error_Handler(FILE, LINE) to #define Error_Handler() _Error_Handler(FUNCTION, LINE) and that removes the filenames in bin file. But I’ve changed stm32_def.h file that is the framework file and it will be updated with an upgrade. So this is not a nice solution but works.

The good thing to do it at program level. But as I understand there is no option to overload macros (and #define Error_Handler() looks like a macro). Are there other ways to get rid of the file names in bin? What do you think?

PS. If I do #undef Error_Handler()
#define Error_Handler() _Error_Handler(FUNCTION, LINE) in my main.h that doesn’t help