User's Manual

printf(" STORAGE ");
}
if ((flags & EXPORT_SYMBOLS) /* export symbols requested */
&& (flags & NO_VALUES)==0) /* NO_VALUES was NOT specified */
printf(" 0x%8X", symbols->value); /* so display symbol's address */
printf("\n"); /* terminate output line */
symbols++; /* move to next symbol record */
}
free(orig_symbols); /* free memory allocated by malloc */
return num_symbols; /* return the number of symbols */
}
The following example shows the source for a program named show_all.c that calls
show_symbols to show all imported and exported symbols for every loaded shared library. It
uses shl_get to get the library handles of all loaded libraries.
show_all - Use show_symbols to Show All Symbols
#include <dl.h>
#include <stdio.h>
/* prototype for show_syms */
int show_syms(shl_t hndl, short type, int flags);
main()
{
int idx, num_syms;
struct shl_descriptor * desc;
for (idx=0; shl_get(idx, &desc) != -1; idx++) /* step through libs */
{
printf("[%s]\n", desc->filename); /* show imports & exports for each */
printf(" Imports:\n");
num_syms = show_symbols(desc->handle, TYPE_UNDEFINED, IMPORT_SYMBOLS);
printf(" TOTAL SYMBOLS: %d\n", num_syms);
printf(" Exports:\n");
num_syms = show_symbols(desc->handle, TYPE_UNDEFINED, EXPORT_SYMBOLS);
printf(" TOTAL SYMBOLS: %d\n", num_syms);
}
}
The show_all program shown above was compiled with the command:
$ cc -Aa -o show_all show_all.c show_symbols.c -ldld
NOTE: The following output for the example differs in Itanium/PA64 mode. For example,
STORAGE is not supported.
The output produced by running this program is shown below:
[show_all]
Imports:
errno STORAGE
_start PROCEDURE
malloc PROCEDURE
free PROCEDURE
exit PROCEDURE
printf PROCEDURE
shl_get PROCEDURE
shl_getsymbols PROCEDURE
__d_trap PROCEDURE
TOTAL SYMBOLS: 9
Exports:
environ DATA 0x40001018
errno STORAGE 0x400011CC
_SYSTEM_ID DATA 0x40001008
__dld_loc STORAGE 0x400011C8
_FPU_MODEL DATA 0x4000100C
_end DATA 0x400011D0
_environ DATA 0x40001018
__d_trap PROCEDURE 0x7AFFF1A6
main PROCEDURE 0x7AFFF1BE
The shl_load Shared Library Management Routines 181