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.

MSPGCC Linker Error "dangerous relocation: unaligned address"

 suggested I post this in the CCS forum.  I'm not an expert on compilers and linkers, so please read my original post in the msp430 forum here.  

I'll try to reiterate and better explain what seems to be happening.  Lets say I have 3 source files, "main.c", "A.c" and "B.c".  Each is accompanied by a header file.  There is a variable function pointer to a runtime-assigned callback function contained in 'A':

typedef void (*cbFunction_t)(void);
cbFunction_t cbFoo = NULL;          // NULL is #defined earlier as 0

In 'B', I have a static uint8_t foo with global scope to that file.  When I compile, I get the linker error shown in the subject of this post.  If I change the variable foo from static to volatile, the error goes away.  If anyone has any answers, please explain.  Thanks.

  • Hi,

    We at the CCS and compiler forums do not support any MSP430 GCC releases, therefore I am afraid you may not find a clear answer here.

    However, I searched around and found this interesting post that clarifies and talks about the same warning message as you.

    This post also evidences a mailing list that may help you at this time with MSP430 GCC questions: the mspgcc-users. Check its archives here.

    Hope this helps,

    Rafael

  • Just for the record in case the link is dead in the future:

    "I did start digging into the mystery with more objdumps. However, the
    problem turned out to be a simple case of one file declaring a variable as
    uint8_t and another extern'ing it with uint16_t. The error message was a
    little scary, but the linker was actually doing the right thing. :-)"
    -Andy Turk

    I had a similar problem but instead, declaring the variable static, fixed the problem.