Syntax

int shl_definesym( const char *sym, short type, long value, int flags )

Parameters

sym

A null-terminated string containing the name of the symbol to change or to add to the process's

 

shared library symbol table.

 

 

type

The type of symbol - either TYPE_PROCEDURE or TYPE_DATA.

 

 

value

If value falls in the address range of a currently loaded library, an association is made

 

and the symbol is undefined when the library is unloaded. (Note that memory dynamically

 

allocated with malloc(3C) does not fall in the range of any library.) The defined symbol

 

may be overridden by a subsequent call to this routine or by loading a more visible library

 

that provides a definition for the symbol.

 

 

flags

Must be set to zero.

 

 

Return Value

If successful, shl_definesym returns 0. Otherwise, it returns -1 and sets errno accordingly. See shl_definesym(3X) for details.

Description

The shl_definesym function allows you to add a new symbol to the global shared library symbol table. Use of this routine is unnecessary for most programmers.

There are two main reasons to add or change shared library symbol table entries:

to generate symbol definitions as the program runs - for example, aliasing one symbol with another

to override a current definition

Symbol definitions in the incomplete executable may also be redefined with certain restrictions:

The incomplete executable always uses its own definition for any data (storage) symbol, even if a more visible one is provided.

The incomplete executable only uses a more visible code symbol if the main program itself does not provide a definition.

The shl_getsymbols Routine

The shl_getsymbols routine retrieves symbols that are imported (referenced) or exported (defined) by a shared library. This information is returned in an allocated array of records, one for each symbol. Most programmers do not need to use this routine.

Syntax

int shl_getsymbols( shl_t handle, short type, int flags,

void * (*memfunc)(),

struct shl_symbol **symbols )

178 Shared Library Management Routines