2

Question: is the definition correct? If not, what should the correct definition be?

Here is the definition:

Dynamic linking is the process of resolving at runtime a program's external function calls or dependencies. It is usually performed at compile time by the linker.

This definition seems to be wildly incorrect - the second sentence, itself incorrect, contradicts the first.

The impression I am under regarding how things work in terms of binary creation and process creation can be summarized by the following (GCC + x86 Linux environment):

preprocessing -> compilation (compile time) -> assembly -> linking (link time)

then

execve (user space) -> exec (kernel) -> dynamic linker -> process (user space)

Since I don't know anything about dynamic linking in the context of other systems such as MS Windows and since the definition needs to be sufficiently generic, I am not in a position where I can suggest a new, correct and broadly applicable definition.

For reference, this question was prompted by some documentation I read over in order to answer Could not find ld-linux-x86-64.so.2 in strace output

  • Remove the second sentence. Problem solved ;) – dyasta Jul 26 '17 at 20:50
2

Yep, seems wrong, we'll need to fix it.

From Linkers and Loaders Ch.10:

Dynamic linking defers much of the linking process until a program starts running. It provides a variety of benefits that are hard to get otherwise:

  • Dynamically linked shared libraries are easier to create than static linked shared libraries.

  • Dynamically linked shared libraries are easier to update than static linked shared libraries.

  • The semantics of dynamically linked shared libraries can be much closer to those of unshared libraries.

  • Dynamic linking permits a program to load and unload routines at runtime, a facility that can otherwise be very difficult to provide.

This is probably too long for a tag definition so we'll need to trim it somewhat. It also refers to linking itself which is defined elsewhere.

2

You are right, that definition is incorrect because the second sentence contradicts the first. Who knows how the author got it wrong. Maybe he was distracted or thinking of something else. Maybe it was a copy and paste accident, but definitely it can be most simply corrected by deleting the second sentence.

  • Hey bitsum, thanks for the input. Would it be correct if the second sentence was changed to "It is performed by the dynamic linker at program load time" ? I'm asking because AFAIK this is true for Linux, but I don't know if this statement generalizes to Windows as well – julian Jul 27 '17 at 1:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .