Partially Linked to Dynamic Linking in C

I'm still struggling to understand the core difference between dynamic linking and static linking, below is a picture and sample code from my textbook:

/* main2.c */
 #include <stdio.h>
 #include "vector.h"

 int x[2] = {1, 2};
 int y[2] = {3, 4};
 int z[2];

 int main()
   addvec(x, y, z, 2);
   printf("z = [%d %d]\n", z[0], z[1]);
   return 0;

and just a DLL that provides definition needed by main2.c

enter image description here

So my questions are:

Why p2 is a 'partially linked executable object file'? Since it is called 'partially linked', so it must have done some static linking. But since none of the code or data sections from or are actually copied into the executable p2 at this point. So why p2 is still 'partially linked'? Isn't the static linking is about copying code and data sections from objects files, if there is no copy, then there is no static linking involved?

1 answer

  • answered 2018-11-08 07:07 Antti Haapala

    The partially linked executable would have all of the .o object files (here only main.o) linked together, and possibly linking stubs, relocation tables and such to facilitate dynamic linking. The dynamic linker does just the remaining "n %" just before running the program.