Uploaded image for project: 'Embedded Software & Tools'
  1. Embedded Software & Tools
  2. EXT_EP-10762

Function local static array allocated to .data section, and not .bss

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Medium Medium
    • Code Generation Tools
    • CODEGEN-9779
    • Hide
      ARMCLANG_2.0.0.STS
      ARMCLANG_1.3.1.LTS
      Show
      ARMCLANG_2.0.0.STS ARMCLANG_1.3.1.LTS
    • Hide
      ARMCLANG_2.1.0.LTS
      ARMCLANG_1.3.2.LTS*
      Show
      ARMCLANG_2.1.0.LTS ARMCLANG_1.3.2.LTS*
    • default

      The attached test case defines and uses a global array and a function local static array. Build it ...

      % tiarmclang -S file.c
      

      Inspect the assembly to see these lines for the definition of the static array ...

              .section        .data.fxn.static_array,"aw",%progbits
              .p2align        2
      fxn.static_array:
              .zero   400
      

      Compare that to the definition of the global array ...

              .comm   global_array,400,4
      

      It's in the common section, which eventually becomes .bss.

      The 400 bytes of zero in the .data section is a waste of memory. It would be better for the static array to be in .bss, and then get zero initialized by the startup code.

            syncuser TI User
            syncuser TI User
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: