Merging of globals optimization causes section containing only uninitialized global variables to be initialized

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: High
    • Code Generation Tools
    • CODEGEN-15667
    • Hide
      C29_1.0.0.LTS
      C29_3.0.0.LTS*
      ARMCLANG_4.0.0.LTS
      ARMCLANG_6.0.0.LTS*
      ARMCLANG_5.1.0.LTS
      C29_2.2.0.LTS
      Show
      C29_1.0.0.LTS C29_3.0.0.LTS* ARMCLANG_4.0.0.LTS ARMCLANG_6.0.0.LTS* ARMCLANG_5.1.0.LTS C29_2.2.0.LTS
    • Hide
      ARMCLANG_5.1.2.LTS*
      C29_2.2.2.LTS*
      C29_3.0.0.LTS*
      ARMCLANG_6.0.0.LTS*
      ARMCLANG_4.0.6.LTS*
      C29_1.0.3.LTS*
      Show
      ARMCLANG_5.1.2.LTS* C29_2.2.2.LTS* C29_3.0.0.LTS* ARMCLANG_6.0.0.LTS* ARMCLANG_4.0.6.LTS* C29_1.0.3.LTS*
    • default

      The attached source file defines two global variables in a user named section ...

      uint8_t VRM_StatusForUDS __attribute__((section(".porstram")));
      uint8_t VRM_StatusForUDS1 __attribute__((section(".porstram")));
      

      Build it ...

      % tiarmclang @options.txt -save-temps -c file.c
      

      Search the compiler generated assembly for the section name ...

      % findstr porstram file.s
              .section        .porstram,"aw",%progbits
      

      The %progbits syntax means the section is initialized.

      The section is expected to contain uninitialized variables and is typically allocated to RAM.  Most embedded systems require that initialized sections be allocated to flash, and never RAM.

      This happens as part of a compiler optimization called merging of global variables.

      A workaround is to disable the optimization with the compiler option -mno-global-merge.

            Assignee:
            TI User
            Reporter:
            TI User
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Connection: Intermediate to External PROD System
                EXTSYNC-6776 - Merging of globals optimization cau...
                SYNCHRONIZED
                • Last Sync Date: