[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, Volume 1

dlsym Subroutine

Purpose

Looks up the location of a symbol in a module that is loaded with dlopen.

Syntax

#include <dlfcn.h>
void *dlsym(Data, Symbol);
void *Data;
const char *Symbol;

Description

The dlsym subroutine looks up a named symbol exported from a module loaded by a previous call to the dlopen subroutine. Only exported symbols are found by dlsym. See the ld command to see how to export symbols from a module.
Data Specifies a value returned by a previous call to dlopen.
Symbol Specifies the name of a symbol exported from the referenced module. The form should be a NULL -terminated string.
Note: C++ symbol names should be passed to dlsym in mangled form; dlsym does not perform any name demangling on behalf of the calling application.

A search for the named symbol is based upon breadth-first ordering of the module and its dependants. If the module was constructed using the -G or -brtl linker option, the module's dependants will include all modules named on the ld command line, in the original order. The dependants of a module that was not linked with the -G or -brtl linker option will be listed in an unspecified order.

Return Values

If the named symbol is found, its address is returned. If the named symbol is not found, NULL is returned and errno is set to 0. If Data or Symbol are invalid, NULL is returned and errno is set to EINVAL .

If the first definition found is an export of an imported symbol, this definition will satisfy the search. The address of the imported symbol is returned. If the first definition is a deferred import, the definition is ignored and the search continues.

If the named symbol refers to a BSS symbol (uninitialized data structure), the search continues until an initialized instance of the symbol is found or the module and all of its dependants have been searched . If an initialized instance is found, its address is returned; otherwise, the address of the first uninitialized instance is returned.

Error Codes

EINVAL If the Data parameter does not refer to a module opened by dlopen that is still loaded or if the Symbol parameter points to an invalid address, the dlsym subroutine returns NULL and errno is set to EINVAL.

Implementation Specifics

This subroutine is part of Base Operating System (BOS) Runtime.

Related Information

The dlclose subroutine, dlerror subroutine, dlopen subroutine, load subroutine, loadbind subroutine, loadquery subroutine, unload subroutine.

The ld command.


[ Previous | Next | Contents | Glossary | Home | Search ]