This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: libltdl proposal for libgcj


It turns out that a simple solution is to prevent dlopen from doing its
own searches.  LD_PRELOADing the attached forces this behaviour.  It
still searches the LD_LIBRARY_PATH paths, but won't pick up
/lib:/usr/lib libraries.

I'm worried about doing anything more complicated now, especially in the
presence of multi-ABId systems (mips64-linux and x86-64 linux, for
instance).  I'll file a bugzilla case for future reference.

AG



/* Copyright (C) 2004  Red Hat, Inc.

   Written by Anthony Green <green@redhat.com>

   Distributed under the terms of the LGPL.  */
   
#define _GNU_SOURCE
#include <stdio.h>
#include <dlfcn.h>

static void *(*dlopen_) (const char *filename, int flag) __THROW;

/* Force constr to execute prior to main().  */
static void constr (void) __attribute__ ((constructor));

static void
constr (void)
{
  /* Get a pointer to the real function.  */
  dlopen_ = dlsym (RTLD_NEXT, "dlopen");
  if (dlopen_ == NULL)
    abort ();
}

/** Wrap dlopen.

    Only dlopen() absolute filenames.  */

void *dlopen (const char *filename, int flag) __THROW
{
  if (filename && filename[0] != '/')
    return NULL;
  return dlopen_ (filename, flag);
}



-- 
Anthony Green <green@redhat.com>
Red Hat, Inc.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]