Keil Logo

Recursive Code References

The following program example:

#pragma code symbols debug oe

void func1(unsigned char *msg ) { ; }

void func2( void ) {
  unsigned char uc;
  func1("xxxxxxxxxxxxxxx");
}

code void (*func_array[])() = { func2 };

void main( void ) {
  (*func_array[0])();
}

when compiled and linked using the following command lines:

C51 EXAMPLE1.C

BL51 EXAMPLE1.OBJ IX

fails and displays the following error message.

*** WARNING 13:  RECURSIVE CALL TO SEGMENT
    SEGMENT:  ?CO?EXAMPLE1
    CALLER:   ?PR?FUNC2?EXAMPLE1

In this program example, func2 defines a constant string ("xxx...xxx") which is directed into the constant code segment ?CO?EXAMPLE1. The definition code void (*func_array[])() = { func2 }; yields a reference between segment ?CO?EXAMPLE1 (where the code table is located) and the executable code segment ?PR?FUNC2?EXAMPLE1. Because func2 also refers to segment ?CO?EXAMPLE1, BL51 assumes that there is a recursive call.

To avoid this problem, link using the following command line:

Lx51 EXAMPLE1.OBJ IX OVERLAY &
(?CO?EXAMPLE1 ~ FUNC2, MAIN ! FUNC2)

?CO?EXAMPLE1 ~ FUNC2 deletes the implied call reference between func2 and the code constant segment in the example. Then, MAIN ! FUNC2 adds an additional call to the reference listing between MAIN and FUNC2 instead. Refer to the Ax51 Macro Assembler User's Guide for more information.

In summary, automatic overlay analysis cannot be successfully accomplished when references are made via pointers to functions. References of this type must be manually implemented, as in the example above.

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.