how to get access to functions by name? (fwd)

Don Holmgren (djholm@fndaub.fnal.gov)
Wed, 30 Sep 1998 13:49:30 -0500 (CDT)

Forwarded message:
Date: Wed, 30 Sep 1998 13:18:37 -0500
From: Petar Maksimovic <petar@heplcdf1.harvard.edu>
Subject: how to get access to functions by name?
To: pcfarms@fnal.gov
Errors-to: pcfarms-error@fnal.gov
Message-id: <199809301818.NAA04238@harv1.fnal.gov>

Hi,

in some cases it is quite useful (despite also being dangerous)
to be able to find a pointer to a function by supplying the
function's name. I append the code below (originally from
Rob Kennedy) that I successfully (and to my great satisfaction)
used on IRIX for years.

I wonder if anyone knows how to do this on Linux...

Thanks!

Petar

Appendix: a working IRIX example:
---------------8<----------------------------------------------
void* nm_find( const char *name )
{
const int nm_loc_total = (int) _procedure_table_size ;
int i;

for ( i = 0; i < nm_loc_total; i++ ) {
if ( strcmp( &_procedure_string_table[_procedure_table[i].irpss],
name ) == 0 ) {
printf("found %s at %d\n", name, _procedure_table[i].adr );
break;
}
}
return (void*) _procedure_table[i].adr;
}