The GNU component will extract the desired material from the libraries that you specified in the object file from the object file. Object files are atomic units with respect to the GNU linker. He does not share them. A component will enter an object file if this object file defines one or more unresolved external links. This object file may have external links. The compiler will try to resolve them, but if it cannot, the linker adds them to the set of links that need to be resolved.
There are a couple of fixes that can make a lot more of the necessary executable. For the most part, I mean an executable file that contains functions that will never be called, global objects that will never be checked or changed during program execution. You will have binary code not available.
One of these getchas results when an object file contains a large number of functions or global objects. Your program may need only one of them, but your executable gets all of them, because object files are atomic units for the linker. These additional functions will not be available because there is no call path from main to these functions, but they are still in your executable file. The only way to ensure that this does not happen is to use the "one function for each source file" rule. I myself do not follow this rule, but I understand its logic.
Another set of errors occurs when you use polymorphic classes. The constructor contains the automatically generated code, as well as the body of the constructor itself. This automatically generated code calls the constructors of the parent classes, inserts a pointer to the vtable for the class in the object, and initializes the data members in the list of initializers. These parent class constructors, vtable, and mechanisms for processing the list of initializers can be external references that the linker needs to eliminate. If the constructor of the parent class is in a larger header file, you just dragged it all into your executable.
How about a virtual table? The GNU compiler selects the key member function as the vtable storage location. This key function is the first member function in a class that does not have a built-in definition. Even if you do not call this member function, you get an object file that contains it in your executable file - and you get everything that drags on this object file.
Saving your source files to a small size once again helps with this: "Look what the cat has attracted!" problem. It is a good idea to pay particular attention to the file containing this member function. Keep this source file small, at least in terms of what the cat is dragging. I try to put small, stand-alone member functions in this source file. Functions that inevitably drag a bunch of other things should not go there.
Another problem with vtable is that it contains pointers to all virtual functions for the class. These pointers should point to something real. Your executable will contain object files that define each virtual function defined for the class, including those that you never call. And you get all those virtual drag and drop functions as well.
One solution to this problem is to prevent the creation of large, huge classes. They tend to pull in everything. The classes of God in particular are problematic in this regard. Another solution is to consider whether the function really should be virtual. Do not just make the function virtual, because you think that someone will have to overload it. This speculative commonality and virtual functions, speculative commonality, are associated with high cost.