IS It possible? dynamic linker problem - Linux

This is a discussion on IS It possible? dynamic linker problem - Linux ; Hi, I encounter a very strange problem. Suppose there is a liba.so(version 1), liba.so(version 2), and the user b.elf. The version 1 has a function func_d, and version 2 did't have. The b.elf is linked with version 1, which has ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: IS It possible? dynamic linker problem

  1. IS It possible? dynamic linker problem

    Hi,

    I encounter a very strange problem. Suppose there is a liba.so(version
    1), liba.so(version 2), and the user b.elf. The version 1 has a
    function func_d, and version 2 did't have.

    The b.elf is linked with version 1, which has the func_d, its no
    problem. But when load, it is with version 2(don't have the func_d),
    but the b.elf can run successfuly, didn't complain with "unrelocatable
    symbol"!! What supprise!

    I mean, is it possible for linker to copy code from shared library(just
    as inline function), like static library. The result elf can benefit
    the load speed if this optimization is done.

    But I have done a small experiment that a library function only simple
    as:

    void a()
    {
    return;
    }

    I made two version with/without this function to see if the linker
    actually did the trick. Unfortunately, the load process complain
    "Unrelocatable symbol...".

    Very comfuse, any help appreciated.

    ABAI


  2. Re: IS It possible? dynamic linker problem



    On 12月11日, 下午1时44分, "Bin Chen"
    wrote:
    > Hi,
    >
    > I encounter a very strange problem. Suppose there is a liba.so(version
    > 1), liba.so(version 2), and the user b.elf. The version 1 has a
    > function func_d, and version 2 did't have.
    >
    > The b.elf is linked with version 1, which has the func_d, its no
    > problem. But when load, it is with version 2(don't have the func_d),
    > but the b.elf can run successfuly, didn't complain with "unrelocatable
    > symbol"!! What supprise!
    >
    > I mean, is it possible for linker to copy code from shared library(just
    > as inline function), like static library. The result elf can benefit
    > the load speed if this optimization is done.
    >
    > But I have done a small experiment that a library function only simple
    > as:
    >
    > void a()
    > {
    > return;
    >
    > }I made two version with/without this function to see if the linker
    > actually did the trick. Unfortunately, the load process complain
    > "Unrelocatable symbol...".
    >
    > Very comfuse, any help appreciated.
    >
    > ABAI


    Some additionals, when I run the program, the program prints "undefined
    symbol" when func_d is called. So it is relocated at run-time! But how
    do the loader know when to relocate the symbol, I mean, I meet two
    occations that complains the undefined symbol in load/run time.


  3. Re: IS It possible? dynamic linker problem

    On 2006-12-11, Bin Chen wrote:

    > Some additionals, when I run the program, the program prints "undefined
    > symbol" when func_d is called. So it is relocated at run-time! But how
    > do the loader know when to relocate the symbol, I mean, I meet two
    > occations that complains the undefined symbol in load/run time.


    man dlsym

    --

    Bye.
    Jasen

  4. Re: IS It possible? dynamic linker problem



    On Dec 12, 1:02 pm, jasen wrote:
    > On 2006-12-11, Bin Chen wrote:
    >
    > > Some additionals, when I run the program, the program prints "undefined
    > > symbol" when func_d is called. So it is relocated at run-time! But how
    > > do the loader know when to relocate the symbol, I mean, I meet two
    > > occations that complains the undefined symbol in load/run time.man dlsym


    This does not answer my question, I don't use dlopen in my code, only
    done automatically by compiler/linker.
    >
    > --
    >
    > Bye.
    > Jasen



  5. Re: IS It possible? dynamic linker problem

    On 2006-12-12, Bin Chen wrote:
    >> > Some additionals, when I run the program, the program prints "undefined
    >> > symbol" when func_d is called. So it is relocated at run-time! But how
    >> > do the loader know when to relocate the symbol, I mean, I meet two
    >> > occations that complains the undefined symbol in load/run time

    >
    > This does not answer my question, I don't use dlopen in my code, only
    > done automatically by compiler/linker.


    This most likely means that your dynamic libraries do not define the
    symbol or the symbol is not marked as global. Try starting your program
    with environment LD_BIND_NOW=1. This should report to you any unresolved
    symbols at start up. The functions do not get "relocated".

    --
    Minds, like parachutes, function best when open

  6. Re: IS It possible? dynamic linker problem



    On Dec 12, 4:20 pm, Andrei Voropaev wrote:
    > On 2006-12-12, Bin Chen wrote:
    >
    > >> > Some additionals, when I run the program, the program prints "undefined
    > >> > symbol" when func_d is called. So it is relocated at run-time! But how
    > >> > do the loader know when to relocate the symbol, I mean, I meet two
    > >> > occations that complains the undefined symbol in load/run time

    >
    > > This does not answer my question, I don't use dlopen in my code, only
    > > done automatically by compiler/linker.This most likely means that your dynamic libraries do not define the

    > symbol or the symbol is not marked as global. Try starting your program
    > with environment LD_BIND_NOW=1. This should report to you any unresolved
    > symbols at start up. The functions do not get "relocated".


    Thanks. So could you please tell me how can I distinguish it from
    "global" or "not", can objdump help?

    >
    > --
    > Minds, like parachutes, function best when open



  7. Re: IS It possible? dynamic linker problem

    On 2006-12-12, Bin Chen wrote:
    > On Dec 12, 4:20 pm, Andrei Voropaev wrote:

    [...]
    >> This most likely means that your dynamic libraries do not define the
    >> symbol or the symbol is not marked as global. Try starting your program
    >> with environment LD_BIND_NOW=1. This should report to you any unresolved
    >> symbols at start up. The functions do not get "relocated".

    >
    > Thanks. So could you please tell me how can I distinguish it from
    > "global" or "not", can objdump help?


    Well, of course. Though I usually check things with 'nm'. For example

    nm libmy.so

    provides a listing like

    00000000000199a0 t first_local
    00000000000197f7 t second_local
    000000000000ab09 T first_global
    000000000000aa44 T second_global

    The letter 't' in second column says that this is local to the library
    function, while 'T' indicates that this is global function. All other
    details are in man.

    --
    Minds, like parachutes, function best when open

+ Reply to Thread