c++assemblylinkerti-dsp

TI C2800 DSPs: troubleshooting linker problems between C++ and assembly code


I have a function sincos_Q15_asm() in assembly, in file sincos_p5sh.asm with directives as follows:

.sect   ".text"
.global _sincos_Q15_asm
.sym    _sincos_Q15_asm,_sincos_Q15_asm, 36, 2, 0
.func   1

The function works fine when I test it by itself (assembly only), but when I try to link to it, I get a linker error:

undefined                   first referenced
symbol                         in file
---------                   ----------------
sincos_Q15_asm(int, int *) build\pwm3phase.obj

error: unresolved symbols remain

This is very puzzling to me, as I am including the assembled file build\blocks\sincos_p5sh.obj in my linker command, and I've used the absolute lister abs2000 on this obj file and it says there is a symbol _sincos_Q15_asm. (the underscore prefix is how it works for assembly)

Any suggestions what I should troubleshoot next?


Solution

  • D'oh! I figured it out -- I was using C++ and forgot to include the extern "C" declaration for my function:

    extern "C" {
    extern void sincos_Q15_asm(int16_t theta, int16_t* cs);
    }