I have an embedded application. The platform on which the program is ran is very limited in terms of resources(code memory included).
So I have a huge open-source library(.c and .h files), which is built along with my application(user) files.
Let assume I have a simple program in main.c
that never invokes any of the library functions. Example:
#include "main.h"
volatile int a;
int main()
{
while(1)
{
if(a)
{
a=0;
}
}
return 0;
}
I the example above, let say main.h includes all the library header files.
The size of the the .text
or ROM
section (in my opinion) should be very small, because the program does not need(at the current state of development) any of the library's functions (Let assume I include them for premature design).
Will the size of the code memory be as big as to contain all the compiled symbols? Or (somehow) the linker is smart enough to know that not-referenced symbols have no place in the output?
If yes, what is the mechanism that determines what symbol (from object files pool) is to be placed in the output?