[EXT_EP-10762] Function local static array allocated to .data section, and not .bss Created: 21/Mar/22  Updated: 27/Apr/22  Resolved: 27/Apr/22

Status: Fixed
Project: Embedded Software & Tools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Medium
Reporter: TI User Assignee: TI User
Resolution: Fixed Votes: 0
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Product: Code Generation Tools
Internal ID: CODEGEN-9779
Found In Release: ARMCLANG_2.0.0.STS
ARMCLANG_1.3.1.LTS
Fix In Release: ARMCLANG_2.1.0.LTS
ARMCLANG_1.3.2.LTS*
Affected Platform/Device: default

 Description   

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.


Generated at Sun Apr 27 17:58:18 CDT 2025 using Jira 9.12.17#9120017-sha1:aba4002bcd633f188b6a4bb5dd8a0e1f20b79ee4.