how to see the list of reference of APIs of an library in my exe - Linux

This is a discussion on how to see the list of reference of APIs of an library in my exe - Linux ; Hello, How I can find list of references made to perticular library. For example my exe is using printf() from libc.so. But i do not know printf() has been references. And i want to know whether printf() is referenced or ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: how to see the list of reference of APIs of an library in my exe

  1. how to see the list of reference of APIs of an library in my exe

    Hello,
    How I can find list of references made to perticular library.
    For example my exe is using printf() from libc.so. But i do not know
    printf() has been references. And i want to know whether printf() is
    referenced or not?
    Is there any tool which lists external references
    -datha


  2. Re: how to see the list of reference of APIs of an library in myexe

    datha.krishnabhat@gmail.com writes:

    > How I can find list of references made to perticular library.


    You can't, because the references aren't made to a particular
    library. Instead, they are made to a particular function (this
    is one major difference between Win32 and ELF shared library models).

    > For example my exe is using printf() from libc.so. But i do not know
    > printf() has been references. And i want to know whether printf() is
    > referenced or not?


    That's easy:

    $ nm myexe | grep printf # if output is not empty, printf *is* referenced
    $ nm myexe | grep ' U ' # lists all "external" referenced symbols.

    Cheers,
    --
    In order to understand recursion you must first understand recursion.
    Remove /-nsp/ for email.

  3. Re: how to see the list of reference of APIs of an library in myexe

    >>How I can find list of references made to perticular library.
    >
    >
    > You can't, because the references aren't made to a particular
    > library. Instead, they are made to a particular function (this
    > is one major difference between Win32 and ELF shared library models).


    It is true that runtime references are made to functions.

    However, the symbol versioning used by glibc and other "system"
    shared libraries enforces some aspects of "reference to a particular
    library." The static binder (/bin/ld) records the symbol version
    that was used to verify that each undefined external reference
    could be satisfied at runtime [assuming that the same libraries
    are available at runtime.] Then the runtime dynamic linker
    (ld-linux.so.2) demands that the same symbol version be used
    at runtime. Because of the way that symbol versions are generated,
    in practice this means that a function with a symbol version
    cannot "move" to a different shared library. See the output from
    "readelf --version-info /bin/date" for example. 'printf' must
    have symbol version "GLIBC_2.0", and in practice this means
    it must be in libc.so.6.

    --

  4. Re: how to see the list of reference of APIs of an library in myexe

    John Reiser writes:

    > Because of the way that symbol versions are generated,
    > in practice this means that a function with a symbol version
    > cannot "move" to a different shared library.


    It sure *can* move (if one intentionally wants it to move):

    $ objdump --syms libtql_c_gcc.so.1 | grep vfprintf
    0003339c g F .text 00000207 vfprintf@GLIBC_2.0

    Cheers,
    --
    In order to understand recursion you must first understand recursion.
    Remove /-nsp/ for email.

  5. Re: how to see the list of reference of APIs of an library in my exe

    Paul Pluzhnikov writes:

    > $ nm myexe | grep ' U ' # lists all "external" referenced symbols.


    nm -U does the same.

    The readelf utility may also be of interest to the OP.

    --
    Måns Rullgård
    mru@inprovide.com

  6. Re: how to see the list of reference of APIs of an library in myexe

    Måns Rullgård writes:

    > Paul Pluzhnikov writes:
    >
    >> $ nm myexe | grep ' U ' # lists all "external" referenced symbols.

    >
    > nm -U does the same.


    None of my Linux systems understand 'nm -U'.

    They do understand 'nm -u', but it produces a larger list than what
    'nm | grep' outputs -- 'nm -u' also lists weakly unresolved, such as
    __gmon_start__, _Jv_RegisterClasses, etc.

    Cheers,
    --
    In order to understand recursion you must first understand recursion.
    Remove /-nsp/ for email.

  7. Re: how to see the list of reference of APIs of an library in my exe

    Paul Pluzhnikov writes:

    > Måns Rullgård writes:
    >
    >> Paul Pluzhnikov writes:
    >>
    >>> $ nm myexe | grep ' U ' # lists all "external" referenced symbols.

    >>
    >> nm -U does the same.

    >
    > None of my Linux systems understand 'nm -U'.
    >
    > They do understand 'nm -u',


    Which is what I meant, but didn't write. I guess I tripped on the U
    in your grep line.

    > but it produces a larger list than what 'nm | grep' outputs -- 'nm
    > -u' also lists weakly unresolved, such as __gmon_start__,
    > _Jv_RegisterClasses, etc.


    True.

    --
    Måns Rullgård
    mru@inprovide.com

+ Reply to Thread