Oracle® Solaris 11.2 Linkers and Libraries Guide

Exit Print View

Updated: July 2014

Using the NODIRECT mapfile Keyword

The NODIRECT mapfile keyword provides a means of preventing a direct binding to individual symbols. This keyword allows for more fine grained control over preventing direct binding than the –B nodirect option.

From the components used in the previous example, can be built to prevent direct binding to the function o().

$ cat mapfile
$mapfile_version 2
                o       { FLAGS = NODIRECT };
$ cc -o -G -Kpic o.c -Mmapfile -zdirect -R.
$ cc -o -G -Kpic a.c -Bdirect -R.

The symbol information for and can be viewed with elfdump(1).

$ elfdump -y
     [1]  DBL     [3]            x
     [5]  DBL     [3]            y
     [6]  DL      [1]            o
     [9]  DBL     [1]            p
$ elfdump -y
     [3]  DB      [0]            x
     [4]  DB      [0]            y
     [6]  N                             o
     [7]  D           <self>            p only declares that the function o() can not be directly bound to. Therefore, is able to directly bind to the function p() in

Several individual interfaces within the Oracle Solaris libraries have been defined to not allow direct binding. One example is the data item errno. This data item is defined in This data item can be referenced by including the header file stdio.h. However, many applications were commonly taught to defined their own errno. These applications would be compromised if a family of system libraries were delivered which directly bound to the errno that is defined in

Another family of interfaces that have been defined to prevent direct binding to, are the malloc(3C) family. The malloc() family are another set of interfaces that are frequently implemented within user applications. These user implementations are intended to interpose upon any system definitions.

Note - Various system interposing libraries are provided with the Oracle Solaris OS that provide alternative malloc() implementations. In addition, each implementation expects to be the only implementation used within a process. All of the malloc() interposing libraries have been built with the –z interpose option. This option is not really necessary as the malloc() family within have been labelled to prevent any direct binding

However, the interposing libraries have been built with –z interpose to set a precedent for building interposers. This explicit interposition has no adverse interaction with the direct binding prevention definitions established within

Symbols that are assigned the STV_SINGLETON visibility can not be directly bound to. See Table 12–23. These symbols can be assigned by the compilation system to an implementation that might become multiply instantiated in a number of objects within a process. All references to a singleton symbol are bound to the first occurrence of a singleton symbol within a process.