Archive for May, 2011

C++ library interposition

When running an application in linux, the search path for applications is the PATH environment variable. If an application uses libraries, the LD_LIBRARY_PATH environment variable can be used to override the default search locations from your ldconfig.

When you want to use a very specific library when starting an application, the LD_PRELOAD environment variable can be used. Your application will search for symbols first in the LD_PRELOAD libraries before it will try other sources.

One use of using specific libraries is debugging. The SUN developer network has the following nice example on how to use library interposition to see memory allocations:

#include <stdio.h>
#include <dlfcn.h>

void *malloc(size_t size)
  static void * (*func)();

    func = (void *(*)()) dlsym(RTLD_NEXT, "malloc");
  printf("malloc(%d) is called\n", size);     

When running ls with library interposition we will see the memory allocations:

$ cc -o -G -Kpic malloc_interposer.c
$ setenv LD_PRELOAD $cwd/
$ ls -l
malloc(64) is called
malloc(52) is called
malloc(1072) is called
-rwxr-xr-x  1 gregn  5224 Aug 3 15:21*

For more information, see the SUN developer network.

Sunday, May 1st, 2011 Uncategorized No Comments

Ubuntu resume from suspend takes long on an ASUS G2SV

If you have a problem with long waiting times after resuming an Ubuntu session on an ASUS G2SV, you may try blacklisting (disabling) some of the DVB modules by creating /etc/modprobe.d/blacklist-dvbusb.conf

blacklist dvb_usb
blacklist dvb_usb_dib0700

If you restart your system, your resume times may be much more friendly.

Sunday, May 1st, 2011 Uncategorized No Comments