I'm trying to create a library with some code I reuse in most of my projects. I have some modules grouped in subdirectories of my working directory. In each of these modules I have one class and one global object of that class. I want to remove the unused objects and functions from the final .hex, so I'm compiling with -fdata-sections and -ffunction-sections, and linking with -Wl,--gc-sections. But looks like some dead code is still linked. The disassembly generated by the Atmel Studio Simulator show me some functions and constructors that shouldn't be there.
I found this discussion about my problem, but I didn't find a solution there: https://www.avrfreaks.net/forum/dead-code-removal-not-working
Moving my modules to an include path could help in some way? Any help?