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

Overlay/function pointers

Hi,
In our project we are using function pointers. After compiling the project, we got "RECURSIVE CALL TO SEGMENT" warning. By selecting OVERLAY (sfname ! *)in BL51, that warnings was removed.
If we add function name in OVERLAY, will it allocate diffrent memory for local variables and function argumants?.
How it is diffrent from by difining same function as rentrant function ?.

Thanks in advance..

Parents
  • Rajesh,

    I'm really no expert on the topic, but I'll give it a crack. When you specify a function as "reentrant," you're telling the compiler NOT to pass function arguments in registers. This means that the compiler will generate code to behave more like a PC in that it will push arguments onto the stack and the function will pop them off. This is MUCH slower and more resource intensive than the standard methodology used by C51.

    Manually modifying the OVERLAY entries to fix problems caused by, say, function pointers has to do (as you rightly guessed) with how the compiler handles local variables. Normally, local variables for functions would be overlayed in all cases where on function doesn't call another, etc. to conserve memory space. When you use pointers, the compiler cannot figure out if/when you have called that function. This directive tells it just to be safe and not overlay the local automatic variables for that function with ANYTHING at all.

Reply
  • Rajesh,

    I'm really no expert on the topic, but I'll give it a crack. When you specify a function as "reentrant," you're telling the compiler NOT to pass function arguments in registers. This means that the compiler will generate code to behave more like a PC in that it will push arguments onto the stack and the function will pop them off. This is MUCH slower and more resource intensive than the standard methodology used by C51.

    Manually modifying the OVERLAY entries to fix problems caused by, say, function pointers has to do (as you rightly guessed) with how the compiler handles local variables. Normally, local variables for functions would be overlayed in all cases where on function doesn't call another, etc. to conserve memory space. When you use pointers, the compiler cannot figure out if/when you have called that function. This directive tells it just to be safe and not overlay the local automatic variables for that function with ANYTHING at all.

Children