Linker and Libraries Guide


In the SolarisTM Operating System (Solaris OS), application developers can create applications and libraries by using the link-editor ld(1), and execute these objects with the aid of the runtime linker This manual is for engineers who want to understand more fully the concepts involved in using the Solaris OS link editors.

Note –

This Solaris release supports systems that use the SPARC® and x86 families of processor architectures: UltraSPARC®, SPARC64, AMD64, Pentium, and Xeon EM64T. The supported systems appear in the Solaris OS: Hardware Compatibility Lists at This document cites any implementation differences between the platform types.

In this document these x86 related terms mean the following:

For supported systems, see the Solaris OS: Hardware Compatibility Lists.

About This Manual

This manual describes the operations of the Solaris OS link-editor and runtime linker. Special emphasis is placed on the generation and use of dynamic executables and shared objects because of their importance in a dynamic runtime environment.

Intended Audience

This manual is intended for a range of programmers who are interested in the Solaris OS link editors, from the curious beginner to the advanced user.

Most programmers should not need to read this manual from cover to cover.

How This Book is Organization

Chapter 1, Introduction to the Solaris OS Link Editors provides an overview of the linking processes under the Solaris OS. This chapter is intended for all programmers.

Chapter 2, Link-Editor describes the functions of the link-editor. This chapter is intended for all programmers.

Chapter 3, Runtime Linker describes the execution environment and program-controlled runtime binding of code and data. This chapter is intended for all programmers.

Chapter 4, Shared Objects provides definitions of shared objects, describes their mechanisms, and explains how to create and use them. This chapter is intended for all programmers.

Chapter 5, Application Binary Interfaces and Versioning describes how to manage the evolution of an interface provided by a dynamic object. This chapter is intended for all programmers.

Chapter 6, Support Interfaces describes interfaces for monitoring, and in some cases modifying, link-editor and runtime linker processing. This chapter is intended for advanced programmers.

Chapter 7, Object File Format is a reference chapter on ELF files. This chapter is intended for advanced programmers.

Chapter 8, Thread-Local Storage describes Thread-Local Storage. This chapter is intended for advanced programmers.

Chapter 9, Mapfile Option describes the mapfile directives to the link-editor, which specify the layout of the output file. This chapter is intended for advanced programmers.

Appendix A, Link-Editor Quick Reference provides an overview of the most commonly used link-editor options, and is intended for all programmers.

Appendix B, Versioning Quick Reference provides naming conventions and guidelines for versioning shared objects, and is intended for all programmers.

Appendix C, Establishing Dependencies with Dynamic String Tokens provides examples of how to use reserved dynamic string tokens to define dynamic dependencies, and is intended for all programmers.

Appendix D, Linker and Libraries Updates and New Features provides an overview of new features and updates that have been added to the link-editors and indicates to which release they were added.

Throughout this document, all command line examples use sh(1) syntax. All programming examples are written in the C language.

Documentation, Support, and Training

The Sun web site provides information about the following additional resources:

Sun Welcomes Your Comments

Sun is interested in improving its documentation and welcomes your comments and suggestions. To share your comments, go to and click Feedback.

Typographic Conventions

The following table describes the typographic conventions that are used in this book.

Table P–1 Typographic Conventions





The names of commands, files, and directories, and onscreen computer output 

Edit your .login file.

Use ls -a to list all files.

machine_name% you have mail.


What you type, contrasted with onscreen computer output 

machine_name% su



Placeholder: replace with a real name or value 

The command to remove a file is rm filename.


Book titles, new terms, and terms to be emphasized 

Read Chapter 6 in the User's Guide.

A cache is a copy that is stored locally.

Do not save the file.

Note: Some emphasized items appear bold online.

Shell Prompts in Command Examples

The following table shows the default UNIX® system prompt and superuser prompt for the C shell, Bourne shell, and Korn shell.

Table P–2 Shell Prompts



C shell 


C shell for superuser 


Bourne shell and Korn shell 


Bourne shell and Korn shell for superuser