I know how to specify the code segment in a source code. But if I am calling a function using a library, how do I specify the location for this function? For example:
...
#pragma CODE_SEG myCodeSeg
...
libfunc1(); //libfunc1() is a function in the library myProj.lib which was included in the project
...
I found that libfunc1() is not located in myCodeSeg. How to force libfunc1() into a code segment I want?
Solved! Go to Solution.
First I must declare one thing: all the source codes and functions are automatically added to segment DEAFULT_ROM unless we use “#pragma CODE_SEG MY_SECTION” to change it.
There is no doubt that your lib function has already integrated with your other source code, but all lib functions is still in the DEAFULT_ROM because you never put “#pragma CODE_SEG MY_SECTION ” on it.
To change the section of the lib function, i usually follow the steps as below:
I have tried to set up an example of this that I am sending as an attachment.
Hi.
The lib which i want to include is ansiis.lib which comes with Codewarrior.
So that means i have to open up the source codes, add the #pragma, and recompile? What happens if the source codes also call some library?
Is there any other ways? Will #pragma REALLOC_OBJ work?
we don't encourage user modify ansi lib file.
ansi lib by default is in NON BANKED memory. why do you want to change it?
Long story.
I have a huge project (Project A) which has lots of source codes. #pragma CODE_SEG was not used in this project Therefore the linker allocates all the program binaries in DEFAULT_ROM
I want to incorporate the source code of another project (Project B) into Project A. The requirement is that all the program binaries of Project B should be allocated in an exclusive protected memory area, separated from DEFAULT_ROM. Therefore in Project B source code, I used #pragma CODE_SEG MyProtectSeg so as to put Project B program in MyProtectSeg, away from
DEFAULT_ROM. Also, some of the source codes in Project B use functions in ansiis.lib. So:
//ProjectB_source1.c ... #pragma CODE_SEG MyProtectSeg ...//code abc();//abc() uses functions in ansiis.lib ...
Now the problem comes. Functions in ansiis.lib are not affected by the #pragma (at least I don't know how to control the
allocation), and therefore these binaries are allocated in DEFAULT_ROM, which violates the requirement
How to solve this?
First I must declare one thing: all the source codes and functions are automatically added to segment DEAFULT_ROM unless we use “#pragma CODE_SEG MY_SECTION” to change it.
There is no doubt that your lib function has already integrated with your other source code, but all lib functions is still in the DEAFULT_ROM because you never put “#pragma CODE_SEG MY_SECTION ” on it.
To change the section of the lib function, i usually follow the steps as below:
I have tried to set up an example of this that I am sending as an attachment.