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 error with latest msp430-gcc

Other Parts Discussed in Thread: MSP430F5438, MSP430FR5959

I was previously building fine using version 3.05. I have switched to version 4.0.01 and I am now getting a linker error which I have no idea how to debug.

/opt/ti/gcc/bin/../lib/gcc/msp430-elf/5.3.0/large/libmul_f5.a(lib2hw_mul_f5.o): In function `__mulhi2_f5':
(.text.__mulhi2_f5+0x0): multiple definition of `__mspabi_mpyi'
/opt/ti/gcc/bin/../lib/gcc/msp430-elf/5.3.0/../../../../msp430-elf/bin/ld: Dwarf Error: Line info data is bigger (0xfffffffc) than the section (0x65)
/opt/ti/gcc/bin/../lib/gcc/msp430-elf/5.3.0/large/libgcc.a(mpy.o):mpy.c:(.text.__mulhi3+0x0): first defined here

I am building for an MSP430F5438 using the large memory model. This image contains more maths than most of the other things which are building correctly (even with the new compiler).

Thanks in advance.

  • To understand how this occurred, I need to reproduce it.  I took a guess at a few things and tried to reproduce it.  But I failed.  Is your code organized as a CCS project?  If so, I'd appreciate if you would submit that project.

    Thanks and regards,

    -George

  • Hi George,

    Thanks for the reply. No, it's not a CCS project, it's a build of our cross-platform codebase. We have our own makefiles and build the same code to target a wide range of other platforms. I would like to simplify the problem down but I'm pretty stuck as to where to start as I don't understand the error. Whilst I try randomly chopping bits out until the I get something small which reproduces the issue, could you enlighten me as to what __mspabi_mpyi and __mulhi2_f5 are for?


    Many thanks,

    Peter

  • They are helper functions for integer multiplication.
  • I can reproduce this compiling zMSP430-GCC 5.3 from source and using the distributed binaries: 

    #include <stdio.h>
    
    int main()
    {
        char a_string[64];
        snprintf(a_string, sizeof(a_string), "Does stdio work? %s", "Yes!");
    
        return a_string[21] == '\0' ? 0 : 1;
    }

    The following fails with the same error when invoking the compiler from the command line:

    /home/hdharmasiri/ti/gcc/bin/msp430-elf-gcc -o a.out dummy_bin.cc -mmcu=msp430fr5959 -L/home/hdharmasiri/ti/gcc/include
    

    That last option is just giving the linker access to all the LD files. It looks like it's linking in both the soft and hard integer multiplier routines even though -mmcu=msp430fr5959 declares that the HW MPY is available for 16/32-bit multiplies. It compiles successfully when I set -mhwmult=none. 

  • Hi Peter,

    I have come up with another workaround that means that the program will still use the hardware floating point. Because the problem is caused by the symbol being defined in both libgcc (which you don't want to use) and libmul_f5 (which you do want to use) then it seems to get the right one if you force the linker to look for it in that library by explicitly undefining the symbol and then putting libmul_f5 on the command line. So adding these options (before any other object files, may be best) to the linker command line seems to work:

    -Wl,--undefined=__mspabi_mpyi -lmul_f5

    We (SOMNIUM) are looking into why the symbol is multiply defined and hope to have a fix in the next release of the tools.

    Hope that helps

  • Hi Jamie,

    Fantastic, thank you. I can confirm that your proposed fix works for me. Much appreciated.

    Do you have a scheduled release data for a tool version which will contain a fix?

    Best regards,

    Peter

  • Peter,

    This will be fixed in Somnium's first release of msp430 gcc chain. The release should go out end of June or early July.

    Greg

  • Thanks Greg, looking forward to that release!