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.

CCS Linker problem? ( Interrupt vector "XXX" does not have an interrupt handler routine.)

Other Parts Discussed in Thread: MSP430G2553

I have a very strange behavior on my project, made out of a static library project, and an executable linking it.

On the library, I implemented most of the interrupt handlers, but compiling the executable I got warnings that some of those were not present (compiling the library alone in itself doesn't give anything).

Code is generically like:

#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR()
{
    // ...
}

So I played a little, and I discovered a crazy thing: if I move all the interrupt handlers on certain source files, they all get compiled and linked, but if I move them on other files, they don't go in the final executable, resulting in the warning as in subj.

The only thing I can think of is of different compiler settings on different source files, even if I created them with CCS and I didn't touch anything so specific.

Is there anyone that already find out a problem like this? Do you have any ideas on what to try?

Thanks in advance

Andrea

  • Hi Andrea,

    Andrea Bioli said:

    So I played a little, and I discovered a crazy thing: if I move all the interrupt handlers on certain source files, they all get compiled and linked, but if I move them on other files, they don't go in the final executable, resulting in the warning as in subj.

    The only thing I can think of is of different compiler settings on different source files, even if I created them with CCS and I didn't touch anything so specific.

    Could it be that the files get excluded from the project? You can check by right clicking at the file, and click on "Properties":

  • Thanks for the shot, Leo, but no way! :-(

    I'm double and triple checking anything, but I found another incredible behaviour, that I must explain.

    I have two different source files, let's say f1.cpp and f2.cpp, that contain handlers h1 and h2 (with all the pragmas, right names, and so on...).

    All the library is compiled wee. but if handler h1 is included perfectly on the executable, h2 isn't., and the compiler says it didn't find a handler for h2.

    Now, and this is wonderful, if I *APPEND* the source code from f1.cpp in f2.cpp (that contains the handler that is NOT included in the executable), magically it's all perfect, and both handlers are included in the executable. I hope it's clear, and I repeat it, that the source code from f1.cpp is appended AFTER the source code in f2.cpp, so (at least this is what I think!), there should be no influence of this source code.

    This, moreover, excludes every influence of potential different compiler settings in the source file (that anyway don't exist).

    Lastly, I can invert the source code of the handlers, but if they are together, they are linked perfectly both from f1.cpp or f2.cpp.

    For me this is really a strange problem: each step I take complicates the situation... :-(

    Andrea

  • ...and trying to find the core of the problem, I started again from scratch, just to implement a couple of interrupt handlers in a static library.

    Now the problem is even greater, if possible... :-(

    I see that I cannot force the linker to include the handlers on the executable at all (and you can see in the source code how I tried to *fool* the linker to include them... .-)).

    From a certain point of view, this is a feasible behaviour, since the functions are not referenced in the executable, so they are stripped away at link time, but I thought that the pragma, someway, could be understood someway to let these (particular) functions to be included.

    So, now, I feel that my new problem is just this: how to insert an interrupt handler in a static library, and have it linked to the executables that link this library?

    The source code is really really minimal...

    Andrea

    0880.Test.rar

  • Andrea Bioli said:
    f I move all the interrupt handlers on certain source files, they all get compiled and linked, but if I move them on other files, they don't go in the final executable

    The linker only includes into the build what it needs. However, it includes only .c files it it told to include, and only those which contain any code that is referenced from somewhere else. So if the ISRs got moved into a .c file that doe snot contain any code that is used, chances are the whole file won't be included into the build.
    Same for .c files which are in the project folder but do not have been explicitely added to the build process. (well, if the linekr doesn't throw other errors, then these files aren't required for the project anyway.

  • Jens,

    thanks for your time here too, but my particular case is a little more complex.

    Here I have a static library with the interrupt handlers, so all the process of building the library passes through the mysterious (at least for me!) archiver, and I link in the executable the generated .lib.

    Common sense tells me that the handlers are in the .lib, but now I don't have any mean to tell the linker that those particular functions are NOT directly referenced by code, but I need them in the process of building the executable!

    Adnrea

  • Andrea Bioli said:
    Here I have a static library with the interrupt handlers

    I see. So you have no reference to the interrupt handlers and therefore they are not included into the link.

    The easiest solution is to put the interrupt handlers into the same C file as, say a function 'include interrupt handlers'. Then the linker will put them into the build as soon as you call this dummy function from your main code. It doesn't have to do anything. It's just important that it is referenced.
    The linker can only include or exclude whole compilation units (the linker doesn't know about internal relations of code inside a *.c file). So if one part of a .c file is included, all is included. Binary libraries are just collections of precompiled .c files. The linker will pick the 'parts' that contain referenced elements. and will include them as a whole. even if much of them isn't really needed.
    Designing a library that doesn't include unnecessary parts is an art. even though you currently have the opposite problem :)

    Another way to force the linker to include the vectors is to use them in your main code. e.g. declare a function pointer and assign it the address of the ISR. Should work too. But will take some bytes ram while the dummy function call will only require flash.

  • Wonderful, Jens!

    Not only you gave me the solution to this last problem, but explaining me a process, I am now able to understand what caused me the other previous problems, so I really thank you very much! :-)

    Andrea

  • I met the problem too, can you help me? thanks QQ280806250,thank you very much 

  • If you have the same problem, then the answers already in this thread will help you. If they don’t, then you don’t have the same problem, and further information and details are needed. Best case in a separate, new thread.

    If you need clarifications for the above, then please ask in detail.

  • Exactl, I don't undestand your meaning, can you describe in Chinese?

  • Sorry, I don’t speak Chinese. If you don’t understand English well enough, you might ask old_cow_yellow for a translation in a private conversation.

  • Actually, my problem is not the same. There are some warnings when I debug my project of MSP430G2553 using CCS5.2. Just like this "

    Description Resource Path Location Type
    <a href="file:/D:/CCS5.2/ccsv5/tools/compiler/dmed/HTML/MSP430/10374.html">#10374-D</a> Interrupt vector "ADC10" does not have an interrupt handler routine. lnk_msp430g2553.cmd /430--EXInterrupt line 82 C/C++ Problem

    "

    These warnings present every time whether I use the interrupts.

    I think you can give some advises, thank you. 

  • The warnings just mean what they say. For the mentioned interrupt vectors, your code does not specify a handler.
    This is not necessarily a problem. If you don’t enable these interrupts, you don’t need a handler and you can ignore the warnings.
    The linker cannot know whether you do or not.

    However, if you enable one of these interrupts, even if accidentally, the MSP will crash when the interrupt happens.

    IIRC, future versions of CCS will list these warnings in a separate tab, so they are not confused with compiler warnings (which you should eliminate by code changes).

**Attention** This is a public forum