A brief history of UNIX programming development

The traditional UNIX compilation technique historically involved static linking. With this technique, multiple object files defining global symbols and containing code and data were combined and written to an executable file with all the references resolved. The executable was a single self contained file, and often became quite large. However, since the name and location of all symbols were resolved at link-time, a program could be executed by simply reading it into memory and transferring control to its entry point. Static linking, which is still used in certain circumstances, has the following drawbacks:

  • If any of the libraries used by the program are updated, the program needs to be re-linked to take advantage of the updated libraries.

  • Disk space is wasted because every program on the system contains private copies of every library functions that it needs.

  • System memory is wasted because every running process loads into memory its own private copy of the same library functions.

To allow the libraries to be shared among different programs, the concept of shared libraries evolved. When a program is linked with a shared library, the shared library code is not included in the generated program executable file. Instead, information is saved in the program that allows the library to be found and loaded when the program is executed. Shared library code is loaded into global system memory by the first program that needs it and is shared by all programs that use it.

The advantages of shared libraries are:

  • Less disk space is used because the shared library code is not included in the executable programs.

  • Less memory is used because the shared library code is only loaded once.

  • The time taken to start an application may be reduced because the shared library code may already be in memory.

  • Performance may be improved because fewer page faults will be generated when the shared library code is already in memory.

When a program is linked with shared libraries, the resulting executable contains a list of symbols imported by it. The actual code is not included. Therefore, if one of the shared libraries is updated, programs using that library do not need to be re-linked, automatically picking up the current version of the library on its next execution. This makes application service and support easier since new versions of individual libraries containing patches and fixes can be shipped to customers without having to rebuild and ship a whole new version of the application.

When a program uses imported symbols, each of those symbols is associated with a specific shared library needed by the program. During program execution, the symbols do not have to be searched, but can be found by simply looking up their addresses in the specified shared library.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset