Hello,
I'm trying to understand how to extract all available symbols from an executable, and therefore I've written the following simple function that should dump a nlist structure:
and in my program I do the following:
The first question is on how to know how many nlist structures have been extracted, since the nlist(3) function returns only the number of invalid entries. Second, the above loop does not work and stops in the middle with a signal 11, and I suspect it is something wrong with an element in the list, but inspecting it with the debugger does not show me any evident error. Does anybody has a clue?
I'm trying to understand how to extract all available symbols from an executable, and therefore I've written the following simple function that should dump a nlist structure:
Code:
void
dump_nlist( struct nlist *nlist ){
if( nlist == NULL || nlist->n_name == NULL )
printf( "\n\t---<null>---" );
else
printf( "\n\t---\n\tType [%c]\tName [%s]\n\tShort Desc [%d]\n\tAddress/value [%d]\n\tOther \
[%c]\n\t---",
nlist->n_type,
nlist->n_name,
nlist->n_desc,
nlist->n_value,
nlist->n_other );
}
and in my program I do the following:
Code:
struct nlist nlist_array[ 300 ];
struct nlist *nlistp = NULL;
...
nsymbols = nlist( boot_file_name, nlist_array );
for ( nlistp = nlist_array; nlistp; nlistp++ )
dump_nlist( nlistp );
The first question is on how to know how many nlist structures have been extracted, since the nlist(3) function returns only the number of invalid entries. Second, the above loop does not work and stops in the middle with a signal 11, and I suspect it is something wrong with an element in the list, but inspecting it with the debugger does not show me any evident error. Does anybody has a clue?