64 bit binary launching 32 bit binaries and LD_PRELOAD'ed shared lib - Solaris

This is a discussion on 64 bit binary launching 32 bit binaries and LD_PRELOAD'ed shared lib - Solaris ; Hi, Platform information: Solaris 10 running on AMD64. I have a 32-bit pre-loaded shared library 'mysharedlib.so' running with a 64-bit binary 'bin_exec_64'. LD_PRELOAD=mysharedlib.so bin_exec_64 ... I am getting the following error: wrong ELF class: ELFCLASS64 I read about this problem ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: 64 bit binary launching 32 bit binaries and LD_PRELOAD'ed shared lib

  1. 64 bit binary launching 32 bit binaries and LD_PRELOAD'ed shared lib

    Hi,

    Platform information: Solaris 10 running on AMD64.

    I have a 32-bit pre-loaded shared library 'mysharedlib.so' running
    with a 64-bit binary 'bin_exec_64'.

    LD_PRELOAD=mysharedlib.so bin_exec_64 ...

    I am getting the following error:

    wrong ELF class: ELFCLASS64

    I read about this problem on the web and found out about the
    specialized LD_PRELOAD_32/LD_FLAGS_32 (for pre-loading 32bit shared
    libs) and LD_PRELOAD_64/LD_FLAGS_64 (for pre-loading 64bit shared
    libs).

    However, if I set LD_PRELOAD_32=mysharedlib.so and execute 64-bit
    'bin_exec_64', none of the functions inside 'mysharedlib.so' are
    called.

    Is there is a strict rule in Solaris that only a 64-bit compiled
    shared library is suitable for pre-loading when run with a 64-bit
    binary? Is there any way I can use my 32-bit compiled
    'mysharedlibrary.so' with my 64-bit 'bin_exec_64'?

    Regards
    Rajesh

  2. Re: 64 bit binary launching 32 bit binaries and LD_PRELOAD'edshared lib

    Rajesh writes:

    > However, if I set LD_PRELOAD_32=mysharedlib.so and execute 64-bit
    > 'bin_exec_64', none of the functions inside 'mysharedlib.so' are
    > called.


    That is expected: LD_PRELOAD_32 affects *only* 32-bit processes.

    > Is there is a strict rule in Solaris that only a 64-bit compiled
    > shared library is suitable for pre-loading when run with a 64-bit
    > binary?


    Yes, Solaris and every other OS in wide use has such a restriction.
    You can't preload objects of the wrong bitness anymore than you
    can link them in directly (and you can't do that either).

    > Is there any way I can use my 32-bit compiled
    > 'mysharedlibrary.so' with my 64-bit 'bin_exec_64'?


    No. Since you "own" mysharedlibrary.so, why don't you just build a
    64-bit version of it?

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

  3. Re: 64 bit binary launching 32 bit binaries and LD_PRELOAD'ed sharedlib

    Thanks for your suggestions. I created a 64 bit version of
    'mysharedlibrary.so'. Also, I read on the groups/web that I have to
    set both LD_PRELOAD_32 and LD_PRELOAD_64 and ld.so will automatically
    do the right thing at runtime:

    $ LD_PRELOAD_32=/32_bit_compiled_shared_lib.so \
    LD_PRELOAD_64=/64_bit_compiled_shared_lib.so bin_exec_64

    However, the problem is that none of the functions inside either of my
    shared library are
    being called. Does anyone have any suggestions on debugging this
    problem ? I set LD_DEBUG=detail but not much help.

    Regards
    Rajesh

  4. Re: 64 bit binary launching 32 bit binaries and LD_PRELOAD'edshared lib

    Rajesh writes:

    > I read on the groups/web that I have to
    > set both LD_PRELOAD_32 and LD_PRELOAD_64 and ld.so will automatically
    > do the right thing at runtime:
    >
    > $ LD_PRELOAD_32=/32_bit_compiled_shared_lib.so \
    > LD_PRELOAD_64=/64_bit_compiled_shared_lib.so bin_exec_64


    Depends on what 'the right thing to do at runtime' is.

    Above will preload 32-bit DSO into every 32-bit process exec'd by
    bin_exec_64, and will preload 64-bit DSO into every 64-bit one
    (provided bin_exec_64 doesn't itself modify/unset these variables).

    >
    > However, the problem is that none of the functions inside either of my
    > shared library are being called.


    What functions did you define, are they actually defined in these
    DSOs (what does 'nm' say), and why do you expect them to be called
    (i.e. what makes you believe bin_exec_64 calls any of them)?

    > Does anyone have any suggestions on debugging this
    > problem ? I set LD_DEBUG=detail but not much help.


    This:

    LD_DEBUG=files,symbols,bindings,detail

    will probably give you more than you ever wanted to know.

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

+ Reply to Thread