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.

sysbios linker .cmd

Other Parts Discussed in Thread: SYSBIOS

Hi all,

I use default linker files, so .bss is between .text.1 and initialized section(.text .data). So the bin size is too big(usb buffer 2M). 

My questions:

How to write cmd to reallocate section?

How is .bss(initialized) cleared when booting?

run origin load origin length init length attrs members
---------- ----------- ---------- ----------- ----- -------
40400000 40400000 00010000 00000000 rw-
40400000 40400000 00010000 00000000 rw- .stack
80000000 80000000 000000c0 000000c0 r-x
80000000 80000000 00000090 00000090 r-x _c_int00
80000090 80000090 00000030 00000030 r-x .text.1
800000c0 800000c0 00251270 00000000 rw-
800000c0 800000c0 00251270 00000000 rw- .bss
80251330 80251330 00022cd0 00022cd0 r-x
80251330 80251330 0002109c 0002109c r-x .text.2
802723cc 802723cc 00001c34 00001c34 r-- .const.1
80274000 80274000 00004000 00000000 rw-
80274000 80274000 00004000 00000000 rw- ti.sysbios.family.arm.a8.mmuTableSection
80278000 80278000 00000781 00000781 r--
80278000 80278000 00000781 00000781 r-- .const.2
80278788 80278788 000020e0 000020e0 rw-
80278788 80278788 000020e0 000020e0 rw- .data
8027ac00 8027ac00 00000950 00000950 r--
8027ac00 8027ac00 00000040 00000040 r-- .vecs
8027ac40 8027ac40 00000910 00000910 r-- .cinit

Regards,

Lusheng

  • Are you using TI or GCC tools?

    Which target, platform, and device are you building for?

    Which version of SYS/BIOS and XDCTOOLS are you using?

    Alan

  • TI CCS

    Code Composer Studio Version: 5.2.1.00018

     SYS/BIOS:  6.33.04.46

    xdc tool: 3.23.03.53


    Regards,

    Lusheng

  • Hi Lusheng,

    The following link would help you to understand the basics of memory management and section arrangement.

    http://rtsc.eclipse.org/docs-tip/Memory_Management

    Regards,
    Kawada 

  • Hi Quote,

    I also want to add one linker cmd such as am335x.cmd.

    Can you give me one guide to write linker cmd? 

    Regards,

    Lusheng

  • Hi Lusheng,

    Xdc will automatically create .cmd file by referring the "platform" you are selecting in RTSC configuration.
    So, the basic memory definitions and section arrangements have been done automatically.
    If you want to modify the section arrangement, you can override that by modifying your .cfg file as I informed you before. 

    Now, if you want to add/modify the linker settings by .cmd file, you can still do that by adding your own .cmd file to your project such as am335x.cmd.
    Please note the memories defined in MEMORY directive in your .cmd file may be already defined in the "platform". In this case, the errors will be raised during linking time.
    If you want to change the definitions of memories, you can create your own platform :

    http://rtsc.eclipse.org/docs-tip/Demo_of_the_RTSC_Platform_Wizard_in_CCSv4

    Or, just remove MEMORY directive from your cmd file not to duplicate the definitions of memories and to rely on the memories generated by "platform".

    Regards,
    Kawada 

  • Another question: 

    How is .bss(initialized) cleared when booting? 

    If .data or .rodata is not continuous, who will move the sections from load address to running address?

    Can you tell me the sequence fo section initialization in sysbios?


  • As for the section initialization, I think there is no difference between bios system and non-bios system.
    c_int00 from run time support library will setup the required C runtime environment and section initializations will be done at this time. In addition to this, if using bios system, some setup routine will run at this time.

    Now, your comment "How is .bss(initialized) cleared when booting" was not clear for me.

    Basically, the .bss initialization will be done in c_int00, but only done having the initial value. For example, please take a look the following:

    Int g_data1 = 1; // This global variable will be initialized with 1 before main().

    Int g_data2; // This global variable will NOT be initialized with zero before main().

    I'm not sure about AM335x runtime, but this is my understanding about Ti's runtime.
    Please verify that your global variable not having the initial value is not being initialized with 0 when PC is coming to main().

    Is this answer your question ?

    Regards,
    Kawada 

  • In load.cmd, .bss is last, but in final map, .bss(when .bss size is larger than text) is  in between boot code and .text. It will add the size of load image.

    You know, I want to place .bss into the last so that the final image can be small. 

    How can I put bss in the end of image whatever is the size of .bbs?

    In spec  ARMAssemblyLanguageToolsv5.1

    ReducingMemoryFragmentation: 

    Eachoutputsectionthat is included in aspecific,namedmemoryrange orthat hasmemoryattribute
    restrictionsis allocated.Eachoutputsectionis placedinto the first availablespacewithinthe named
    area,consideringalignmentwherenecessary.

    Anyremaining sectionsareallocatedin the orderin whichthey aredefined.Sectionsnotdefinedin a
    SECTIONSdirectiveareallocatedin the orderin whichthey areencountered.Eachoutputsectionis
    placedinto the first availablememoryspace,consideringalignmentwherenecessary.

  • Ok. I understand your point. 
    It may be depending on the bootloader, but as you know .bss section don't have to be reflected to the final boot image (hex image) and .bss will be configured properly in run time by c_int00. 

    If you intentionally want to put .bss to the last in your memory map, you can define the dedicated memory for .bss and place it to the last in your MEMORY directive. Or, you can apply the load address explicitly to bss section:

    .bss:  load = <load address>

    Please refer to the following manual in detail.
    http://www.ti.com/lit/ug/spnu118l/spnu118l.pdf 

    Regards,
    Kawada