This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

gcc globals, unexpected result

Other Parts Discussed in Thread: EK-TM4C1294XL, TM4C1294NCPDT

I'm getting some confusing behavior with gcc.  Here's some code that reproduces the problem:

/*

* main.c
*/
int xyz = 17;
int abc = 32;
int main(void) {
    int aaa;
    aaa = xyz; // shouldn't aaa == 17?
    aaa = abc; // shouldn't aaa == 32?
    while(1) {}
    return 0;
}

xyz gives me the value located at 0x2000004, which is  0x20000010 (which is the address of where the '17' is stored).  While abc gives me 0 (a value at 0x20000008).  The values (the 17 and 32) are in memory, starting at 0x20000010, a location named impure_data (whatever that is).

I encountered the problem when writing some assembler code, so I tried the above code to see what assembly code the compiler generated.  But it has the exact same issue.  Thus it must be an assembler or linker issue.

The TI compiler works as expected.  The reason I'm using GCC is that I had some other issues when writing assembler in the TI toolchain.  I'm developing exercises for an undergraduate class that covers ARM assembly.

Some details.

Tiva TM4C1294 Evaluation Kin (EK-TM4C1294XL)

css version 6.0.1.00040

GNU v4.7.4 (Linaro)