RE: how to link only the used part of a lib file
The traditional task of linkers is to link complete object
And a library is a collection of one or more object files.
So the traditional way to create professional libraries is to
split the source code into many small files, giving the linker a
suitable granularity when selecting what to include.
Some specific compilers/linkers have moved some of the compiler
functionality into the linker, giving the linker the ability to play
around and cut/paste/finalize object code when linking. But that is
not part of the C standard, and not part of the behavior of the
system-supplied "standard" linker.
If function A always calls function B, and function B is never
expected to be called from anything but function A, then it is
suitable to have function A and B in the same source file. Else, you
should consider having them in individual source files.
So if you look at big runtime library source trees, you are likely
Often (almost) one source file for every exported library