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

Structure is not initialized correctly when using -o2 or -o3 optimization

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Medium Medium
    • Code Generation Tools
    • CODEGEN-322
    • SDSCM00040934
    • Hide
      C2000_16.9.0.LTS
      MSP430_21.6.0.LTS
      C6000_8.1.0B1
      C6000_7.4.0B1
      ARM_5.2.0B1
      MSP430_16.9.0.LTS
      ARM_15.12.0.LTS
      C6000_8.2.0
      C2000_18.1.0.LTS
      C2000_6.4.0B1
      C6000_8.3.0
      MSP430_20.2.0.LTS
      ARM_18.12.0.LTS
      C2000_21.6.0.LTS
      MSP430_15.12.0.LTS
      PRU_2.3.0
      PRU_2.2.0
      PRU_2.1.0
      ARM_20.2.0.LTS
      C2000_20.2.0.LTS
      ARM_18.1.0.LTS
      MSP430_18.1.0.LTS
      ARM_16.9.0.LTS
      C2000_22.6.0.LTS
      C2000_15.12.0.LTS
      MSP430_4.4.0B1
      MSP430_18.12.0.LTS
      C2000_18.12.0.LTS
      ARP32_1.0.0B1
      Show
      C2000_16.9.0.LTS MSP430_21.6.0.LTS C6000_8.1.0B1 C6000_7.4.0B1 ARM_5.2.0B1 MSP430_16.9.0.LTS ARM_15.12.0.LTS C6000_8.2.0 C2000_18.1.0.LTS C2000_6.4.0B1 C6000_8.3.0 MSP430_20.2.0.LTS ARM_18.12.0.LTS C2000_21.6.0.LTS MSP430_15.12.0.LTS PRU_2.3.0 PRU_2.2.0 PRU_2.1.0 ARM_20.2.0.LTS C2000_20.2.0.LTS ARM_18.1.0.LTS MSP430_18.1.0.LTS ARM_16.9.0.LTS C2000_22.6.0.LTS C2000_15.12.0.LTS MSP430_4.4.0B1 MSP430_18.12.0.LTS C2000_18.12.0.LTS ARP32_1.0.0B1
    • Hide
      The initialization will have to be done at run-time, through a __sti initialization routine. You can see this routine when compiling without optimization. To workaround the compiler removing this initialization routine, initialize the object at the beginning of main:

      Info2.mSize = ((unsigned)_end_isr_stack - (unsigned)_start_isr_stack);
      Show
      The initialization will have to be done at run-time, through a __sti initialization routine. You can see this routine when compiling without optimization. To workaround the compiler removing this initialization routine, initialize the object at the beginning of main: Info2.mSize = ((unsigned)_end_isr_stack - (unsigned)_start_isr_stack);

      There is a problem with the initialization of a structure using symbols generated in the linker command file. We use symbols generated in the linker cmd file using the dot operator. These symbols are used as an initial value for a class/struct with a constructor. In our case we want the difference of two addresses that the linker generates.

      When using optimization -o2 or -o3, the compiler generates .cinit entries instead of the constructor call. In those .init-entries it doesn't use the difference of the addresses; instead it uses the first symbol.

      When turning off optimization or using lower level of opt than -o2, the constructor calls are generated and the struct is initialized correctly.

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

              Created:
              Updated: