I'm glad you're helping me with this. Apparently, my command doesn't work.
I've typed "LD_PRELOAD=/usr/lib/libhoard.so" which is where the shared object is located.
I have libc.so.6 loaded.
What am I doing wrong?
Edit: I've found typing "export LD_PRELOAD=/usr/lib/libhoard.so" helps but now I have both libraries loaded and the first program you gave me says it's still pulling malloc from libc.so.6 even though libhoard.so is loaded too.
Edit edit: Ha ha ha, I figured it out. First, I think all I have to really type is LD_PRELOAD=libhoard.so
With this, the output of ldd /bin/ls looks like this:
And Nominal, modifying your code because it didn't seem like it was doing what I wanted it to so I used:Code:linux-vdso.so.1 (0x00007fff6d9fe000)
libhoard.so => /usr/lib/libhoard.so (0x00007f7368cdf000)
libcap.so.2 => /usr/lib/libcap.so.2 (0x00007f7368adb000)
libacl.so.1 => /usr/lib/libacl.so.1 (0x00007f73688d2000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f7368525000)
libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f7368321000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f7368105000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f7367e01000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007f7367b03000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f73678ed000)
/lib64/ld-linux-x86-64.so.2 (0x00007f7368f16000)
libattr.so.1 => /usr/lib/libattr.so.1 (0x00007f73676e8000)
And got the following output:Code:libhoard_handle = dlopen(LIBHOARD_NAME, RTLD_NOW | RTLD_NOLOAD | RTLD_GLOBAL);
if (libhoard_handle) {
current_malloc = dlsym(RTLD_DEFAULT, "malloc");
libhoard_malloc = dlsym(libhoard_handle, "malloc");
if (current_malloc == libhoard_malloc) {
fprintf(stderr, "malloc() is from Hoard library (%s)\n", LIBHOARD_NAME);
} else {
fprintf(stderr, "malloc() is from an unknown library.\n");
}
dlclose(libhoard_handle);
} else {
fprintf(stderr, "%s: Hoard library not loaded.\n", LIBHOARD_NAME);
}
I knew it couldn't really be that simple! Or did I do this wrong?Code:malloc() is from Hoard library (libhoard.so)