Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In order to have a shared object satisfy the requirements listed above we need to use the following ld options:

  • -soname.
  • -L to specify the library search path.
  • -l: to specify the library file names (without directories).
    • Specify every shared object used directly by the object being built.

Using -soname when building every shared object. Then whether you include the object as an input or search for it using -L and -l: puts the sonames of the referenced objects , ld will put the soname on the needed list, whereas just referencing an object as another input puts its file name on the list. Referencing an object that lacks an embedded soname will result in the file name of the object being put on the needed list which is not what we want. For efficiency we should also use --as-needed which will put only those sonames on the list whose objects actually satisfy references in the object being built; the default is to list every object named as an input or using -l:.

I recommend that we also use --no-add-needed which will prevent ld from putting indirect dependencies on the needed list, which would violate the principle of encapsulation. I don't think we want to rebuild a shared object if an indirect dependency changes.

...