This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: Code Composer Studio
Hi,
I'm using C6678.
I got an application with ccs project app, and App is linked with ort.lib which is built from static library project ort. I want to set the .bss and .neardata of ort.lib to L2 and the .bss and .neardata of app to DDR. So I add these lines below in my linker.cmd of project app.
SECTIONS
{
.localdata :
{
"ort.lib" (.bss)
"ort.lib" (.neardata)
} > L2
}
SECTIONS
{
.bss > DDR
.neardata > DDR
}
After I built the project app,I check the .map file and I see that the sections are mappedd into the places as cmd described. But when I try to print out the address of an initialized local static variable which defined in app's source file with printf("%x",&var); it's not an address like 0x8xxxxxxx, but an address like 0x88xxxx which is a weird. So is there something wrong with my linker.cmd?
How to place some same sections of app and ort.lib to different memory segment(some other sections keep the same in both app and lib)?
Thank you !!
ruijie yang said:But when I try to print out the address of an initialized local static variable which defined in app's source file with printf("%x",&var); it's not an address like 0x8xxxxxxx, but an address like 0x88xxxx which is a weird.
It is likely the variable is not in the .bss or .neardata sections. See the part of the C6000 compiler manual titled Sections for a description of the section names used by the compiler, and what those section names contain. Another way to see the sections used in ort.lib is with the object file display utility ofd6x. It is described in the C6000 assembly tools manual.
Another point on a different, but related, topic ... You cannot split up .bss and .neardata like that. Because those variables are all accessed at an offset from the DP (data page pointer) register, they have to be together. Please read more about this in the C6000 compiler manual section titled Data Memory Models.
Thanks and regards,
-George
Thank you George,
I've read the manual you recommanded, but can not work out my problem.
1. First I want to make sure that my goal is reachable. If I want to put the .neardata in ort.lib to L2, and .neardata in app to DDR as I described in my first post, is it possible ? Any way to do so?
2. I want to show a weird problem that occurred, I tried to define a static variable as near(static near int var), but the ccs seems not recognize the near as keyword,the "near" is not red and bold in the edit window and there's a question mark on the left edge of that line(keyword far is properly marked as a keyword). I'm using CCS 5.5. Somehow I can't show the screenshot Sorry.
3.In my first post, I use
SECTIONS
{
.localdata
{
"ort.lib"(.neardata)
} > L2
}
to put the .neardata in ort.lib to L2. Because I take a linker.cmd in ccs's omp demo "matrix" project . In this cmd file , it put the .fardata of some libraries to L2 while other objects's .fardata to MSMCRAM. Would you mind checking this linker.cmd and helping my understand it ?
4. I tried to modify my cmd file according to Example 7-9 and Example 7-25 in the manual, But it does not work in my expecting way. And when I build the app project, it has warning :
#Section ".localdata" requires a STATIC_BASE relative relocation,But is located at 0x80000000, which is probably out of range of the STATIC_BASE.STATIC_BASE is located at 0x0087d000.Might be required to correct placement of ".localdata" so it lies with 0x8000 of the STATIC_BASE.
#relocation from function "main" to symbol "var" overflowed;
var is a static int define in main().And it seems that the compiler has correct my setting in cmd by putting the .localdata to an address within 0x8000 from STATIC_BASE. Any way to stop to compiler to do so?
Thank you so much!! And hope you can help me out!
ruijie
ruijie yang said:1. First I want to make sure that my goal is reachable. If I want to put the .neardata in ort.lib to L2, and .neardata in app to DDR as I described in my first post, is it possible ? Any way to do so?
It is not possible. All the .neardata input sections from any object module, including those from libraries, must be combined together into a single output section which is (almost always) named .neardata. That is because all those variables are accessed with an offset from the DP. The size of that offset is limited to 15-bits. For more background on this topic, please see the chapter of the C6000 EABI Application Report titled Data Allocation and Addressing.
ruijie yang said:2. I want to show a weird problem that occurred, I tried to define a static variable as near(static near int var), but the ccs seems not recognize the near as keyword
This seems to be a bug in the CCS editor. For scalar global variables, near is default.
ruijie yang said:Because I take a linker.cmd in ccs's omp demo "matrix" project . In this cmd file , it put the .fardata of some libraries to L2 while other objects's .fardata to MSMCRAM. Would you mind checking this linker.cmd and helping my understand it ?
It is okay to split .fardata up into different output sections. References to variables in that section do not rely on the DP. For a general understanding of linker command files, please see the article Linker Command File Primer.
ruijie yang said:#Section ".localdata" requires a STATIC_BASE relative relocation,But is located at 0x80000000, which is probably out of range of the STATIC_BASE.STATIC_BASE is located at 0x0087d000.Might be required to correct placement of ".localdata" so it lies with 0x8000 of the STATIC_BASE.
#relocation from function "main" to symbol "var" overflowed;
This diagnostic occurs because the section .localdata has variables that are accessed with an offset from the DP, yet the .localdata section is somehow not allocated to a memory range that can be reached within that offset from the DP.
Thanks and regards,
-George