Exported functions in shared libraries

G

gopan

I want to call the 'stat' system call dynamically.

In other words, I want to use the dlopen to dynamically load a shared
library and bind to the stat function using dlsym. I want to be able
to do this on Linux (Ubuntu) and Mac OS X.

My questions are:
0) Given a function name, how can I fiund out if it is available in a
shared library (.so) or only in a static library(.a)?
1) Given a function name, how can I find which shared library (.so)
exports that function?
2) Is the stat system call available as an exported function in a
shared library?

Thanks,
gopan
 
I

Ian Collins

gopan said:
I want to call the 'stat' system call dynamically.

In other words, I want to use the dlopen to dynamically load a shared
library and bind to the stat function using dlsym. I want to be able
to do this on Linux (Ubuntu) and Mac OS X.
You should try a Linux group, or comp.unix.programmer for a more generic
answer.
 
K

Keith Thompson

gopan said:
I want to call the 'stat' system call dynamically.

In other words, I want to use the dlopen to dynamically load a shared
library and bind to the stat function using dlsym. I want to be able
to do this on Linux (Ubuntu) and Mac OS X.
[snip]

Try comp.unix.programmer.
 
J

jacob navia

gopan said:
I want to call the 'stat' system call dynamically.

In other words, I want to use the dlopen to dynamically load a shared
library and bind to the stat function using dlsym. I want to be able
to do this on Linux (Ubuntu) and Mac OS X.

My questions are:
0) Given a function name, how can I fiund out if it is available in a
shared library (.so) or only in a static library(.a)?
1) Given a function name, how can I find which shared library (.so)
exports that function?
2) Is the stat system call available as an exported function in a
shared library?

Thanks,
gopan

You should FIRST build a database of functions. You scan the
/lib and /usr/lib and /usr/local/lib with the appropiate tools
(objdump comes to mind for instance).

Using this information you build a "database" as a text file
for instance, using two columns:
name of the function path to library.

This allows you to answer any question like (0) and (1) immediately.

To answer (2) you should look for it, (it is probably in the libc)

jacob
 
C

CBFalconer

gopan said:
I want to call the 'stat' system call dynamically.

In other words, I want to use the dlopen to dynamically load a shared
library and bind to the stat function using dlsym. I want to be able
to do this on Linux (Ubuntu) and Mac OS X.

There is not 'stat' system, nor dlopen, nor stat function, nor
dlsym in standard C. You should take your question to a Linux or
Ubuntu newsgroup. It is OT in c.l.c.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top