Parameters

handle The handle of the shared library whose symbols you want to retrieve. If handle is NULL, shl_getsymbols returns symbols that were defined with the shl_definesym routine.

type

Defines the type of symbol to retrieve. It must be one of the following values, which are defined as

 

 

constants in <dl.h>:

 

 

 

 

 

 

 

 

 

 

TYPE_PROCEDURE

 

Retrieve only function or procedure symbols.

 

 

 

 

 

 

 

TYPE_DATA

 

Retrieve only symbols from the data segment (for example, variables).

 

 

 

 

 

 

 

TYPE_UNDEFINED

 

Retrieve all symbols, regardless of type.

 

 

 

 

 

 

 

TYPE_STORAGE

 

same as TYPE_DATA

 

 

 

 

flags

Defines whether to retrieve import or export symbols from the library. An import symbol is an external

 

 

reference made from a library. An export symbol is a symbol definition that is referenced outside the

 

 

library. In addition, any symbol defined by shl_definesym is an export symbol. Set this argument

 

 

to one of the following values (defined in <dl.h>):

 

 

 

 

 

 

 

IMPORT_SYMBOLS

 

To return import symbols.

 

 

 

 

 

 

 

EXPORT_SYMBOLS

 

To return export symbols.

 

 

 

 

 

 

 

INITIALIZERS

 

To return initializer symbols.

 

 

 

 

 

 

One of the following modifiers can be alternated with both the EXPORT_SYMBOLS and the

 

 

INITIALIZERS flags:

 

 

 

 

 

 

 

 

NO_VALUES

 

Do not calculate the value field of the shl_symbol structure for symbols.

 

 

 

 

The value field has an undefined value.

 

 

 

 

 

 

 

GLOBAL_VALUES

 

For symbols that are defined in multiple libraries, this flag causes

 

 

 

 

shl_getsymbols to return the most-visible occurrence, and to set the value

 

 

 

 

and handle fields of the shl_symbol structure (defined in the description

 

 

 

 

of the symbols parameter).

 

 

 

 

memfunc

Points to a function that has the same interface (calling conventions and return value) as malloc(3C).

 

 

The shl_getsymbols function uses this function to allocate memory to store the array of symbol

 

 

records, symbols.

 

 

 

 

 

 

 

symbols

This points to an array of symbol records for all symbols that match the criteria determined by the type

 

 

and value parameters. The type of these records is struct shl_symbol, defined in <dl.h> as:

 

 

 

 

struct shl_symbol {

 

 

 

 

char * name;

 

 

 

short

type;

 

 

 

void * value;

 

 

 

shl_t

handle;

 

 

 

};

 

 

The members of this structure are described in “The shl_symbol Structure” (page 180).

Return Value

If successful, shl_getsymbols returns the number of symbols found; otherwise, -1 is returned and shl_getsymbols sets errno to one of these values:

ENOEXEC

A format error was detected in the specified library.

 

 

ENOSYM

Some symbol required by the shared library cannot be found.

 

 

EINVAL

The specified handle is invalid.

 

 

ENOMEM

memfunc failed to allocate the requested memory.

 

 

The shl_load Shared Library Management Routines 179