Page 1 of 1

How to make ld generate error on missing symbols

Posted: Mon Oct 08, 2018 12:25 pm
by bitto
Hello,
first of all I hope this is not a duplicated topic; I have searched before posting, but I may have missed something.

I'm using ChibiStudio preview 20, and the reported behaviour is valid both for GCC 5.4 and GCC 7.0.

If I do not include in the Makefile a particular source file of my project that, for example, contains declaration and definition of funcion foo(), at compile time I get the warning:

src/main.c:214:44: warning: implicit declaration of function 'foo' [-Wimplicit-function-declaration]

and this is reasonable, since no declaration is found

However, at link-time ld does not complain at all.

Is there any option for gcc or ld that can be passed in order to have the linking phase exit with an error in case of unresolved symbols (or, alternatively, to print out a list of all unresolved symbols) ?

Thank you in advance.
Alberto

Re: How to make ld generate error on missing symbols

Posted: Mon Oct 08, 2018 2:49 pm
by Giovanni
Hi,

It is because garbage collector, unreferenced symbols are removed, so the function that refers the undefined symbol is removed because not called anywhere.

You can disable GC in makefile.

Giovanni

Re: How to make ld generate error on missing symbols

Posted: Mon Oct 08, 2018 4:42 pm
by bitto
Thanks.

Alberto