libtool-patches
[Top][All Lists]
Advanced

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

329-gary-allow-RTLD_GLOBAL


From: Gary V. Vaughan
Subject: 329-gary-allow-RTLD_GLOBAL
Date: Sun, 8 Apr 2007 00:28:25 +0100 (BST)
User-agent: mailnotify/0.9

This fixes a regression from the NEWS file.  To alter the visibility
of symbols in loaded modules from the system default, you can now

    lt_dlopenflags("libmymod.la", LT_DLSYMGLOBAL);

Or even:

    lt_dlopenflags("myothermod", LT_DLYSMLOCAL|LT_DLTRYEXT)

since lt_dlopen and lt_dlopenext are now wrappers around this new
entrypoint.

I didn't write the documentation yet incase the interface changes
during patch review.  If there are no comments over the next few
days, I'll write those docs and commit.

Cheers,
        Gary

  Index: ChangeLog
  from  Gary V. Vaughan  <address@hidden>
        * libltdl/ltdl.c (BIT_GET, BIT_SET, BIT_RESET): New macros
        taken from GNU M4.
        (LT_DLGET_FLAG, LT_DLSET_FLAG): Use them.
        (LT_DLRESIDENT_FLAG): Removed.
        (LT_DLIS_RESIDENT): Use public LT_DLRESIDENT flag.
        (LT_DLIS_SYMLOCAL, LT_DLIS_SYMGLOBAL): New macros to test for
        module symbol visibility status.
        (tryall_dlopen): If vtable->module_open was able to act on
        either LT_DLSYMLOCAL or LT_DLSYMGLOBAL flags, store that in
        the handle flags.
        (lt_dlopenflags): New function that works like lt_dlopen,
        but accepts a bitfield to determine whether to ask dlloaders
        to change default symbol visibility.
        (lt_dlopen, lt_dlopenext): Just call lt_dlopenflags with the
        correct parameters.
        (lt_dlissymglobal, lt_dlissymlocal): New functions that test
        whether non-default symbol visibility was successfully
        requested on a module.
        * libltdl/ltdl.h: Declare all of the above.
        * libltdl/libltdl/lt_dlloader.h (lt_module_open): Add a new
        flags parameter.  Adjust all callers.
        * libltdl/libltdl/lt_error.h (CONFLICTING_FLAGS): New error
        for attempts to have local and global symbol visibility at the
        same time.
        * libltdl/loaders/dld_link.c, libltdl/loaders/dyld.c,
        libltdl/loaders/load_add_on.c, libltdl/loaders/loadlibrary.c,
        libltdl/loaders/preopen.c, libltdl/loaders/shl_load.c: Adjust.
        * libltdl/loaders/dlopen.c (RTLD_LOCAL, RTLD_GLOBAL): Try to
        define these symbols of the system has equivalents.
        (vmopen): If unable to act on a caller request to set symbol
        visibility, then unset the relevant bits in the flags field.
        * NEWS: Updated.
  
  Index: NEWS
  ===================================================================
  RCS file: /sources/libtool/libtool/NEWS,v
  retrieving revision 1.202
  diff -u -u -r1.202 NEWS
  --- NEWS 26 Mar 2007 20:18:43 -0000 1.202
  +++ NEWS 7 Apr 2007 23:24:36 -0000
  @@ -8,10 +8,6 @@
       libltdl currently does not build.  The new structure of libltdl with
       preopened modules exposes some long-lived bugs here.
   
  -  - Since libltdl does not use the RTLD_GLOBAL global flag with dlopen
  -    any more, some setups may fail.  A mechanism to allow the user to
  -    choose the mode has not been implemented yet.
  -
     - In 1.9b, a new variable inherited_linker_flags has been added to the
       libtool library files.  This variable takes flags that should be
       used by dependent libraries and programs, but that do not fit into
  @@ -60,6 +56,10 @@
       lt_dlhandle_iterate, lt_dlhandle_fetch, lt_dlhandle_map.
     - New lt_dlinterface_register to maintain separation of concerns
       between modules loaded by different libraries.
  +  - New lt_dlopenflags lets the caller request LT_DLSYMLOCAL or
  +    LT_DLSYMGLOBAL symbols from the module loader.  If neither is
  +    given, or if lt_dlopen (or lt_dlopenext) are called, then the
  +    system default module symbol visibility is used.
     - Allow shell special characters like `$' in source file names, but
       not in object names, to enhance GCJ support.
     - An entire new Autotest-based testsuite in addition to the old one.
  Index: libltdl/ltdl.c
  ===================================================================
  RCS file: /sources/libtool/libtool/libltdl/ltdl.c,v
  retrieving revision 1.248
  diff -u -u -r1.248 ltdl.c
  --- libltdl/ltdl.c 25 Mar 2007 12:12:42 -0000 1.248
  +++ libltdl/ltdl.c 7 Apr 2007 23:24:36 -0000
  @@ -1,7 +1,7 @@
   /* ltdl.c -- system independent dlopen wrapper
   
  -   Copyright (C) 1998, 1999, 2000, 2004, 2005,
  -                 2006 Free Software Foundation, Inc.
  +   Copyright (C) 1998, 1999, 2000, 2004, 2005, 2006,
  +                 2007 Free Software Foundation, Inc.
      Written by Thomas Tanner, 1998
   
      NOTE: The canonical source of this file is maintained with the
  @@ -58,16 +58,18 @@
   #undef       LT_SYMBOL_OVERHEAD
   #define LT_SYMBOL_OVERHEAD   5
   
  +#define BIT_GET(flags, bit)  (((flags) & (bit)) == (bit))
  +#define BIT_SET(flags, bit)  ((flags) |= (bit))
  +#define BIT_RESET(flags, bit)        ((flags) &= ~(bit))
   
   /* Various boolean flags can be stored in the flags field of an
      lt_dlhandle... */
  -#define LT_DLGET_FLAG(handle, flag) ((((lt__handle *) handle)->flags & 
(flag)) == (flag))
  -#define LT_DLSET_FLAG(handle, flag) (((lt__handle *)handle)->flags |= (flag))
  +#define LT_DLGET_FLAG(handle, bit) BIT_GET(((lt__handle *)handle)->flags, 
bit)
  +#define LT_DLSET_FLAG(handle, bit) BIT_SET(((lt__handle *)handle)->flags, 
bit)
   
  -#define LT_DLRESIDENT_FLAG       (0x01 << 0)
  -/* ...add more flags here... */
  -
  -#define LT_DLIS_RESIDENT(handle)    LT_DLGET_FLAG(handle, LT_DLRESIDENT_FLAG)
  +#define LT_DLIS_RESIDENT(handle)    LT_DLGET_FLAG(handle, LT_DLRESIDENT)
  +#define LT_DLIS_SYMGLOBAL(handle)   LT_DLGET_FLAG(handle, LT_DLSYMGLOBAL)
  +#define LT_DLIS_SYMLOCAL(handle)    LT_DLGET_FLAG(handle, LT_DLSYMLOCAL)
   
   
   static       const char      objdir[]                = LT_OBJDIR;
  @@ -111,16 +113,19 @@
                                       const char *base_name, char **pdir);
   static       lt_dlhandle *find_handle      (const char *search_path,
                                       const char *base_name,
  -                                    lt_dlhandle *handle);
  +                                    lt_dlhandle *handle, int flags);
   static       int     find_module           (lt_dlhandle *handle, const char 
*dir,
                                       const char *libdir, const char *dlname,
  -                                    const char *old_name, int installed);
  +                                    const char *old_name, int installed,
  +                                    int flags);
  +static  int     has_library_ext       (const char *filename);
   static       int     load_deplibs          (lt_dlhandle handle,  char 
*deplibs);
   static       int     trim                  (char **dest, const char *str);
   static       int     try_dlopen            (lt_dlhandle *handle,
  -                                    const char *filename);
  +                                    const char *filename, const char *ext,
  +                                    int flags);
   static       int     tryall_dlopen         (lt_dlhandle *handle,
  -                                    const char *filename);
  +                                    const char *filename, int flags);
   static       int     unload_deplibs        (lt_dlhandle handle);
   static       int     lt_argz_insert        (char **pargz, size_t *pargz_len,
                                       char *before, const char *entry);
  @@ -330,8 +335,12 @@
     return errors;
   }
   
  +
  +/* Try all dlloaders for FILENAME.  If the library is not successfully
  +   loaded, return non-zero.  Otherwise, the dlhondle is stored at the
  +   address given in PHANDLE.  */
   static int
  -tryall_dlopen (lt_dlhandle *phandle, const char *filename)
  +tryall_dlopen (lt_dlhandle *phandle, const char *filename, int flags)
   {
     lt__handle *       handle          = (lt__handle *) handles;
     const char *       saved_error     = 0;
  @@ -390,12 +399,19 @@
   
       while ((loader = (lt_dlloader *) lt_dlloader_next (loader)))
         {
  +     int flags_used = flags;
  +
        vtable = lt_dlloader_get (loader);
        handle->module = (*vtable->module_open) (vtable->dlloader_data,
  -                                              filename);
  +                                              filename, &flags_used);
   
        if (handle->module != 0)
          {
  +         if ((flags & flags_used & LT_DLSYMGLOBAL) != 0)
  +           LT_DLSET_FLAG(handle, LT_DLSYMGLOBAL);
  +         if ((flags & flags_used & LT_DLSYMLOCAL) != 0)
  +           LT_DLSET_FLAG(handle, LT_DLSYMLOCAL);
  +
            break;
          }
         }
  @@ -419,7 +435,7 @@
   
   static int
   tryall_dlopen_module (lt_dlhandle *handle, const char *prefix,
  -                   const char *dirname, const char *dlname)
  +                   const char *dirname, const char *dlname, int flags)
   {
     int      error     = 0;
     char     *filename = 0;
  @@ -453,10 +469,10 @@
        shuffled.  Otherwise, attempt to open FILENAME as a module.  */
     if (prefix)
       {
  -      error += tryall_dlopen_module (handle,
  -                                  (const char *) 0, prefix, filename);
  +      error += tryall_dlopen_module (handle, (const char *) 0,
  +                                     prefix, filename, flags);
       }
  -  else if (tryall_dlopen (handle, filename) != 0)
  +  else if (tryall_dlopen (handle, filename, flags) != 0)
       {
         ++error;
       }
  @@ -467,12 +483,13 @@
   
   static int
   find_module (lt_dlhandle *handle, const char *dir, const char *libdir,
  -          const char *dlname,  const char *old_name, int installed)
  +          const char *dlname,  const char *old_name, int installed,
  +          int flags)
   {
     /* Try to open the old library first; if it was dlpreopened,
        we want the preopened version of it, even if a dlopenable
        module is available.  */
  -  if (old_name && tryall_dlopen (handle, old_name) == 0)
  +  if (old_name && tryall_dlopen (handle, old_name, flags) == 0)
       {
         return 0;
       }
  @@ -483,22 +500,23 @@
         /* try to open the installed module */
         if (installed && libdir)
        {
  -       if (tryall_dlopen_module (handle,
  -                                 (const char *) 0, libdir, dlname) == 0)
  +       if (tryall_dlopen_module (handle, (const char *) 0,
  +                                 libdir, dlname, flags) == 0)
            return 0;
        }
   
         /* try to open the not-installed module */
         if (!installed)
        {
  -       if (tryall_dlopen_module (handle, dir, objdir, dlname) == 0)
  +       if (tryall_dlopen_module (handle, dir, objdir,
  +                                 dlname, flags) == 0)
            return 0;
        }
   
         /* maybe it was moved to another directory */
         {
  -       if (dir && (tryall_dlopen_module (handle,
  -                                 (const char *) 0, dir, dlname) == 0))
  +       if (dir && (tryall_dlopen_module (handle, (const char *) 0,
  +                                         dir, dlname, flags) == 0))
            return 0;
         }
       }
  @@ -703,10 +721,11 @@
   }
   
   static int
  -find_handle_callback (char *filename, void *data, void * LT__UNUSED ignored)
  +find_handle_callback (char *filename, void *data, void *data2)
   {
     lt_dlhandle  *handle               = (lt_dlhandle *) data;
     int                notfound        = access (filename, R_OK);
  +  int                flags           = *((int *) data2);
   
     /* Bail out if file cannot be read...  */
     if (notfound)
  @@ -714,7 +733,7 @@
   
     /* Try to dlopen the file, but do not continue searching in any
        case.  */
  -  if (tryall_dlopen (handle, filename) != 0)
  +  if (tryall_dlopen (handle, filename, flags) != 0)
       *handle = 0;
   
     return 1;
  @@ -724,13 +743,13 @@
      found but could not be opened, *HANDLE will be set to 0.  */
   static lt_dlhandle *
   find_handle (const char *search_path, const char *base_name,
  -          lt_dlhandle *handle)
  +          lt_dlhandle *handle, int flags)
   {
     if (!search_path)
       return 0;
   
     if (!foreach_dirinpath (search_path, base_name, find_handle_callback,
  -                       handle, 0))
  +                       handle, &flags))
       return 0;
   
     return handle;
  @@ -1066,16 +1085,18 @@
     return errors;
   }
   
  +
   /* Try to open FILENAME as a module. */
   static int
  -try_dlopen (lt_dlhandle *phandle, const char *filename)
  +try_dlopen (lt_dlhandle *phandle, const char *filename, const char *ext,
  +            int flags)
   {
  -  const char *       ext             = 0;
     const char *       saved_error     = 0;
     char *     canonical       = 0;
     char *     base_name       = 0;
     char *     dir             = 0;
     char *     name            = 0;
  +  char *        try             = 0;
     int                errors          = 0;
     lt_dlhandle        newhandle;
   
  @@ -1094,9 +1115,9 @@
         newhandle      = *phandle;
   
         /* lt_dlclose()ing yourself is very bad!  Disallow it.  */
  -      LT_DLSET_FLAG (*phandle, LT_DLRESIDENT_FLAG);
  +      LT_DLSET_FLAG (*phandle, LT_DLRESIDENT);
   
  -      if (tryall_dlopen (&newhandle, 0) != 0)
  +      if (tryall_dlopen (&newhandle, 0, flags) != 0)
        {
          FREE (*phandle);
          return 1;
  @@ -1107,9 +1128,24 @@
   
     assert (filename && *filename);
   
  +  if (ext)
  +    {
  +      try = MALLOC (char, LT_STRLEN (filename) + LT_STRLEN (ext) + 1);
  +      if (!try)
  +     return 1;
  +
  +      sprintf(try, "%s.%s", filename, ext);
  +    }
  +  else
  +    {
  +      try = lt__strdup (filename);
  +      if (!try)
  +     return 1;
  +    }
  +
     /* Doing this immediately allows internal functions to safely
        assume only canonicalized paths are passed.  */
  -  if (canonicalize_path (filename, &canonical) != 0)
  +  if (canonicalize_path (try, &canonical) != 0)
       {
         ++errors;
         goto cleanup;
  @@ -1139,11 +1175,11 @@
   
     assert (base_name && *base_name);
   
  -  ext = strrchr (base_name, '.');
     if (!ext)
       {
         ext = base_name + LT_STRLEN (base_name);
       }
  +  ext = strrchr (base_name, '.');
   
     /* extract the module name from the file name */
     name = MALLOC (char, ext - base_name + 1);
  @@ -1262,7 +1298,8 @@
        {
          newhandle = *phandle;
          /* find_module may replace newhandle */
  -       if (find_module (&newhandle, dir, libdir, dlname, old_name, 
installed))
  +       if (find_module (&newhandle, dir, libdir, dlname, old_name,
  +                        installed, flags))
            {
              unload_deplibs (*phandle);
              ++errors;
  @@ -1305,19 +1342,21 @@
         first in user_search_path and then other prescribed paths.
         Otherwise (or in any case if the module was not yet found) try
         opening just the module name as passed.  */
  -      if ((dir || (!find_handle (user_search_path, base_name, &newhandle)
  +      if ((dir || (!find_handle (user_search_path, base_name,
  +                              &newhandle, flags)
                   && !find_handle (getenv (LTDL_SEARCHPATH_VAR), base_name,
  -                                 &newhandle)
  +                                 &newhandle, flags)
   #if defined(LT_MODULE_PATH_VAR)
                   && !find_handle (getenv (LT_MODULE_PATH_VAR), base_name,
  -                                 &newhandle)
  +                                 &newhandle, flags)
   #endif
   #if defined(LT_DLSEARCH_PATH)
  -                && !find_handle (sys_dlsearch_path, base_name, &newhandle)
  +                && !find_handle (sys_dlsearch_path, base_name,
  +                                 &newhandle, flags)
   #endif
                   )))
        {
  -          if (tryall_dlopen (&newhandle, filename) != 0)
  +          if (tryall_dlopen (&newhandle, filename, flags) != 0)
               {
                 newhandle = NULL;
               }
  @@ -1347,6 +1386,7 @@
   
    cleanup:
     FREE (dir);
  +  FREE (try);
     FREE (name);
     if (!canonical)            /* was MEMREASSIGNed */
       FREE (base_name);
  @@ -1355,18 +1395,6 @@
     return errors;
   }
   
  -lt_dlhandle
  -lt_dlopen (const char *filename)
  -{
  -  lt_dlhandle handle = 0;
  -
  -  /* Just incase we missed a code path in try_dlopen() that reports
  -     an error, but forgets to reset handle... */
  -  if (try_dlopen (&handle, filename) != 0)
  -    return 0;
  -
  -  return handle;
  -}
   
   /* If the last error messge store was `FILE_NOT_FOUND', then return
      non-zero.  */
  @@ -1382,92 +1410,103 @@
     return 0;
   }
   
  -/* If FILENAME has an ARCHIVE_EXT or MODULE_EXT extension, try to
  -   open the FILENAME as passed.  Otherwise try appending ARCHIVE_EXT,
  -   and if a file is still not found try again with MODULE_EXT appended
  -   instead.  */
  -lt_dlhandle
  -lt_dlopenext (const char *filename)
  -{
  -  lt_dlhandle        handle          = 0;
  -  char *     tmp             = 0;
  -  char *     ext             = 0;
  -  size_t     len;
  -  int                errors          = 0;
   
  -  if (!filename)
  -    {
  -      return lt_dlopen (filename);
  -    }
  +/* Unless FILENAME already bears a suitable library extension, then
  +   return 0.  */
  +static int
  +has_library_ext (const char *filename)
  +{
  +  char *        ext     = 0;
  +  size_t        len;
   
     assert (filename);
  -
  +  
     len = LT_STRLEN (filename);
     ext = strrchr (filename, '.');
   
  -  /* If FILENAME already bears a suitable extension, there is no need
  -     to try appending additional extensions.  */
     if (ext && ((streq (ext, archive_ext))
   #if defined(LT_MODULE_EXT)
  -           || (streq (ext, shlib_ext))
  +             || (streq (ext, shlib_ext))
   #endif
  -      ))
  +    ))
       {
  -      return lt_dlopen (filename);
  +      return 1;
       }
  +    
  +  return 0;
  +}
  +
  +
  +/* Libtool-1.5x interface for loading a new module named FILENAME.  */
  +lt_dlhandle
  +lt_dlopen (const char *filename)
  +{
  +  return lt_dlopenflags (filename, 0);
  +}
   
  -  /* First try appending ARCHIVE_EXT.  */
  -  tmp = MALLOC (char, len + LT_STRLEN (archive_ext) + 1);
  -  if (!tmp)
  -    return 0;
   
  -  strcpy (tmp, filename);
  -  strcat (tmp, archive_ext);
  -  errors = try_dlopen (&handle, tmp);
  -
  -  /* If we found FILENAME, stop searching -- whether we were able to
  -     load the file as a module or not.  If the file exists but loading
  -     failed, it is better to return an error message here than to
  -     report FILE_NOT_FOUND when the alternatives (foo.so etc) are not
  -     in the module search path.  */
  -  if (handle || ((errors > 0) && !file_not_found ()))
  +/* If FILENAME has an ARCHIVE_EXT or MODULE_EXT extension, try to
  +   open the FILENAME as passed.  Otherwise try appending ARCHIVE_EXT,
  +   and if a file is still not found try again with MODULE_EXT appended
  +   instead.  */
  +lt_dlhandle
  +lt_dlopenext (const char *filename)
  +{
  +  return lt_dlopenflags (filename, LT_DLTRYEXT);
  +}
  +
  +lt_dlhandle
  +lt_dlopenflags (const char *filename, int flags)
  +{
  +  lt_dlhandle        handle          = 0;
  +  int                errors          = 0;
  +
  +  if (BIT_GET(flags, LT_DLSYMLOCAL) && BIT_GET(flags, LT_DLSYMGLOBAL))
       {
  -      FREE (tmp);
  -      return handle;
  +      LT__SETERROR (CONFLICTING_FLAGS);
  +      return 0;
       }
   
  -#if defined(LT_MODULE_EXT)
  -  /* Try appending MODULE_EXT.   */
  -  if (LT_STRLEN (shlib_ext) > LT_STRLEN (archive_ext))
  +  if (!filename || !BIT_GET(flags, LT_DLTRYEXT) || has_library_ext 
(filename))
       {
  -      FREE (tmp);
  -      tmp = MALLOC (char, len + LT_STRLEN (shlib_ext) + 1);
  -      if (!tmp)
  -     return 0;
  +      lt_dlhandle handle = 0;
   
  -      strcpy (tmp, filename);
  +      /* Just incase we missed a code path in try_dlopen() that reports
  +         an error, but forgets to reset handle... */
  +      if (try_dlopen (&handle, filename, NULL, flags) != 0)
  +        return 0;
  +
  +      return handle;
       }
     else
       {
  -      tmp[len] = LT_EOS_CHAR;
  -    }
  +      assert (filename);
  +      
  +      /* First try appending ARCHIVE_EXT.  */
  +      errors += try_dlopen (&handle, filename, archive_ext, flags);
  +
  +      /* If we found FILENAME, stop searching -- whether we were able to
  +         load the file as a module or not.  If the file exists but loading
  +         failed, it is better to return an error message here than to
  +         report FILE_NOT_FOUND when the alternatives (foo.so etc) are not
  +         in the module search path.  */
  +      if (handle || ((errors > 0) && !file_not_found ()))
  +        return handle;
   
  -  strcat(tmp, shlib_ext);
  -  errors = try_dlopen (&handle, tmp);
  +#if defined(LT_MODULE_EXT)
  +      /* Try appending SHLIB_EXT.   */
  +      errors = try_dlopen (&handle, filename, shlib_ext, flags);
   
  -  /* As before, if the file was found but loading failed, return now
  -     with the current error message.  */
  -  if (handle || ((errors > 0) && !file_not_found ()))
  -    {
  -      FREE (tmp);
  -      return handle;
  -    }
  +      /* As before, if the file was found but loading failed, return now
  +         with the current error message.  */
  +      if (handle || ((errors > 0) && !file_not_found ()))
  +        return handle;
   #endif
  -
  +    }
  +    
     /* Still here?  Then we really did fail to locate any of the file
        names we tried.  */
     LT__SETERROR (FILE_NOT_FOUND);
  -  FREE (tmp);
     return 0;
   }
   
  @@ -2020,7 +2059,7 @@
       }
     else
       {
  -      LT_DLSET_FLAG (handle, LT_DLRESIDENT_FLAG);
  +      LT_DLSET_FLAG (handle, LT_DLRESIDENT);
       }
   
     return errors;
  @@ -2038,9 +2077,32 @@
     return LT_DLIS_RESIDENT (handle);
   }
   
  +int
  +lt_dlissymglobal (lt_dlhandle handle)
  +{
  +  if (!handle)
  +    {
  +      LT__SETERROR (INVALID_HANDLE);
  +      return -1;
  +    }
  +
  +  return LT_DLIS_SYMGLOBAL (handle);
  +}
  +
  +int
  +lt_dlissymlocal (lt_dlhandle handle)
  +{
  +  if (!handle)
  +    {
  +      LT__SETERROR (INVALID_HANDLE);
  +      return -1;
  +    }
  +
  +  return LT_DLIS_SYMLOCAL (handle);
  +}
  +
   
   
  -
   /* --- MODULE INFORMATION --- */
   
   typedef struct {
  Index: libltdl/ltdl.h
  ===================================================================
  RCS file: /sources/libtool/libtool/libltdl/ltdl.h,v
  retrieving revision 1.84
  diff -u -u -r1.84 ltdl.h
  --- libltdl/ltdl.h 25 Mar 2007 12:12:42 -0000 1.84
  +++ libltdl/ltdl.h 7 Apr 2007 23:24:36 -0000
  @@ -42,7 +42,6 @@
   /* LT_STRLEN can be used safely on NULL pointers.  */
   #define LT_STRLEN(s) (((s) && (s)[0]) ? strlen (s) : 0)
   
  -

   /* --- DYNAMIC MODULE LOADING API --- */
   
  @@ -67,13 +66,24 @@
   /* Portable libltdl versions of the system dlopen() API. */
   LT_SCOPE lt_dlhandle lt_dlopen               (const char *filename);
   LT_SCOPE lt_dlhandle lt_dlopenext    (const char *filename);
  +LT_SCOPE lt_dlhandle lt_dlopenflags     (const char *filename, int flags);
   LT_SCOPE void *          lt_dlsym            (lt_dlhandle handle, const char 
*name);
   LT_SCOPE const char *lt_dlerror              (void);
   LT_SCOPE int     lt_dlclose          (lt_dlhandle handle);
   
  +/* Values for FLAGS argument of lt_dlopenflags().  */
  +enum {
  +  LT_DLTRYEXT        = (1 << 0),
  +  LT_DLSYMLOCAL              = (1 << 1),
  +  LT_DLSYMGLOBAL     = (1 << 2),
  +  LT_DLRESIDENT              = (1 << 3)
  +};
  +
   /* Module residency management. */
   LT_SCOPE int     lt_dlmakeresident   (lt_dlhandle handle);
   LT_SCOPE int     lt_dlisresident     (lt_dlhandle handle);
  +LT_SCOPE int     lt_dlissymlocal     (lt_dlhandle handle);
  +LT_SCOPE int     lt_dlissymglobal    (lt_dlhandle handle);
   
   
   
  Index: libltdl/libltdl/lt_dlloader.h
  ===================================================================
  RCS file: /sources/libtool/libtool/libltdl/libltdl/lt_dlloader.h,v
  retrieving revision 1.3
  diff -u -u -r1.3 lt_dlloader.h
  --- libltdl/libltdl/lt_dlloader.h 25 Mar 2007 12:12:43 -0000 1.3
  +++ libltdl/libltdl/lt_dlloader.h 7 Apr 2007 23:24:36 -0000
  @@ -41,7 +41,7 @@
   
   /* Function pointer types for module loader vtable entries:  */
   typedef lt_module   lt_module_open   (lt_user_data data,
  -                                      const char *filename);
  +                                      const char *filename, int *flags);
   typedef int      lt_module_close     (lt_user_data data,
                                         lt_module module);
   typedef void *           lt_find_sym         (lt_user_data data, lt_module 
module,
  Index: libltdl/libltdl/lt_error.h
  ===================================================================
  RCS file: /sources/libtool/libtool/libltdl/libltdl/lt_error.h,v
  retrieving revision 1.5
  diff -u -u -r1.5 lt_error.h
  --- libltdl/libltdl/lt_error.h 25 Mar 2007 12:12:43 -0000 1.5
  +++ libltdl/libltdl/lt_error.h 7 Apr 2007 23:24:36 -0000
  @@ -60,7 +60,8 @@
       LT_ERROR(SHUTDOWN,                   "library already shutdown\0")       
\
       LT_ERROR(CLOSE_RESIDENT_MODULE, "can't close resident module\0") \
       LT_ERROR(INVALID_MUTEX_ARGS,    "internal error (code withdrawn)\0")\
  -    LT_ERROR(INVALID_POSITION,           "invalid search path insert 
position\0")
  +    LT_ERROR(INVALID_POSITION,           "invalid search path insert 
position\0")\
  +    LT_ERROR(CONFLICTING_FLAGS,          "symbol visibility can be global or 
local\0")
   
   /* Enumerate the symbolic error names. */
   enum {
  Index: libltdl/loaders/dld_link.c
  ===================================================================
  RCS file: /sources/libtool/libtool/libltdl/loaders/dld_link.c,v
  retrieving revision 1.8
  diff -u -u -r1.8 dld_link.c
  --- libltdl/loaders/dld_link.c 25 Mar 2007 12:12:43 -0000 1.8
  +++ libltdl/loaders/dld_link.c 7 Apr 2007 23:24:36 -0000
  @@ -1,6 +1,7 @@
   /* loader-dld_link.c -- dynamic linking with dld
   
  -   Copyright (C) 1998, 1999, 2000, 2004, 2006 Free Software Foundation, Inc.
  +   Copyright (C) 1998, 1999, 2000, 2004, 2006,
  +                 2007 Free Software Foundation, Inc.
      Written by Thomas Tanner, 1998
   
      NOTE: The canonical source of this file is maintained with the
  @@ -44,7 +45,8 @@
   
   /* Boilerplate code to set up the vtable for hooking this loader into
      libltdl's loader list:  */
  -static lt_module vm_open  (lt_user_data loader_data, const char *filename);
  +static lt_module vm_open  (lt_user_data loader_data, const char *filename,
  +                           int *flags);
   static int    vm_close (lt_user_data loader_data, lt_module module);
   static void *         vm_sym   (lt_user_data loader_data, lt_module module,
                          const char *symbolname);
  @@ -94,7 +96,8 @@
      loader.  Returns an opaque representation of the newly opened
      module for processing with this loader's other vtable functions.  */
   static lt_module
  -vm_open (lt_user_data LT__UNUSED loader_data, const char *filename)
  +vm_open (lt_user_data LT__UNUSED loader_data, const char *filename,
  +         int LT__UNUSED *flags)
   {
     lt_module module = lt__strdup (filename);
   
  Index: libltdl/loaders/dlopen.c
  ===================================================================
  RCS file: /sources/libtool/libtool/libltdl/loaders/dlopen.c,v
  retrieving revision 1.9
  diff -u -u -r1.9 dlopen.c
  --- libltdl/loaders/dlopen.c 25 Mar 2007 12:12:43 -0000 1.9
  +++ libltdl/loaders/dlopen.c 7 Apr 2007 23:24:36 -0000
  @@ -1,6 +1,7 @@
   /* loader-dlopen.c --  dynamic linking with dlopen/dlsym
   
  -   Copyright (C) 1998, 1999, 2000, 2004, 2006 Free Software Foundation, Inc.
  +   Copyright (C) 1998, 1999, 2000, 2004, 2006,
  +                 2007 Free Software Foundation, Inc.
      Written by Thomas Tanner, 1998
   
      NOTE: The canonical source of this file is maintained with the
  @@ -44,7 +45,8 @@
   
   /* Boilerplate code to set up the vtable for hooking this loader into
      libltdl's loader list:  */
  -static lt_module vm_open  (lt_user_data loader_data, const char *filename);
  +static lt_module vm_open  (lt_user_data loader_data, const char *filename,
  +                           int *flags);
   static int    vm_close (lt_user_data loader_data, lt_module module);
   static void *         vm_sym   (lt_user_data loader_data, lt_module module,
                          const char *symbolname);
  @@ -122,6 +124,19 @@
   #  define LT_LAZY_OR_NOW     0
   #endif /* !LT_LAZY_OR_NOW */
   
  +/* We only support local and global symbols from modules for loaders
  +   that provide such a thing, otherwise the system default is used.  */
  +#if !defined(RTLD_GLOBAL)
  +#  if defined(DL_GLOBAL)
  +#    define RTLD_GLOBAL              DL_GLOBAL
  +#  endif
  +#endif /* !RTLD_GLOBAL */
  +#if !defined(RTLD_LOCAL)
  +#  if defined(DL_LOCAL)
  +#    define RTLD_LOCAL               DL_LOCAL
  +#  endif
  +#endif /* !RTLD_LOCAL */
  +
   #if defined(HAVE_DLERROR)
   #  define DLERROR(arg)       dlerror ()
   #else
  @@ -135,9 +150,32 @@
      loader.  Returns an opaque representation of the newly opened
      module for processing with this loader's other vtable functions.  */
   static lt_module
  -vm_open (lt_user_data LT__UNUSED loader_data, const char *filename)
  +vm_open (lt_user_data LT__UNUSED loader_data, const char *filename,
  +         int *flags)
   {
  -  lt_module module = dlopen (filename, LT_LAZY_OR_NOW);
  +  int                module_flags = LT_LAZY_OR_NOW;
  +  lt_module  module;
  +
  +#ifdef RTLD_GLOBAL
  +  /* If there is some means of asking for global symbol resolution,
  +     do so.  */
  +  if (((*flags) & LT_DLSYMGLOBAL) != 0)
  +    module_flags |= RTLD_GLOBAL;
  +#else
  +  /* Otherwise, reset that bit so the caller can tell it wasn't
  +     acted on.  */
  +  *flags &= !LT_DLSYMGLOBAL;
  +#endif
  +
  +/* And similarly for local only symbol resolution.  */
  +#ifdef RTLD_LOCAL
  +  if (((*flags) & LT_DLSYMLOCAL) != 0)
  +    module_flags |= RTLD_LOCAL;
  +#else
  +  *flags &= !LT_DLSYMLOCAL;
  +#endif
  +
  +  module = dlopen (filename, module_flags);
   
     if (!module)
       {
  Index: libltdl/loaders/dyld.c
  ===================================================================
  RCS file: /sources/libtool/libtool/libltdl/loaders/dyld.c,v
  retrieving revision 1.7
  diff -u -u -r1.7 dyld.c
  --- libltdl/loaders/dyld.c 25 Mar 2007 12:12:43 -0000 1.7
  +++ libltdl/loaders/dyld.c 7 Apr 2007 23:24:36 -0000
  @@ -1,6 +1,7 @@
   /* loader-dyld.c -- dynamic linking on darwin and OS X
   
  -   Copyright (C) 1998, 1999, 2000, 2004, 2006 Free Software Foundation, Inc.
  +   Copyright (C) 1998, 1999, 2000, 2004, 2006,
  +                 2007 Free Software Foundation, Inc.
      Written by Peter O'Gorman, 1998
   
      NOTE: The canonical source of this file is maintained with the
  @@ -46,7 +47,8 @@
      libltdl's loader list:  */
   static int    vl_init  (lt_user_data loader_data);
   static int    vl_exit  (lt_user_data loader_data);
  -static lt_module vm_open  (lt_user_data loader_data, const char *filename);
  +static lt_module vm_open  (lt_user_data loader_data, const char *filename,
  +                           int *flags);
   static int    vm_close (lt_user_data loader_data, lt_module module);
   static void *         vm_sym   (lt_user_data loader_data, lt_module module,
                          const char *symbolname);
  @@ -213,7 +215,8 @@
      loader.  Returns an opaque representation of the newly opened
      module for processing with this loader's other vtable functions.  */
   static lt_module
  -vm_open (lt_user_data loader_data, const char *filename)
  +vm_open (lt_user_data loader_data, const char *filename,
  +         int LT__UNUSED *flags)
   {
     lt_module module = 0;
     NSObjectFileImage ofi = 0;
  Index: libltdl/loaders/load_add_on.c
  ===================================================================
  RCS file: /sources/libtool/libtool/libltdl/loaders/load_add_on.c,v
  retrieving revision 1.8
  diff -u -u -r1.8 load_add_on.c
  --- libltdl/loaders/load_add_on.c 25 Mar 2007 12:12:43 -0000 1.8
  +++ libltdl/loaders/load_add_on.c 7 Apr 2007 23:24:36 -0000
  @@ -1,6 +1,7 @@
   /* loader-load_add_on.c --  dynamic linking for BeOS
   
  -   Copyright (C) 1998, 1999, 2000, 2004, 2006 Free Software Foundation, Inc.
  +   Copyright (C) 1998, 1999, 2000, 2004, 2006, 
  +                 2007 Free Software Foundation, Inc.
      Written by Thomas Tanner, 1998
   
      NOTE: The canonical source of this file is maintained with the
  @@ -44,7 +45,8 @@
   
   /* Boilerplate code to set up the vtable for hooking this loader into
      libltdl's loader list:  */
  -static lt_module vm_open  (lt_user_data loader_data, const char *filename);
  +static lt_module vm_open  (lt_user_data loader_data, const char *filename,
  +                           int *flags);
   static int    vm_close (lt_user_data loader_data, lt_module module);
   static void *         vm_sym   (lt_user_data loader_data, lt_module module,
                          const char *symbolname);
  @@ -92,7 +94,8 @@
      loader.  Returns an opaque representation of the newly opened
      module for processing with this loader's other vtable functions.  */
   static lt_module
  -vm_open (lt_user_data LT__UNUSED loader_data, const char *filename)
  +vm_open (lt_user_data LT__UNUSED loader_data, const char *filename,
  +         int LT__UNUSED *flags)
   {
     image_id image = 0;
   
  Index: libltdl/loaders/loadlibrary.c
  ===================================================================
  RCS file: /sources/libtool/libtool/libltdl/loaders/loadlibrary.c,v
  retrieving revision 1.14
  diff -u -u -r1.14 loadlibrary.c
  --- libltdl/loaders/loadlibrary.c 25 Mar 2007 12:12:43 -0000 1.14
  +++ libltdl/loaders/loadlibrary.c 7 Apr 2007 23:24:36 -0000
  @@ -1,7 +1,7 @@
   /* loader-loadlibrary.c --  dynamic linking for Win32
   
  -   Copyright (C) 1998, 1999, 2000, 2004, 2005,
  -                 2006 Free Software Foundation, Inc.
  +   Copyright (C) 1998, 1999, 2000, 2004, 2005, 2006,
  +                 2007 Free Software Foundation, Inc.
      Written by Thomas Tanner, 1998
   
      NOTE: The canonical source of this file is maintained with the
  @@ -49,7 +49,8 @@
   
   /* Boilerplate code to set up the vtable for hooking this loader into
      libltdl's loader list:  */
  -static lt_module vm_open  (lt_user_data loader_data, const char *filename);
  +static lt_module vm_open  (lt_user_data loader_data, const char *filename,
  +                           int *flags);
   static int    vm_close (lt_user_data loader_data, lt_module module);
   static void *         vm_sym   (lt_user_data loader_data, lt_module module,
                          const char *symbolname);
  @@ -100,7 +101,8 @@
      loader.  Returns an opaque representation of the newly opened
      module for processing with this loader's other vtable functions.  */
   static lt_module
  -vm_open (lt_user_data LT__UNUSED loader_data, const char *filename)
  +vm_open (lt_user_data LT__UNUSED loader_data, const char *filename,
  +         int LT__UNUSED *flags)
   {
     lt_module  module     = 0;
     char               *ext;
  Index: libltdl/loaders/preopen.c
  ===================================================================
  RCS file: /sources/libtool/libtool/libltdl/loaders/preopen.c,v
  retrieving revision 1.12
  diff -u -u -r1.12 preopen.c
  --- libltdl/loaders/preopen.c 25 Mar 2007 12:12:43 -0000 1.12
  +++ libltdl/loaders/preopen.c 7 Apr 2007 23:24:36 -0000
  @@ -1,6 +1,7 @@
   /* loader-preopen.c -- emulate dynamic linking using preloaded_symbols
   
  -   Copyright (C) 1998, 1999, 2000, 2004, 2006 Free Software Foundation, Inc.
  +   Copyright (C) 1998, 1999, 2000, 2004, 2006,
  +                 2007 Free Software Foundation, Inc.
      Written by Thomas Tanner, 1998
   
      NOTE: The canonical source of this file is maintained with the
  @@ -46,7 +47,8 @@
      libltdl's loader list:  */
   static int    vl_init  (lt_user_data loader_data);
   static int    vl_exit  (lt_user_data loader_data);
  -static lt_module vm_open  (lt_user_data loader_data, const char *filename);
  +static lt_module vm_open  (lt_user_data loader_data, const char *filename,
  +                           int *flags);
   static int    vm_close (lt_user_data loader_data, lt_module module);
   static void *         vm_sym   (lt_user_data loader_data, lt_module module,
                          const char *symbolname);
  @@ -139,7 +141,8 @@
      loader.  Returns an opaque representation of the newly opened
      module for processing with this loader's other vtable functions.  */
   static lt_module
  -vm_open (lt_user_data LT__UNUSED loader_data, const char *filename)
  +vm_open (lt_user_data LT__UNUSED loader_data, const char *filename,
  +         int LT__UNUSED *flags)
   {
     symlist_chain *lists;
     lt_module   module = 0;
  Index: libltdl/loaders/shl_load.c
  ===================================================================
  RCS file: /sources/libtool/libtool/libltdl/loaders/shl_load.c,v
  retrieving revision 1.9
  diff -u -u -r1.9 shl_load.c
  --- libltdl/loaders/shl_load.c 25 Mar 2007 12:12:43 -0000 1.9
  +++ libltdl/loaders/shl_load.c 7 Apr 2007 23:24:36 -0000
  @@ -1,6 +1,7 @@
   /* loader-shl_load.c --  dynamic linking with shl_load (HP-UX)
   
  -   Copyright (C) 1998, 1999, 2000, 2004, 2006 Free Software Foundation, Inc.
  +   Copyright (C) 1998, 1999, 2000, 2004, 2006,
  +                 2007 Free Software Foundation, Inc.
      Written by Thomas Tanner, 1998
   
      NOTE: The canonical source of this file is maintained with the
  @@ -44,7 +45,8 @@
   
   /* Boilerplate code to set up the vtable for hooking this loader into
      libltdl's loader list:  */
  -static lt_module vm_open  (lt_user_data loader_data, const char *filename);
  +static lt_module vm_open  (lt_user_data loader_data, const char *filename,
  +                           int *flags);
   static int    vm_close (lt_user_data loader_data, lt_module module);
   static void *         vm_sym   (lt_user_data loader_data, lt_module module,
                          const char *symbolname);
  @@ -135,7 +137,8 @@
      loader.  Returns an opaque representation of the newly opened
      module for processing with this loader's other vtable functions.  */
   static lt_module
  -vm_open (lt_user_data LT__UNUSED loader_data, const char *filename)
  +vm_open (lt_user_data LT__UNUSED loader_data, const char *filename,
  +         int LT__UNUSED *flags)
   {
     static shl_t self = (shl_t) 0;
     lt_module module = shl_load (filename, LT_BIND_FLAGS, 0L);
-- 
  ())_.              Email me: address@hidden
  ( '/           Read my blog: http://blog.azazil.net
  / )=         ...and my book: http://sources.redhat.com/autobook
`(_~)_ Join my AGLOCO Network: http://www.agloco.com/r/BBBS7912 
_________________________________________________________
This patch notification generated by vcsapply version 1.0
http://savannah.gnu.org/projects/cvs-utils

Attachment: pgpbVgH9asro2.pgp
Description: PGP signature


reply via email to

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