I have a large structure I wish to locate in code space. The problem appears to be the linker intreprets the accesses to this structure as a subroutine call. I get the error "Too many recursive calls to segment...". The structure works fine in XDATA. It also worked fine in code space until there were enough routines accessing the structure. Anyone have a clue?
This is one area where the compiler is not as smart as I might wish it to be. Everything in a single .c file goes into the same segment, and that segment name is the unit of granularity for tracking references. I run into the problem a lot with code that has the structure:
// Cmd.c const code Strings[]; void Cmd1 () { printf (Strings[0]); } void Cmd2 () { printf (Strings[1]); } const code CmdTbl[] = { Cmd1, Cmd2 }
Thanks for the tip(s). I really want this structure in code space. It is the heart of a complex menuing system and I don't want take any chances that it may get corrupted. Again thank you for taking the time to answer.
"I really want this structure in code space ... I don't want take any chances that it may get corrupted." So the true requirement here is to have it read-only, yes? Placing it in code space is merely a means to that end? Is your memory architecture such that you can map (some of) a ROM into XDATA space? If so, you could look at XCONST as an alternative solution to your requirement.
You are correct. Read only is the goal. Can't do any re-mapping. I am using a Cygnal 8051 type processor. The flash and RAM are internal and fixed. By the way, I have looked high and low for a way to turn off the recursion errors. I have not found it yet. Thanks again.