This is a helpful document, thanks. It speaks to the same problem as my previous post to this list regarding rom->ram relocation. It recommends two things for running from flash:
1. use #pragma switch_tables off
As described, the default compiler/linker behavior is to locate the jump table in ram requiring a rom->ram relocation. This pragma works because it causes the compiler to implement the switch statement as a series of if/elses with all code in rom. However, this represents a performance hit and sidesteps the issue so is not ideal IMO. From reviewing my own application, it appears that the reason the default switch tables do not work is that the rom->ram relocation misplaces the jump table addresses. To be precise, the rom image of the .data section where they are placed is mislocated and the ensuing rom->ram relocation merely duplicates the problem in ram.
2. make sure all constants are located in rom
Yes, this works, but again sidesteps the issue IMO. In the case of an initialized string like this:
printf("Hello World\n");
the default location of the string "Hello World" is in the data section unless the 'make strings readonly' box is checked in the project settings dialog. When unchecked and running from rom, the string is relocated to ram by the __init_data function. In my test case, the string also falls victim to the rom->ram relocation issue and what comes out of the printf is "o World". The basic problem is that the starting address for the rom copy of the .data section is off by 4 bytes so it "misses" the "Hell" part of the string. Its the same problem that prevents the normal switch statement code to fail. Why doesn't this work properly?
If I prepare a modified version of the copy_rom function I can relocate the .data function elements to ram properly so that both the normal switch statement code and the initialized strings are copied properly. It seems to work on simple applications but I can't be certain that the relocation issue is completely repeatable.
FWIW, there is a support request in the system on this issue.