Versions Compared

Key

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

...

OptionNeeds -Wl,
-shared 
-fpic or -fPIC 
-e (optional) 
-soname(tick)
--as-needed(tick)
--no-add-needed(tick)-zcombreloc(tick)
--zmax-page-size=4K(tick)
--hash-style=gnu(tick)
-l: (instead of -l) 

...

In order to have a shared object satisfy the requirements listed above we need to use -soname when building every shared object. Then whether you include the object as an input or search for it using -L and -l:, ld will put the soname on the needed 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.

All the direct dependencies of the shared object being built should be searched or included as inputs, and undefined references should cause the build to fail (--no-undefined). 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.

Dynamic symbol table

  1. Every shared object must have a GNU-style hash table (--hash-style=gnu). System V hash tables will be ignored.
  2. Symbols beginning with "lnk_" are used for data and functions to be made known to the dynamic linker. Currently in use are:
    1. "lnk_preferences" labels object preference data, passed to lnk_prelude().
    2. "lnk_prelude" labels a function to be called by the dynamic linker just after the functions pointed to by the .init_array have been run.

...