I am trying to solve a challenge by using LD_PRELOAD to load my own strcmp library.
I first tried to compile my library with gcc -shared -fPIC strcmp.c -o strcmp.so, but when I tried to execute my file with LD_PRELOAD=/path/to/lib/strcmp.so ltrace ./exec, I had a the error :
object '/path/strcmp.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored By comparing file /path/to/strcmp.so and file exec, I found out that my exec file was a ELF 32-bit LSB executable and that my lib was a ELF 64-bit LSB shared object.
Then I tried to compile my lib with gcc -m32 -shared -fPIC strcmp.c -o strcmp.so, but when executing I have the same error (but this time with ELFCLASS32) :
object '/path/strcmp.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored Any suggestions? How can I have the same error with both 32 and 64 bits version of my lib?
ltrace? Perhaps it can't be linked against the 32-bit preload? If so, you might have to traceenv LD_PRELOAD=/path/to/lib/strcmp.so ./execinstead (assuming thatltracewill work across theexec()). Or just accept thatltracecan ignore the preload.ltrace .exec- withoutLD_PRELOAD). If so, you need to rebuild exec and strcmp.so for 64bit and try again. Or (if possible) install 32bit ltrace?