Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Linker Version Scripts

A version script is a text file containing instructions for the linker, ld. In order to use a version script, we must specify the —version-script linker option:

$ gcc -Wl,--version-script,myscriptfile.map ...

Version scripts are commonly (but not universally) identified using the extension .map.

The following sections describe some uses of version scripts.

Controlling Symbol Visibility with Version Scripts

One use of version scripts is to control the visibility of symbols that might otherwise accidentally be made global (i.e., visible to applications linking against the library). As a simple example, suppose that we are building a shared library from the three source files vis_comm.c, vis_f1.c, and vis_f2.c, which respectively define the functions vis_comm(), vis_f1(), and vis_f2(). The vis_comm() function is called by vis_f1() and vis_f2(), but is not intended for direct use by applications linked against the library. Suppose we build the shared library in the usual way:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint