How to make ld generate error on missing symbols

Discussions and support about ChibiStudio, the free development environment for ARM.
Post Reply
bitto
Posts: 16
Joined: Thu Jan 30, 2014 9:45 am

How to make ld generate error on missing symbols

Post 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:

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

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
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: How to make ld generate error on missing symbols

Post 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
bitto
Posts: 16
Joined: Thu Jan 30, 2014 9:45 am

Re: How to make ld generate error on missing symbols

Post by bitto »

Thanks.

Alberto
Post Reply