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.

ALIGN 2 doesn't align at HALF WORD Boundary for TI ARM 4.9.7 compiler

Hello Support,

Attached is a ZIP file where you can see that even though ALIGN 2 is present in the .\Debu\tctrmmrc.lst file, the corresponding CONST item is aligned to 4 Byte address in the .\Debug\test.map file.

Once you unzip the contents using WINZIP FOLDER option, you can run compile.bat file in case you want to rebuild yourself. Assuming you have the same path of 4.9.7 TI ARM compiler in your PC.

Else, you can change the path in compile.bat line
set COMPILER_PATH=

Attached is a picture of the MAP file to highlight the problem.

Let me know if you can't see the problem I am talking about.
Any help is appreciated.
Thank you.
Regards
Pashan

Linker_Bug11.zip
  • I can reproduce the behavior you describe.  I don't understand why the .const section from the file tctrmmrc.c has alignment of 4 bytes.  I think this is a bug in the assembler.  I filed SDSCM00050557 in the SDOWP system to have this investigated.  Feel free to follow it with the SDOWP link below in my signature.

    Thanks and regards,

    -George

  • Hello George,

     

    Is there any way I can override using ALIGN statement inside linker.def file for each of the filenames?

    linker.def contents shown below for reference.

        .MRAM_Const    :  SIZE(_MANAGED_ROM_COPY_DATA_LENGTH)
                            {
                              MANAGED_RAM_ROM_COPY_START = .;
    //                           * (.Default_Managed_RAM_Const)
    .\Debug\dcifxmrc.obj  (.const)
    .\Debug\dcprtmrc.obj  (.const)
    .\Debug\tcifxmrc.obj  (.const)
    .\Debug\tctrmmrc.obj  (.const)   --- Using some ALIGN statement
                               . = . + (0xF0 - .);              /* Reserve the remaining space   */
                            } load = (CAL_BLOCK /*align(16)*/)                  /* Default Managed RAM calibratable value */

    Thank you.
    Regards
    Pashan

  • There is no reason to try aligning things in the linker command file.  This turned out to be a problem in the compiler which is already fixed.

    The problem is the .field directive forces the section it appears in to be aligned to a 4-byte address.  And the compiler issued the .field directive as part of initializing the array within the structure.  Starting with compiler version 4.9.9, the compiler uses the .bits directive instead of .field.  The .bits directive does not force the 4-byte alignment, and gives you the 2-byte alignment you seek.  Please see this page on how to upgrade the compiler.  

    Since you are upgrading the compiler anyway, I encourage to upgrade all the way to the latest version 5.1.7.  Please see this wiki article for an general overview of the differences between compiler versions.

    Thanks and regards,

    -George

  • Hello George,

    It is really difficult for us to change the compiler at this stage of the development activity.

    That's why I am asking if in any way using some extra ALIGN statement in the linker I can at least make all the modules to always align at 4-Byte boundary guaranteed. Or, using some DOT operator tricks.

    Especially in this BSS section:

        .Managed_RAM_Area : SIZE(MANAGED_RAM_DATA_LENGTH)
                            {
                               MANAGED_RAM_START_LOCATION = .;
    //                           * (.Managed_RAM_Area) { SIZE(_MANAGED_RAM_CONTENT_LENGTH) }
    .\Debug\dcifxmrv.obj  (.bss)   -- ALIGN to 4-Byte boundaries GURANTEED
    .\Debug\dcprtmrv.obj  (.bss)   -- ALIGN to 4-Byte boundaries GURANTEED
    .\Debug\tcifxmrv.obj  (.bss)    -- ALIGN to 4-Byte boundaries GURANTEED
    .\Debug\tctrmmrv.obj  (.bss)   -- ALIGN to 4-Byte boundaries GURANTEED

                               . = . + (0xF0 - .);              /* Reserve the remaining space   */
                            } > MANAGED_RAM, type=NOINIT                    /* Managed RAM Application Area  */

    Please let me know.
    Thank you.
    Regards
    Partha

  • Pashan None said:
    It is really difficult for us to change the compiler at this stage of the development activity.

    Upgrading your compiler from version 4.9.7 to 4.9.9 is a particularly low risk change.  The only difference between these versions is bug fixes, including one bug fix you need.  Thus, this particular version change is likely to increase the stability of your builds.  Please see this wiki article for more detail.

    Presuming you still cannot upgrade ...

    I'm a little confused that you now want 4-byte alignment everywhere.  Up to this point your focus was on getting only 2-byte alignment, and avoiding holes caused by 4-byte alignment.

    Here is a way to force 4-byte alignment between input sections.

        .Managed_RAM_Area {
            . = align(4);
            file1.obj(.bss)
            . = align(4);
            file2.obj(.bss)
            . = align(4);
            /* and so on */
    
        }
          > MANAGED_RAM,
          type = NOINIT,
          SIZE(MANAGED_RAM_DATA_LENGTH),
    RUN(MANAGED_RAM_START_LOCATION)

    Note how I create the symbols for the section size and start address.  This avoids some known problems with using the '.' operator to create symbols.  And it collects those symbols together in one place.

    Instead of ...

    Pashan None said:
      . = . + (0xF0 - .);              /* Reserve the remaining space   */

    I think you would be happier using the fill=value attribute when you define the MANAGED_RAM memory range in the MEMORY directive.

    Thanks and regards,

    -George