This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/1319] dlsym/RTLD_NEXT is broken when more than 1 lib has the symbol.


------- Additional Comments From langlais at ilay dot org  2005-09-09 17:41 -------
According to http://www.opengroup.org/onlinepubs/009695399/toc.htm it is indeed
reserved for future use : 
>>>>>>>>>>>>>>>>>>
APPLICATION USAGE
        Special purpose values for handle are reserved for future use. These
values and their meanings are:
                
                
                RTLD_DEFAULT
                The symbol lookup happens in the normal global scope; that is, a
search for a symbol using this handle would find the same definition as a direct
use of this symbol in the program code.
                        RTLD_NEXT
                Specifies the next object after this one that defines name. This
one refers to the object containing the invocation of dlsym(). The next object
is the one found upon the application of a load order symbol resolution
algorithm (see dlopen()). The next object is either one of global scope (because
it was introduced as part of the original process image or because it was added
with a dlopen() operation including the RTLD_GLOBAL flag), or is an object that
was included in the same dlopen() operation that loaded this one. 
                        
                        The RTLD_NEXT flag is useful to navigate an
intentionally created hierarchy of multiply-defined symbols created through
interposition. For example, if a program wished to create an implementation of
malloc() that embedded some statistics gathering about memory allocations, such
an implementation could use the real malloc() definition to perform the memory
allocation-and itself only embed the necessary logic to implement the statistics
gathering function.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<                        
        
But as it *IS* documented in the man page as without mention of  "reservation
for future use". 
The bug is then where in the code, whether in the documentation. 

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Extract of "man dlsym" :
   dlsym
       The  function  dlsym()  takes a "handle" of a dynamic library returned by
dlopen and the NUL-terminated symbol
       name, returning the address where that symbol is loaded into memory.  If
the symbol is not found, in the spec-
       ified library or any of the libraries that were automatically loaded by
dlopen() when that library was loaded,
       dlsym() returns NULL.  (The search performed by dlsym() is breadth first
through the dependency tree of  these
       libraries.)  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() to clear any  old  error  condi-
       tions,  then  call  dlsym(), and then call dlerror() again, saving its
return value into a variable, and check
       whether this saved value is not NULL.

       There are two special pseudo-handles, RTLD_DEFAULT and RTLD_NEXT.  The
former will find the  first  occurrence
       of  the  desired symbol using the default library search order.  The
latter will find the next occurrence of a
       function in the search order after the current library.  This allows one
to provide a wrapper around  a  func-
       tion in another shared library.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |


http://sourceware.org/bugzilla/show_bug.cgi?id=1319

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]