Can --gc-sections remove all the function not used?
This is my file, named xxx.c. And there are two functions in it.
static void bxx() //It's called by axx only , in this file.
When I try to compile the whole project, I used -ffunction-sections,-fdata-sections to generate the .o files, use Wl,--gc-sections -Wl,--print-gc-sections
to link to the exacutable file.
After the first time I compiled it, I got a list of Removed functions. Iwas so happy.
But one second later, I rememberd that I forget to close the Compile Switch:
Debug. Then I had to recompile it and got another list.
Compare these two lists, I found that , bxx isn't on the second list.
First I guess that bxx is a debug function but never used in debug mode, and it won't be compiled in release mode .
I check the source and find that there was no compile switch for bxx........
But it's caller function axx, is removed, both the debug switch is on and off.
I try to compiled the project for several times , but the result is the same.
I can't realized it , why?
Is that the --gc-sections won't remove all the functions not used?
God, you're right, but WHY~~~~~~~~~
When I make the function not static, it was removed correctly by linker.
Originally Posted by Kloschüssel
God, you're right, but WHY~~~~~~~~~???????
Obviously, it's a bug ~!!!!! Because not all the situation it won't be removed.
Please, my lord, tell me WHY?
Could this problem be fixed by any methods?