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

Declaring local variable causes L15 warnings, but only on optimization level 9

For reference, please take a look at this older question of mine:
https://community.arm.com/developer/tools-software/tools/f/keil-forum/41992/spurious-link-from-isr-to-pr-main
Previously, function pointers that were placed in a global table made the linker think ?CO?MAIN is calling all of those referenced functions. Telling the linker to OVERLAY(?CO?MAIN ~ ThoseReferencedFunctions) (and adding OVERLAY(TheFunctionUsingThatTable ! ThoseReferencedFunctions), of course) fixed the problem.

The linker warnings back then looked very similar to the ones I am getting now:

*** WARNING L15: MULTIPLE CALL TO FUNCTION
    NAME:    FOO/MAIN
    CALLER1: INTERRUPTVECTORS_INT0/MAIN
    CALLER2: INTERRUPTVECTORS_UART/MAIN
*** WARNING L15: MULTIPLE CALL TO FUNCTION
    NAME:    FOO/MAIN
    CALLER1: INTERRUPTVECTORS_UART/MAIN
    CALLER2: ?C_C51STARTUP

These warnigs show up when, in `void Foo()`, i simply only declare a local variable. Like unsigned char i; or bit b;. (That is, the function is empty except for the declaration.) If I add some more code that accesses a few global variables (but does not call any other functions), an L13 appears too:

*** WARNING L13: RECURSIVE CALL TO FUNCTION
    CALLED:  MAIN
    CALLER:  HARDWARETEST_GP_TESTRS485_QUEUEFIRSTIDLETEST/MAIN

But all of these warnings only show up when the code optimization level is set to 9: Common Block Subroutines. On the lower levels, the warnings don't show up. Now... the errors last time were also insane, so nothing can shock me anymore, but goodamnit the error messages are just so useless for finding the actual cause.

Curiously, the MAP file says

MAIN                                          ----- -----  ----- -----
  +--> ?CO?MAIN
  +--> ?PR?FOO...
  +--> ?PR?_BAR?MAIN

(Please note that Foo and Bar are short placeholders. The real function names are longer, which is why "FOO..." has an ellipsis at the end.)
I don't know why BAR has an underscore and FOO doesn't. I also don't know why these show up here in the first place. I never take function pointers to either. They are also not called directly from void main().

Any suggestions on what is going on and how to fix it are welcome!

Parents Reply Children