libtool
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dlopening the C runtime library


From: Paolo Bonzini
Subject: Re: dlopening the C runtime library
Date: Tue, 08 Dec 2009 13:21:57 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.4pre) Gecko/20090922 Fedora/3.0-3.9.b4.fc12 Lightning/1.0pre Thunderbird/3.0b4


Right. dlsym(RTLD_NEXT, "open") will give you the one that you shadowed;
this might not be the real symbol yet as there may be other wrappers
loaded, and it might not be the one from libc as applications are
allowed to provide their own definitions of symbols and have them take
precedence.

That looks like what I'm looking for. I don't seem to find an analogous
flag for lt_dlsym, in libtool's documentation, so I'll go with native
dlsym, then.

RTLD_NEXT seems like a better choice, but just in case I am using the following Autoconf stuff:

m4/libc-so-name.m4:
dnl Sets the variables LIBC_SO_NAME and LIBC_SO_DIR to the directory
dnl and basename for the C library.
AC_DEFUN([GST_LIBC_SO_NAME],
[AC_CACHE_CHECK([how to dlopen the C library], gst_cv_libc_so_name, [
  if test $GCC = yes; then
    gst_lib_path=`$CC --print-multi-os-directory $CFLAGS $CPPFLAGS`
    case $gst_lib_path in
      .) gst_lib_path= ;;
      *) gst_lib_path=$gst_lib_path/ ;;
    esac
  else
    gst_lib_path=
  fi
  case $gst_lib_path in
    /*) gst_libc_search_path="${gst_lib_path}libc.so*
          ${gst_lib_path}libc-*.so
          ${gst_lib_path}libc.sl
          ${gst_lib_path}libSystem.dylib" ;;
    *) gst_libc_search_path="/shlib/libc.so \
        /lib/${gst_lib_path}libc.so* \
        /usr/lib/${gst_lib_path}libc.so.* \
        /usr/lib/${gst_lib_path}libc.sl \
        /lib/${gst_lib_path}libc-*.so \
        /System/Library/Frameworks/System.framework/System \
        /usr/lib/libSystem.dylib"
  esac

  gst_lib_sysroot=`$CC --print-sysroot`
  for i in $gst_libc_search_path; do
    if test -f "$gst_lib_sysroot$i"; then
      oldwd=`pwd`
      gst_cv_libc_so_name=`basename $i`
      gst_cv_libc_so_dir=`dirname $i`
      cd "$gst_cv_libc_so_dir" && gst_cv_libc_so_dir=`pwd`
      cd $oldwd
      break
    fi
  done])
LIBC_SO_NAME=$gst_cv_libc_so_name
LIBC_SO_DIR=$gst_cv_libc_so_dir
AC_SUBST(LIBC_SO_NAME)
AC_SUBST(LIBC_SO_DIR)
])

libc.la.in:
# libc.la - a libtool library file
# Generated by GNU libtool
# Created for GNU Smalltalk's dynamic loading mechanism.

# The name that we can dlopen(3).
dlname='@LIBC_SO_NAME@'

# Names of this library.
library_names='@LIBC_SO_NAME@'

# Libraries that this one depends upon.
dependency_libs=''

# Is this an already installed library?
installed=yes

# Directory that this library needs to be installed in:
libdir='@LIBC_SO_DIR@'

in configure.ac:
GST_LIBC_SO_NAME
AC_CONFIG_FILES([libc.la])





reply via email to

[Prev in Thread] Current Thread [Next in Thread]