4

Is there any relationship between the linking of binaries (as in dynamic or static linking) and symbolic links. Do they interact in any way, or share some history, or are these two completely orthogonal concepts that just happen to be called similarly?

4

Not at all. One involves redirecting all references to a file name ( any kind of file ) to a different file instead ( symlinks ), and the other involves building an executable image by copying code from a library into the executable ( static linking ) or referencing a dynamic library that contains the required code and loading that dynamic library at runtime.

0

Yes, they share a common sense of the word "link", in the abstract sense of "using a (text) key to look up a named resource". It's helpful to start by looking at the "regular" kind of file link, the hard link.

A hard link is an entry in a Unix directory that associates a name with a particular file on the disk by pointing to its inode. When the file is accessed (opened, stated), the filesystem driver looks up the inode corresponding to the requested name. The directory is a table that connects names with inode numbers; in this listing, the number at the front is the inode that the file is actually stored in:

6951168 -rwxr-xr-x 1 christopher christopher 209 Apr 24  2014 CAPS
6951172 -rwxr-xr-x 1 christopher christopher 976 Aug  6  2012 offline
6951175 -rwxr-xr-x 1 christopher christopher 541 Apr  8  2014 records-backup.sh
6950166 -rwxr-xr-x 1 christopher christopher 778 Nov  4 07:05 switch-monitors.sh

A symbolic link is a feature that, instead of pointing directly to the inode, points to a special tiny text file that has a relative path inside. For most purposes, it looks to programs like a regular hard link, and it got the name by analogy.

A linker in the sense of ld.so performs an operation analogous to the filesystem's use of hard links. C (and compatible) programs use a symbol table that lists the names of functions that the program wants to call from other libraries. The linker looks up the memory location for the function corresponding to each requested name and fills it in (the precise manner varies).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.