How to make ld generate error on missing symbols

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

How to make ld generate error on missing symbols

Postby bitto » Mon Oct 08, 2018 12:25 pm

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

User avatar
Giovanni
Site Admin
Posts: 11224
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 401 times
Been thanked: 333 times
Contact:

Re: How to make ld generate error on missing symbols

Postby Giovanni » Mon Oct 08, 2018 2:49 pm

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: 8
Joined: Thu Jan 30, 2014 9:45 am

Re: How to make ld generate error on missing symbols

Postby bitto » Mon Oct 08, 2018 4:42 pm

Thanks.

Alberto


Return to “ChibiStudio”

Who is online

Users browsing this forum: No registered users and 1 guest