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.

linker variable value problems

I have a variable in my linker script that I am using in my code so that it can tell where in memory it is loaded.  The problem is two-fold, first the correct value appears in the CCS "expressions" window during debug, but the program logic is not getting the correct value, and so the program thinks it is somewhere else.

From my linker .cmd file:

#define CURRENT_ROM_START        0x00022000
ROMAddress = CURRENT_ROM_START;

From my .c file:

extern const void * ROMAddress;

... later on in Init()...

    sprintf(DebugString, "ROM: 0x%08X", (unsigned long )ROMAddress);
    UARTSend(UART0_BASE, DebugString, 30);
    sprintf(DebugString, "CURR ROM: 0x%08X", CURRENT_ROM_START);
    UARTSend(UART0_BASE, DebugString, 30);

    switch ((unsigned long *)ROMAddress)
    {
    case CURRENT_ROM_START:
        UARTSend(UART0_BASE, "Running from Update ROM Location\r\n", 40);
        break;
    case FACTORY_ROM_START:
        UARTSend(UART0_BASE, "Running from Factory ROM Location\r\n",40);
        break;
    default:
        UARTSend(UART0_BASE, "ROM loaded in unusual location\r\n",40);
    }

The output of UART0 is correct for CURRENT_ROM_START, but gives me a memory location in SRAM, 0x2000770, for the value of ROMAddress.  Dereferencing, (unsigned long *) of this does not give me the correct value for ROMAddress.  Casting ROMAddress to a long or unsigned long doesn't help.  Here's the really puzzling part.  If I go to the "expressions" window in CCS v5.1 and type in ROMAddress, it pulls up the correct value.  When I compare ROMAddress == 0x00022000 it shows true in the expressions window, but does not test true in the actual program.

Anyone know what's going on.  Is there a way to cross-post this to the C/C++ compiler forum as well?