0

When it is said that in dynamic linking the linker resolves the addresses of shared libraries at run time, does that mean the same linker that is used in static linker is called at run time? For example when using the gcc such as gcc mysource.c -o myprog does it skip the linking step if dynamic linking is used? If dynamic linking is used, is the same gcc linker called each time the program is run, or is this linker somehow different (i.e. comes with the operating system)?

If dynamic linking is used and linking technically hasn't happened yet when the executable file is outputted, how come the file is executable (since it missed the stage of linking)? Or is it not really executable until the dynamic linking has happened?

1 Answer 1

1

"Executable" only means "able to be loaded by a loader". It is the loader that is responsible for dynamic linking. The compile-time linker writes information in the executable's header about which libraries and symbols are used, and the loader reads this information in order to perform the linking.

2
  • Is the static linker part of the operating system or does it come with the compiler, for example the GNU tool chain? Also I don't get your definition of executable, anything can be loaded into Ram for example data, which as far as I know isn't considered executable.
    – Celeritas
    Oct 13, 2013 at 1:32
  • The static linker is part of a toolchain. The important part of the definition is "by a loader". Data files can be read into memory, but the loader isn't responsible for that. Oct 13, 2013 at 1:45

You must log in to answer this question.

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