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

Calltree problem

There is a strange behaviour of the linker concerning the calltree!

Look at this simple code:

void Function1()
{
	int a;
}

void Function2(void (code *fptr)(void))
{
	int b;
	fptr();
}

main()
{
	Function2(Function1);
}
Function1 gets called from Function2 via pointer. Both functions declare a local variable (a and b).

The linker LX51 produces this calltree:
FUNCTION/MODULE              BIT_GROUP   DATA_GROUP
--> CALLED FUNCTION/MODULE  START  STOP  START  STOP
====================================================
?C_C51STARTUP               ----- -----  ----- -----
  +--> ?PR?MAIN?MAIN

MAIN/MAIN                   ----- -----  ----- -----
  +--> ?PR?FUNCTION1?MAIN
  +--> ?PR?_FUNCTION2?MAIN

FUNCTION1/MAIN              ----- -----  0008H 0009H

_FUNCTION2/MAIN             ----- -----  0008H 0009H
I think that's not correct, because Function1 is not called by main() !

As a result of this calltree the linker locates the variables a and b to the same address!

      00000008H   SYMBOL    DATA     INT       a
      00000008H   SYMBOL    DATA     INT       b

As workaround I manipulated the calltree via linker options. Any other ideas ??

Bernhard

Parents
  • Look at this simple code:

    That code uses function pointers. On an 8051, that makes it decidedly unsimple.

    Please see the app notes and the Manual about how to tell the calltree analyser in the linker about your usage of function pointers. In particular, you'll have to add OVERLAY directives to your linker command line.

Reply
  • Look at this simple code:

    That code uses function pointers. On an 8051, that makes it decidedly unsimple.

    Please see the app notes and the Manual about how to tell the calltree analyser in the linker about your usage of function pointers. In particular, you'll have to add OVERLAY directives to your linker command line.

Children