Forum: Ruby DL: Array of symbols in a dynamic lib

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Benjohn B. (Guest)
on 2006-05-26 11:11
(Received via mailing list)
With DL, is there a way to ask for the symbols that exist within a
module that I've loaded?

For instance, once I've done...

	module_handle = DL::dlopen('my_lib')

Can I then ask module_handle for an array of symbols? I can't see a
likely looking method in there, and it seems like it'd be very nice
to have that kind of introspection available.

Off topic, can someone give me a good entry point for OS X's tool
chain for looking inside dynamic libraries, and understanding the
subject in general? I really found myself struggling! The only really
constructive thing I found out last night was that on OS X, you need
to ask cgg to make you:
	 -dynamiclib

This let me try an example out (which worked, wooO!), but I've no
idea where these things are usually kept (somewhere in bundles?). Or
how I can peek about in one.

Cheers,
	Benjohn
unknown (Guest)
on 2006-05-26 18:26
(Received via mailing list)
On Fri, 26 May 2006, Benjohn B. wrote:

>
> Cheers,
> 	Benjohn


it's not exactly what you're asking, but try

   strings libname.so

on the command line.

another useful command is

   ldd libname.so

also

   man ld.so

hth.

-a
Gregory S. (Guest)
on 2006-05-26 18:49
(Received via mailing list)
On Fri, May 26, 2006 at 11:24:15PM +0900, removed_email_address@domain.invalid 
wrote:
[...]
} it's not exactly what you're asking, but try
}
}   strings libname.so
}
} on the command line.
}
} another useful command is
}
}   ldd libname.so
}
} also
}
}   man ld.so

Actually, /usr/bin/nm is probably a better bet than any of these.

} hth.
} -a
--Greg
unknown (Guest)
on 2006-05-26 18:55
(Received via mailing list)
On Fri, 26 May 2006, Gregory S. wrote:

> }   ldd libname.so
> }
> } also
> }
> }   man ld.so
>
> Actually, /usr/bin/nm is probably a better bet than any of these.

indeed.  i'm still drinking my coffee! ;-)

-a
Benjohn B. (Guest)
on 2006-05-27 03:02
(Received via mailing list)
On 26 May 2006, at 15:53, removed_email_address@domain.invalid wrote:

>> }
> indeed.  i'm still drinking my coffee! ;-)
Brilliant :) Thanks Ara and Greg - they look good.
Benjohn B. (Guest)
on 2006-05-27 03:11
(Received via mailing list)
On 26 May 2006, at 23:59, Benjohn B. wrote:

>>> }   strings libname.so
>>>
>>> Actually, /usr/bin/nm is probably a better bet than any of these.
>>
>> indeed.  i'm still drinking my coffee! ;-)
>
> Brilliant :) Thanks Ara and Greg - they look good.

Interesting that objective c methods are verbosely described in a
symbol table. From the man pages of nm:

> If   the   symbol   is  a  Objective  C  method,  the  symbol
> name  is
>        +-[Class_name(category_name) method:name:],  where  `+'  is
> for  class
>        methods,  `-'  is  for instance methods, and (category_name)
> is present
>        only when the method is in a category.


I don't remember if objective c method signatures are typed though,
or if all of the parameters must be object ids? If the later's the
case, then you've got just about everything you need in the symbol
table and the header isn't really needed.
This topic is locked and can not be replied to.