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.

Defining Output Sections with Absolute Start Address and length in Linker Command File

Hi,

Some of my output sections in the linker file need fixed start address in its memory region and a fixed length too. These addresses are to be used directly in my source code to transfer data. How do i set absolute start address and length for an output section in a linker command file? I know this can be done for a particular MEMORY REGION. But i have checked in several example linker files on how to do this for a particular output section. But couldnt find it.

 My memory regions are organized as below:
MEMORY {
   ISRAM       : origin = 0x0,         len = 0xe0000
   CACHE_L2    : origin = 0xe0000,     len = 0x20000
   SDRAM       : origin = 0x81d00000,  len = 0x300000
   SDRAM_data  : origin = 0x80000000,  len = 0x1d00000
}
 
I have to create ouput sections X and Y in the memory region SDRAM_data. Subsections XX and YY have to be created inside the X and Y respectively. The following should be the memory start addresses and length for these sections and subsections.
 
Sections/Subsections        Start Address               Length
---------------------------------       --------------------            --------------
X                                      0x80000000               0x100000                             
    XX                                0x80080000               0x080000
Y                                     0x80110000               0x0F0000  
    YY                               0x80110000               0x010000
 
Under the SECTIONS in my linker command file. I have written as below:
 
SECTIONS {
X:  {} > SDRAM_data
Y:  {} > SDRAM_data
}
 
How do i include Start Address and Length info for X and Y as well as XX and YY under the SECTIONS content in the linker command file?
  • Hi Shiras,

    If making the above changes in the linker command file is not obligatory, then using #pragma directive can be an option. You can define small sections of SDRAM memory in your linker file and use #pragma directive to define certain memory chunks internal to these sections.

    Hope this helps.

    Regards,

    Sid

  • Hi Sid,

    Thanks for your reply.

    I am trying to link a project using text linker. The same project was linked using a visual linker previously. For some reasons, i have to use text linker now for the project. Since i have some custom output sections, i have to write a linker file of my own which will include the bios-configuration tool generated linker file. It would be very helpful if i can get the way of specifying the start address and length of an output section in the linker file itself, without using #pragma. I am not declaring any variables in these output sections in my code. Instead , i am accessing memory locations in this space using the hardcoded start addresses of the output section.

    Regards

    Shiras

     

  • Sections can also be allocated to a specific address by specifying the actual address in the SECTIONS directive rather than specifying a memory region, for eg,

    SECTIONS {
    X:  {} > 0x80000000
    Y:  {} > 0x80110000
    }

    The current versions of code generation tools also support START(), SIZE() and END() operators which can be used in linker command files to define symbols for load-time start address, size, and load-time end address of related allocation unit. These can then be referenced from within the C source code, which could be handy here.

    Please refer to the Assembly Language Tools Users Guide for the processor family you are using. There is a lot of good information on the Linker command file specifications. Also you'd have to check the version of codegen tools you are using, if it is a very old version, the START(), END(), SIZE() operators may not be supported.

  • The X and Y sections are in my SDRAM_data memory region and a heap of size 00200000 has to be defined in it. In the configuration tool, it allows to set the heap size of SDRAM_data memory region.

     If I write as below (as you have mentioned in your previous mail) in the linker file under SECTIONS,

     SECTIONS {
    X:  {} > 0x80000000
    Y:  {} > 0x80110000

    I would get a map file with the following contents

     SECTION ALLOCATION MAP

    output                                                                                         attributes/

    section            page             origin                length               input sections

    --------                ----                ----------             ----------             ----------------

    X

    *                          0             80000000             00000000             UNINITIALIZED

     Y

    *                          0             80110000             00000000             UNINITIALIZED

     .SDRAM_data$heap

    *                          0                80000000          00200000                 UNINITIALIZED

     Here the problem, as you can see, is that the output section X and .SDRAM_data$heap would have the same origin. Also the lengths of X and Y is 0.

     But the map file generated by linking the project with its actual Visual Linker recipe has the following contents. All the sections start at different address locations and have their own lengths.

     SECTION ALLOCATION MAP

    output                                                                                       attributes/

    section           page             origin                length               input sections

    --------              ----                 ----------             ----------            ----------------

    X

    *                      0             80000000             00100000             UNINITIALIZED

     Y

    *                      0             80110000             000F0000            UNINITIALIZED

     .SDRAM_data$heap

    *                      0             80800000            00200000                 UNINITIALIZED

     How do I make changes to my linker file SECTION directive so that both the above map files would be alike?

    I have referred SPRU186K  (TMS320C6000 Assembly Language Tools User's Guide). I don't have any Symbol to be defined in these output sections. I just wanted to link some fixed range of memory sections to some output sections. So I think START(), END() and SIZE() operators will not be of use to me as they operate on symbols and not on sections directly.

  • Hi Shiras,

    Maybe if you directly define the SDRAM heap, X and Y with their corresponding origins and lengths and ensure that in your program the data transferred to these memory sections dont overlap, I think it may get initialized correctly.

    Does a definition like this -

    MEMORY
     {
       SDRAM$heap     : origin = 0x80800000,  len = 0x00200000
       X                            : origin = 0x80000000,  len = 0x00100000
       Y                            : origin = 0x80110000,  len = 0x000F0000
    }

    SECTIONS
    {
    }

    give an error? Ideally it should just be giving a warning ,if at all, indicating overlapping memories. And maybe you can ensure that your data memory doesnt overflow the bounds set by the linker cmd file

    Regards,

    Sid

  • You cant redefine SDRAM$heap in your custom linker file as its already defined in the generated linker file. Instead you can modify it using the BIOS Config tool.

    I defined X and Y as Memory regions by inserting MEM region through DSP/BIOS COnfig tool. and by this i could get my things working...

    Thanks Sid for your reply...