Sign in to follow this  

question about linking

This topic is 1270 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

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

This topic is 1270 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this