• Advertisement
Sign in to follow this  

question about linking

This topic is 1307 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I always do not know this - If i link many object  modules (or library) and thay contain the functions that are not called from my code will they be linked to or stripped out form final exe? Thare maybe may be some differences in behavoiur of modules and libraries but im not sure..

 

?

 

 

Share this post


Link to post
Share on other sites
Advertisement

If you're talking about static libs, then the behavior depends on the compiler toolchain you're using as well as the settings provided for the linker. In Visual C++ for instance, dead-code stripping is controlled by the /OPT:REF command-line option.

Share this post


Link to post
Share on other sites

c standard is not saying something? or some common rule - that it is linked in or not?

Share this post


Link to post
Share on other sites

c standard is not saying something? or some common rule - that it is linked in or not?

"Linking" is not a concept addressed by the language standard, no.  There is no requirement in the language standard that a system offer separate compilation of modules, and indeed there are embedded systems that do not.

 

Practically, though, most modern (post-1960s at least) linkers will normally only satisfy undefined symbols from a static archive (library).  Dynamic shared objects (DLLs, .so files, .dylibs and so on) are loaded by the dynamic link-loader in their entirety, just as an executable is, but their symbol relocation tables may not be resolve until required (so-called "lazy" loading).  Command-line options can be used to vary that behaviour (eg. --Wl,-whole-archive passed to GCC).

 

Symbols from object modules may also have unreferenced symbols stripped.  That's going to depend on your linker and likely on the options passed o the linker.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement