libltdl proposal for libgcj

Anthony Green green@redhat.com
Mon Jul 12 17:17:00 GMT 2004


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.


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /