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

ELF symbol table entry for uninitialized static variable incorrectly shows size of 0

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Medium Medium
    • Code Generation Tools
    • CODEGEN-11328
    • Hide
      ARM_20.2.7.LTS
      C2000_22.6.0.LTS
      C6000_8.3.0
      MSP430_20.2.0.LTS
      C7000_2.1.0.LTS
      MSP430_21.6.0.LTS
      C2000_21.6.0.LTS
      PRU_2.3.0
      C7000_3.1.0.LTS
      ARM_20.2.0.LTS
      Show
      ARM_20.2.7.LTS C2000_22.6.0.LTS C6000_8.3.0 MSP430_20.2.0.LTS C7000_2.1.0.LTS MSP430_21.6.0.LTS C2000_21.6.0.LTS PRU_2.3.0 C7000_3.1.0.LTS ARM_20.2.0.LTS
    • Hide
      MSP430_20.2.8.LTS*
      C7000_2.1.3.LTS*
      MSP430_21.6.2.LTS*
      C7000_3.1.1.LTS
      C2000_22.6.1.LTS
      C6000_8.3.13
      ARM_20.2.8.LTS*
      PRU_2.3.4*
      C2000_21.6.2.LTS*
      Show
      MSP430_20.2.8.LTS* C7000_2.1.3.LTS* MSP430_21.6.2.LTS* C7000_3.1.1.LTS C2000_22.6.1.LTS C6000_8.3.13 ARM_20.2.8.LTS* PRU_2.3.4* C2000_21.6.2.LTS*
    • default

      The ELF symbol table entry for an uninitialized static variable incorrectly shows size of 0.

      The TI assembler was not correctly setting size for variables allocated using the .bss directive.
      .bss ||svar_bss||,1,1,0

      More details:
      ----------------
      The attached C file has these lines ...

      int global_variable;
      static int static_variable;
      
      void init(int *);
      int use_static()
      {
          init(&static_variable);
          return static_variable;
      }
      

      Build it with the proprietary TI Arm compiler, and the clang based TI Arm compiler.

      $ armcl file.c
      $ tiarmclang -c file.c
      

      Note armcl produces file.obj, and tiarmclang produces file.o . Compare the output of the names utility in long format.

      $ armnm -l file.obj | findstr variable
      [29]    |0x00000004|4|GLOB |COMN |HIDN |COMN  |global_variable
      [2]     |0x00000000|0|LOCL |OBJT |HIDN |3     |static_variable
      
      $ armnm -l file.o | findstr variable
      [7]     |0x00000004|4|GLOB |OBJT |HIDN |COMN  |global_variable
      [4]     |0x00000000|4|LOCL |OBJT |DFLT |7     |static_variable
      

      The third number is the size field of the symbol table entry. Compare the size field for static_variable. armcl shows 0, while tiarmclang shows 4.

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

              Created:
              Updated:
              Resolved: