dlsym(3)


NAME

   dlsym,  dlvsym  -  obtain  address  of  a  symbol in a shared object or
   executable

SYNOPSIS

   #include <dlfcn.h>

   void *dlsym(void *handle, const char *symbol);

   #define _GNU_SOURCE
   #include <dlfcn.h>

   void *dlvsym(void *handle, char *symbol, char *version);

   Link with -ldl.

DESCRIPTION

   The function dlsym() takes a "handle" of a dynamic loaded shared object
   returned  by  dlopen(3)  along  with a null-terminated symbol name, and
   returns the address where that symbol is loaded into  memory.   If  the
   symbol  is  not  found,  in  the  specified object or any of the shared
   objects that were automatically loaded by dlopen(3)  when  that  object
   was  loaded, dlsym() returns NULL.  (The search performed by dlsym() is
   breadth first through the dependency tree of these shared objects.)

   Since the value of the symbol could actually be NULL (so  that  a  NULL
   return  from  dlsym()  need  not indicate an error), the correct way to
   test for an error  is  to  call  dlerror(3)  to  clear  any  old  error
   conditions,  then  call dlsym(), and then call dlerror(3) again, saving
   its return value into a variable, and check whether this saved value is
   not NULL.

   There are two special pseudo-handles that may be specified in handle:

   RTLD_DEFAULT
          Find  the  first  occurrence  of  the  desired  symbol using the
          default shared object search order.   The  search  will  include
          global  symbols  in the executable and its dependencies, as well
          as symbols in shared objects that were dynamically  loaded  with
          the RTLD_GLOBAL flag.

   RTLD_NEXT
          Find  the  next  occurrence  of the desired symbol in the search
          order after the current object.  This allows one  to  provide  a
          wrapper around a function in another shared object, so that, for
          example, the definition of a  function  in  a  preloaded  shared
          object  (see  LD_PRELOAD  in  ld.so(8))  can find and invoke the
          "real" function provided in another shared object (or  for  that
          matter,  the  "next"  definition  of the function in cases where
          there are multiple layers of preloading).

   The function dlvsym() does the same as  dlsym()  but  takes  a  version
   string as an additional argument.

RETURN VALUE

   On  success, these functions return the address associated with symbol.
   On failure, they return NULL; the cause of the error can  be  diagnosed
   using dlerror(3).

VERSIONS

   dlsym()  is present in glibc 2.0 and later.  dlvsym() first appeared in
   glibc 2.1.

ATTRIBUTES

   For  an  explanation  of  the  terms  used   in   this   section,   see
   attributes(7).

   
   Interface          Attribute      Value   
   
   dlsym(), dlvsym()  Thread safety  MT-Safe 
   

CONFORMING TO

   POSIX.1-2001  describes  dlsym().   The  dlvsym()  function  is  a  GNU
   extension.

NOTES

   History
   The dlsym() function is part of the dlopen  API,  derived  from  SunOS.
   That system does not have dlvsym().

EXAMPLE

   See dlopen(3).

SEE ALSO

   dl_iterate_phdr(3),   dladdr(3),   dlerror(3),   dlinfo(3),  dlopen(3),
   ld.so(8)

COLOPHON

   This page is part of release 4.09 of the Linux  man-pages  project.   A
   description  of  the project, information about reporting bugs, and the
   latest    version    of    this    page,    can     be     found     at
   https://www.kernel.org/doc/man-pages/.





Opportunity


Personal Opportunity - Free software gives you access to billions of dollars of software at no cost. Use this software for your business, personal use or to develop a profitable skill. Access to source code provides access to a level of capabilities/information that companies protect though copyrights. Open source is a core component of the Internet and it is available to you. Leverage the billions of dollars in resources and capabilities to build a career, establish a business or change the world. The potential is endless for those who understand the opportunity.

Business Opportunity - Goldman Sachs, IBM and countless large corporations are leveraging open source to reduce costs, develop products and increase their bottom lines. Learn what these companies know about open source and how open source can give you the advantage.





Free Software


Free Software provides computer programs and capabilities at no cost but more importantly, it provides the freedom to run, edit, contribute to, and share the software. The importance of free software is a matter of access, not price. Software at no cost is a benefit but ownership rights to the software and source code is far more significant.


Free Office Software - The Libre Office suite provides top desktop productivity tools for free. This includes, a word processor, spreadsheet, presentation engine, drawing and flowcharting, database and math applications. Libre Office is available for Linux or Windows.





Free Books


The Free Books Library is a collection of thousands of the most popular public domain books in an online readable format. The collection includes great classical literature and more recent works where the U.S. copyright has expired. These books are yours to read and use without restrictions.


Source Code - Want to change a program or know how it works? Open Source provides the source code for its programs so that anyone can use, modify or learn how to write those programs themselves. Visit the GNU source code repositories to download the source.





Education


Study at Harvard, Stanford or MIT - Open edX provides free online courses from Harvard, MIT, Columbia, UC Berkeley and other top Universities. Hundreds of courses for almost all major subjects and course levels. Open edx also offers some paid courses and selected certifications.


Linux Manual Pages - A man or manual page is a form of software documentation found on Linux/Unix operating systems. Topics covered include computer programs (including library and system calls), formal standards and conventions, and even abstract concepts.