Gcc only binds "required functions"

When compiling a C program, gcc binds the standard C library by default. Is it possible to link only selected functions, say printfinstead of a full library of standard C, to reduce the size of the executable to a minimum?

+3
source share
1 answer

With most traditional linkers, linking to a static library is based on an object file. gcc will typically use the system builder on the system used.

Traditionally, a static library is simply an archive file made up of object files that make up a library. When you link a static library to your program, the linker extracts from the library any object files that help resolve any unresolved characters in your program, including those that were entered by object files from the library that helped resolve previously unresolved characters.

Theoretically, if the standard library implementation consisted of one object file for each function and there were no dependencies between the standard library functions, then you would get only those functions that you explicitly called. In practice, you are more likely to get more features than you explicitly call included.

. , .

+5

All Articles