Linux FFI question: library given function name?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Linux FFI question: library given function name?

Schwab,Wilhelm K
Hello all,

In the short term, I'm looking for where I might find syslog() and friends, but a fishing lesson would be even better.  How does one figure out in which library a named function lives?

Bill



_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Linux FFI question: library given function name?

hernanmd
http://www.linuxselfhelp.com/HOWTO/Program-Library-HOWTO/miscellaneous.html

2009/10/27 Schwab,Wilhelm K <[hidden email]>
Hello all,

In the short term, I'm looking for where I might find syslog() and friends, but a fishing lesson would be even better.  How does one figure out in which library a named function lives?

Bill



_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Linux FFI question: library given function name?

Schwab,Wilhelm K

That seems to work.  I found a similar looking script that did not.  So far, it's sending me to a static library that I have yet to associate with anything that FFI can load, but it's progress.

Thanks,

Bill

 



From: [hidden email] [mailto:[hidden email]] On Behalf Of Hernán Morales Durand
Sent: Wednesday, October 28, 2009 9:53 AM
To: [hidden email]
Subject: Re: [Pharo-project] Linux FFI question: library given function name?

http://www.linuxselfhelp.com/HOWTO/Program-Library-HOWTO/miscellaneous.html

2009/10/27 Schwab,Wilhelm K <[hidden email]>
Hello all,

In the short term, I'm looking for where I might find syslog() and friends, but a fishing lesson would be even better.  How does one figure out in which library a named function lives?

Bill



_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Linux FFI question: library given function name?

Martin McClure-2
Schwab,Wilhelm K wrote:
> That seems to work.  I found a similar looking script that did not.  So
> far, it's sending me to a static library that I have yet to associate
> with anything that FFI can load, but it's progress.

I'm not an expert in this field, but I've gone fishing for similar
things before. Here's what I did this time...

There's a man page for syslog in sections 2 and 3. The syslog (2) man
page (which is for the system call, I think not what you want)
references "the C library function syslog()" which I think *is* probably
what you're looking for.

The fact that it says it's a C library function leads me to believe that
it might be in libc, where a lot of this really fundamental stuff hides.
So I look in /lib to see what libc*.so files there are, find
/lib/libc-2.9.so, and try:

  objdump -T /lib/libc-2.9.so | grep syslog

which prints this:
00000000000ccff0 g    DF .text  0000000000000098  GLIBC_2.2.5 syslog
00000000000ccf60 g    DF .text  000000000000008b  GLIBC_2.4   __syslog_chk
00000000000ccf50 g    DF .text  0000000000000010  GLIBC_2.2.5 vsyslog
00000000000cc960 g    DF .text  00000000000005e2  GLIBC_2.4   __vsyslog_chk

I suspect this is what you're looking for.

Using nm on .so files reports that there are no symbols, so it's
probably better to use objdump.

Regards,

-Martin

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Linux FFI question: library given function name?

Schwab,Wilhelm K
Martin,

Objdump is a new one; I found readelf, which with the --symbols option seems to do the job, though the names look a little more C++ decorated.  That loud thump (by the time it reached your location) you just heard was me slapping my head over missing /lib.

Many thanks!

Bill



-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Martin McClure
Sent: Wednesday, October 28, 2009 3:12 PM
To: [hidden email]
Subject: Re: [Pharo-project] Linux FFI question: library given function name?

Schwab,Wilhelm K wrote:
> That seems to work.  I found a similar looking script that did not.  
> So far, it's sending me to a static library that I have yet to
> associate with anything that FFI can load, but it's progress.

I'm not an expert in this field, but I've gone fishing for similar things before. Here's what I did this time...

There's a man page for syslog in sections 2 and 3. The syslog (2) man page (which is for the system call, I think not what you want) references "the C library function syslog()" which I think *is* probably what you're looking for.

The fact that it says it's a C library function leads me to believe that it might be in libc, where a lot of this really fundamental stuff hides.
So I look in /lib to see what libc*.so files there are, find /lib/libc-2.9.so, and try:

  objdump -T /lib/libc-2.9.so | grep syslog

which prints this:
00000000000ccff0 g    DF .text  0000000000000098  GLIBC_2.2.5 syslog
00000000000ccf60 g    DF .text  000000000000008b  GLIBC_2.4   __syslog_chk
00000000000ccf50 g    DF .text  0000000000000010  GLIBC_2.2.5 vsyslog
00000000000cc960 g    DF .text  00000000000005e2  GLIBC_2.4   __vsyslog_chk

I suspect this is what you're looking for.

Using nm on .so files reports that there are no symbols, so it's probably better to use objdump.

Regards,

-Martin

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project