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.
Hello Support,
For CONST data item I see that the compiler generates .const section.
But when the CONST data item is a MATRIX, then I see that the section name is changed to something like .const:XXXXXX.
Any clue aboutthe rule for section name creation by the compiler when the user doesn't use any PRAGMA.
Also, how does the linker allocate those .const:XXXX section names within the .const section, even though the exact section name is missing in the Linker Command File?
I am using TMS470 4.6.4 compiler.
It is a C code which I am compiling.
Some snippet from MAP file will indicate the question I am asking:
.Layer2_Const
* 0 00008050 00000978
00008050 000002f8 hzspicnf.obj (.const:SPI_Messages_Database) --- Why the section name is not .const
00008348 00000008 hzspicnf.obj (.const)
00008350 00000058 hcnvm.obj (.const:nvm_stage_process)
000083a8 00000010 hcnvm.obj (.const)
000083b8 00000020 hi
Thank you.
Regards
Pashan
This wiki article talks about something similar. I don't recommend you adopt the techniques contained in that article. But the method it uses to remove unused variables is the same as the one the compiler employs to remove C const variables that end up not getting used. Pay particular attention to this piece of the article.
Thanks and regards,
-George
Hello George,
Thank you for the pointer.
But this didn't answer my exact question.
The article tells me how to create SECTION Names so that the linker removes it.
I am asking different.
I am writing a C program in the usual way and not creating any new section names as mentioned in the WIKI.
Hence, when I open the LISTING File, I should see all my CONST variables under .const section.
But for some multi-dimensional arrays, I see then under section name .const:XXXXX.
Question is why not those multi-dimensional arrays are within .const section and instead under .const:XXXXX section?
Please help me to understand the algorithm followed by the C Compiler to generate those enhanced .const:XXXXX section names only for certain symbols.
Thank you.
Regards
Pashan
Well, let's define some terms first. An input section is a section created by the compiler (assembler, really), and comes from a single source file. The linker creates an output section by combining together one or more input sections. The confusing part is that an input section often has the same name as the output section which contains it. Even so, it is best to view them as different sections. A scalar is a simple variable such as "int i;", while an aggregate is an array, struct, or union.
With that terminology in mind, your question is: When does the compiler place a variable in an input section merely named .const, and when does it place it in an input section with a name of the form .const:name_of_variable? Scalars and very small aggregates are placed in an input section named .const. Aggregates larger than some small size are placed in input sections named .const:name_of_variable.
Thanks and regards,
-George
George,
Thank you for the exact response I was looking for.
Now, the next question is what is the THRESHOLD of the size of data item beyond which triggers the renaming from default .const to .const:variable_name section by the compiler?
This will help me a lot.
Thank you.
Regards
Pashan
Any data object larger than 32 bytes is placed in a sub-section of the form .const:name_of_variable.
Thanks and regards,
-George