[OpenIndiana-discuss] Setting LD_PRELOAD

Paul Johnston Paul.A.Johnston at manchester.ac.uk
Sun Nov 7 13:27:57 UTC 2010


  On 11/ 6/10 11:34 PM, McBofh wrote:
> On  7/11/10 08:57 AM, Paul Johnston wrote:
>> Under my thread about couchdb I was advised to set LD_PRELOAD.
>> I thought this had not worked but is seems bigger than that :-)
>>
>>> Then it appears that the LD_PRELOAD environment setting is not
>>> being passed onto the child. You need to try recompiling the
>>> executable beam.smp with '-LCrun'.
>>>
>>> Regards,
>>> Moinak.
>>
>> Err!
>> paulj at openindiana:~$ echo $LD_PRELOAD
>> /usr/lib/libCrun.so.1
>> paulj at openindiana:~$ ps
>> ld.so.1: ps: fatal: /usr/lib/libCrun.so.1: wrong ELF class: ELFCLASS32
>> Killed
>> paulj at openindiana:~$ prstat
>> ld.so.1: prstat: fatal: /usr/lib/libCrun.so.1: wrong ELF class: 
>> ELFCLASS32
>> Killed
>>
>> Well it sure is doing something if not fixing my couchdb problem :-)
>
>
> if you tried
>
> LD_PRELOAD=libCrun.so /path/to/utility
>
> then the linker should have found the correct library
> for the app that you invoked on the same command line.
>
> By just setting an env var, subsequent program invocations
> were forced to use the 32bit version, even if they are
> 64bit programs.
>
> McB
>
>
>
Dear all.
Please regard this as a learning exercise for me so if I don't do the 
exactly right thing I learn a little bit each iteration :-)
Anyway

paulj at openindiana:~$ grep PRELOAD .bashrc
LD_PRELOAD=/usr/lib/libCrun.so.1 
/usr/local/lib/erlang/erts-5.8.1.1/bin/beam.smp
export LD_PRELOAD

paulj at openindiana:~$ source .bashrc
Environment variable BINDIR is not set

paulj at openindiana:~$ file /usr/local/lib/erlang/erts-5.8.1.1/bin/beam.smp
/usr/local/lib/erlang/erts-5.8.1.1/bin/beam.smp:    ELF 32-bit LSB 
executable 80386 Version 1 [FPU], dynamically linked, not stripped
paulj at openindiana:~$ ldd /usr/local/lib/erlang/erts-5.8.1.1/bin/beam.smp
     libdl.so.1 =>     /lib/libdl.so.1
     libm.so.2 =>     /lib/libm.so.2
     libsocket.so.1 =>     /lib/libsocket.so.1
     libnsl.so.1 =>     /lib/libnsl.so.1
     libcurses.so.1 =>     /lib/libcurses.so.1
     libkstat.so.1 =>     /lib/libkstat.so.1
     libpthread.so.1 =>     /lib/libpthread.so.1
     libc.so.1 =>     /lib/libc.so.1
     libmp.so.2 =>     /lib/libmp.so.2
     libmd.so.1 =>     /lib/libmd.so.1

Just curious why setting LD_PRELOAD for a single file complains about BINDIR

As an aside if anyone can recommend good source/tutorial on linking / 
compiling in c I would be very grateful.

Cheers Paul



More information about the OpenIndiana-discuss mailing list