when i use preprocessor #if 0 ... #endif to cross out a bunch of sentences, then after building the target. I noticed the "data" memory usage increased, why? There is no error in the result.
That is, the call tree still explodes unless we manually take out unused functions. That may have been caused by the linker not being able to tell that these were unused. If, as the other reply hinted, function pointers are involved in any way, it's provably impossible to do call tree analysis in the general case, i.e. the linker has to drop the ball at some point. In an (admittedly minimalistic) example I just tried, it worked just fine: the un-called function and its data segment show up in the map file only in a new segment list titled "REMOVED SEGMENTS": they don't appear in the call tree, nor in the final program.