Exported functions in shared libraries

Discussion in 'C Programming' started by gopan, Aug 30, 2007.

  1. gopan

    gopan Guest

    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
     
    gopan, Aug 30, 2007
    #1
    1. Advertising

  2. gopan

    Ian Collins Guest

    gopan wrote:
    > 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.

    --
    Ian Collins.
     
    Ian Collins, Aug 30, 2007
    #2
    1. Advertising

  3. gopan <> writes:
    > 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.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, Aug 30, 2007
    #3
  4. gopan

    jacob navia Guest

    gopan wrote:
    > 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
     
    jacob navia, Aug 30, 2007
    #4
  5. gopan

    CBFalconer Guest

    gopan wrote:
    >
    > 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.

    --
    Chuck F (cbfalconer at maineline dot net)
    Available for consulting/temporary embedded and systems.
    <http://cbfalconer.home.att.net>



    --
    Posted via a free Usenet account from http://www.teranews.com
     
    CBFalconer, Aug 30, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tshad
    Replies:
    11
    Views:
    850
    tshad
    May 27, 2005
  2. Tony Johansson
    Replies:
    3
    Views:
    2,191
    Jack Klein
    Dec 16, 2004
  3. XBSANTOS
    Replies:
    1
    Views:
    564
    Victor Bazarov
    May 2, 2005
  4. Mayer
    Replies:
    6
    Views:
    343
    M.E.Farmer
    Apr 27, 2005
  5. Etantonio
    Replies:
    13
    Views:
    881
Loading...

Share This Page