This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

why after deleting some functions, the IData Space overflow!

I got a demo sources from our chip vendor.
It can be compiled successfully!
However, after I comment out some functions, the compiler says that IData Space overflow. When I check the MAP file, I find that there is no ?STACK. Why?

I donot add any new file to the project, nor drop any file from the project. I only comment out several function calls in a file.

Why? Thanks a lot!

  • Overlay analysis?

    When you comment out calls to a function, those functions no longer have a place in the call tree from main(). So, they must become the root of a new call tree. This means their local variables, temporaries, etc., no longer overlay with the main call tree. Since the code remains in the program, it can increase the amount of memory needed. If the original program were close to its limits, commenting out a function can cause the program no longer to compile.

    You can fix the call tree manually with the OVERLAY directive in the linker. You also might try something like:

    if (0)
    MyFunction();

    rather than

    //MyFunction();

    to remove the call.

  • Thanks for your explaination! and I think it is quite correct! Thanks

    I try add if(0) ... but still cannot. Space overflow.

    I will try use OVERLAY directive.

  • Hi, Davis,

    I got it. After using OVERLAY, now can work. Thanks!

    However, After I really delete the function implementations and also those OVERLAY directives, I got space overflow again! Since the implementations are deleted, and the variable are no longer exist, why I get this error again?

    Thanks!

  • the only safe way to drop functions without possible overlay problems is:

    #ifdef USE_FOO
    foo();
    #endif

    and
    #ifdef USE_FOO
    foo()
    {
    ...
    }
    #endif

    Erik

  • Hi, Erik
    thanks! But can you tell me why this method can work?

    Suppose I donot define USE_FOO, then the call to function and the function implementation are not included, which is the same as that I delete the call to function and the function implementations.

  • However, After I really delete the function implementations and also those OVERLAY directives, I got space overflow again!

    Well, it has been said here before, but let me say it again, a bit louder: You absolutely have to look at the map file to solve this kind of issue. And you have to watch out for warnings about uncalled functions --- they're serious.

    In the case at hand, odds are your now deleted function called *other* functions, which are now unused, too, and should thus be removed or commented out.

  • thanks! But can you tell me why this method can work?

    Suppose I donot define USE_FOO, then the call to function and the function implementation are not included, which is the same as that I delete the call to function and the function implementations.


    Because the linker assign space outside the call stack to functions that are not called. Thus a function called from main() only will typically not use any space for its variables (other functions have reserved the space) whareas, if it is not called the space for the variables will be added at the end of the call stack.

    Erik

  • "I try add if(0) ... but still cannot. Space overflow."

    I think the optimiser is too clever to be fooled by this. Try:

    if(!SP)
    {
    FnCall();
    }

    instead.