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.

Unresolved externals failing to appear!

I have a somewhat different type of "unresolved symbol" problem - the unresolveds are NOT showing up!
I noticed this during development because I've been radically changing function names and pointers etc.

I have a .h file that has a lot of extern statements like "extern int function1(void);" to declare the functions.

I do *not* have them defined.

I have a table of function pointers that attempt to reference said functions. The names of the functions in the
table are a little bit different than the extern'd names; hence, I would expect all sorts of "unresolved symbols" or something during the link.

That doesn't happen!  I even put in a direct function call to one of the declared but not
defined functions. The compiler and linker doesn't show me an unresolved, it just links!

I have created small project attempting to duplicate the issue for submission here - I can't!

Am I getting caught by some sort of CCS option that is inserting code for the unresolved functions?

Thanks,
Gary L. Coakley

  • You need to find the object file or library which unexpectedly defines the symbol.  Here is one way to do that.

    You don't say which target device you use.  Based on your other posts, it appears you use an ARM device.

    Suppose a function named no_such_function does not get the unresolved symbol error you expect.  Write a batch file or shell script which goes through every object file and library the linker sees.  It runs this command on each one ...

    % armnm file_name.obj | find /v " U " | find "no_such_function"

    That is how you would do it in a DOS command shell under Windows.  If you use some variant of Unix, then it would be ...

    % armnm file_name.obj | fgrep -v ' U ' | fgrep no_such_function

    The armnm command invokes the name utility on the object file or library.  That is documented in the chapter titled Object File Utilities in the ARM assembly tools manual.  The first find or fgrep command ignores any lines with ' U ' on them.  These are references to symbols which are not defined in that file.  A source line like

    extern void no_such_function();

    causes an undefined symbol to appear.  The last find or fgrep command looks for any appearance of no_such_function.  The file that which has it supplies the definition of no_such_function.

    Thanks and regards,

    -George

  • Are you absolutely sure the symbol actually appears in the executable file? Are you sure the compiler and linker haven't optimized out the reference to the undefined function?
  • Hmmm...
    Here is the most straight-forward example of what's happening. I do *not* rule out some kind of weird optimizing going on, but I *think* I have all optimizations off right now.

    At the beginning of a file foo.c I have:
    static void Func1(int);

    Later in the file I have:
    func1(I);


    NOWHERE else do I have Func1() anything defined. I know this because I just found this issue and it should have shown me an error because I inadvertently deleted to much "dead code" that wasn't dead!

    Gary
  • I presume you have typed both those function names correctly, especially regarding the upper case F in Func1 and the lower case f in the other func1.

    The static Func1 comes to nothing.  It is a static function declaration that is never called.

    As for the call to func1 ... I presume this is a global symbol name and not static.  Look in the map file to find the address of this function.  Then, in the part of the map file where it lists input section names and the address they start on, work out which input section contains the address for func1.  That will show you the name of the object file, or library module, which supplies the full implementation of func1.

    Thanks and regards,

    -George