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

Recursive code reference error

Hello ALL!

I would ask the next question...

according http://www.keil.com/support/docs/2379.htm

one must manually remove the reference between func2 and the ?CO?EXAMPLE1 segment and add MAIN ! FUNC2 reference between MAIN and FUNC2.
But from App129 if I define
code void (*func_array[])() = { func2 };
with the storing table in code space, I will get the correct call tree.

Now is a question: if I would not make this overlay command like sad in the
http://www.keil.com/support/docs/2379.htm
bl51 EXAMPLE1.OBJ IX OVERLAY & (?CO?EXAMPLE1 ~ FUNC2, MAIN ! FUNC2)

would I have any problem?

How I understood it's harmless because there are no actual recursive calls in the code, just a reference from one item in the constant segment to another.

Could somebody please make it a little bit more clear for me?

Thank you very much,
A.

Parents
  • according http://www.keil.com/support/docs/2379.htm

    one must manually remove the reference between func2 and the ?CO?EXAMPLE1 segment and add MAIN ! FUNC2 reference between MAIN and FUNC2.
    But from App129 if I define
    code void (*func_array[])() = { func2 };
    with the storing table in code space, I will get the correct call tree.


    The problem here is that there are 2 different data objects but only 1 data segment in code space. And, since one of them is referenced as a function pointer (or a table of function pointers), the linker must make the assumption that all of these are function pointers.

    There is a key phrase in the Application Note that you are ignoring:

    "As long as the function pointer table is located in a separate source file, C51 and BL51 make all the correct links in the call tree for you."

    The reason for this is that all CODE globals in a source file are lumped into a single segment. So, if you have function pointers and constant string data, you'll get the problem you describe.

    Yes. You should use OVERLAY to solve this problem. Or, as the application note suggests, put the function pointer table in a separate source file.

    Jon

Reply
  • according http://www.keil.com/support/docs/2379.htm

    one must manually remove the reference between func2 and the ?CO?EXAMPLE1 segment and add MAIN ! FUNC2 reference between MAIN and FUNC2.
    But from App129 if I define
    code void (*func_array[])() = { func2 };
    with the storing table in code space, I will get the correct call tree.


    The problem here is that there are 2 different data objects but only 1 data segment in code space. And, since one of them is referenced as a function pointer (or a table of function pointers), the linker must make the assumption that all of these are function pointers.

    There is a key phrase in the Application Note that you are ignoring:

    "As long as the function pointer table is located in a separate source file, C51 and BL51 make all the correct links in the call tree for you."

    The reason for this is that all CODE globals in a source file are lumped into a single segment. So, if you have function pointers and constant string data, you'll get the problem you describe.

    Yes. You should use OVERLAY to solve this problem. Or, as the application note suggests, put the function pointer table in a separate source file.

    Jon

Children