Ignore:
Timestamp:
Jul 13, 2017, 9:01:05 AM (22 months ago)
Author:
Juanma
Message:

Initial release

File:
1 edited

Legend:

Unmodified
Added
Removed
  • squid-ssl/trunk/fuentes/libltdl/loaders/dlopen.c

    r5495 r5496  
    11/* loader-dlopen.c --  dynamic linking with dlopen/dlsym
    22
    3    Copyright (C) 1998-2000, 2004, 2006-2008, 2011-2015 Free Software
    4    Foundation, Inc.
     3   Copyright (C) 1998, 1999, 2000, 2004, 2006,
     4                 2007, 2008 Free Software Foundation, Inc.
    55   Written by Thomas Tanner, 1998
    66
     
    6969    {
    7070      vtable->name              = "lt_dlopen";
    71 #if defined DLSYM_USCORE
     71#if defined(DLSYM_USCORE)
    7272      vtable->sym_prefix        = "_";
    7373#endif
     
    9494
    9595
    96 #if defined HAVE_DLFCN_H
     96#if defined(HAVE_DLFCN_H)
    9797#  include <dlfcn.h>
    9898#endif
    9999
    100 #if defined HAVE_SYS_DL_H
     100#if defined(HAVE_SYS_DL_H)
    101101#  include <sys/dl.h>
    102102#endif
     
    105105/* We may have to define LT_LAZY_OR_NOW in the command line if we
    106106   find out it does not work in some platform. */
    107 #if !defined LT_LAZY_OR_NOW
    108 #  if defined RTLD_LAZY
     107#if !defined(LT_LAZY_OR_NOW)
     108#  if defined(RTLD_LAZY)
    109109#    define LT_LAZY_OR_NOW      RTLD_LAZY
    110110#  else
    111 #    if defined DL_LAZY
     111#    if defined(DL_LAZY)
    112112#      define LT_LAZY_OR_NOW    DL_LAZY
    113113#    endif
    114114#  endif /* !RTLD_LAZY */
    115115#endif
    116 #if !defined LT_LAZY_OR_NOW
    117 #  if defined RTLD_NOW
     116#if !defined(LT_LAZY_OR_NOW)
     117#  if defined(RTLD_NOW)
    118118#    define LT_LAZY_OR_NOW      RTLD_NOW
    119119#  else
    120 #    if defined DL_NOW
     120#    if defined(DL_NOW)
    121121#      define LT_LAZY_OR_NOW    DL_NOW
    122122#    endif
    123123#  endif /* !RTLD_NOW */
    124124#endif
    125 #if !defined LT_LAZY_OR_NOW
     125#if !defined(LT_LAZY_OR_NOW)
    126126#  define LT_LAZY_OR_NOW        0
    127127#endif /* !LT_LAZY_OR_NOW */
     
    129129/* We only support local and global symbols from modules for loaders
    130130   that provide such a thing, otherwise the system default is used.  */
    131 #if !defined RTLD_GLOBAL
    132 #  if defined DL_GLOBAL
     131#if !defined(RTLD_GLOBAL)
     132#  if defined(DL_GLOBAL)
    133133#    define RTLD_GLOBAL         DL_GLOBAL
    134134#  endif
    135135#endif /* !RTLD_GLOBAL */
    136 #if !defined RTLD_LOCAL
    137 #  if defined DL_LOCAL
     136#if !defined(RTLD_LOCAL)
     137#  if defined(DL_LOCAL)
    138138#    define RTLD_LOCAL          DL_LOCAL
    139139#  endif
    140140#endif /* !RTLD_LOCAL */
    141141
    142 #if defined HAVE_DLERROR
     142#if defined(HAVE_DLERROR)
    143143#  define DLERROR(arg)  dlerror ()
    144144#else
     
    153153   longer needed by the application.  */
    154154static int
    155 vl_exit (lt_user_data loader_data LT__UNUSED)
     155vl_exit (lt_user_data LT__UNUSED loader_data)
    156156{
    157157  vtable = NULL;
     
    164164   module for processing with this loader's other vtable functions.  */
    165165static lt_module
    166 vm_open (lt_user_data loader_data LT__UNUSED, const char *filename,
     166vm_open (lt_user_data LT__UNUSED loader_data, const char *filename,
    167167         lt_dladvise advise)
    168168{
    169169  int           module_flags = LT_LAZY_OR_NOW;
    170170  lt_module     module;
    171 #ifdef RTLD_MEMBER
    172   int           len = LT_STRLEN (filename);
    173 #endif
    174171
    175172  if (advise)
     
    195192    }
    196193
    197 #ifdef RTLD_MEMBER /* AIX */
    198   if (len >= 4) /* at least "l(m)" */
    199     {
    200       /* Advise loading an archive member only if the filename really
    201          contains both the opening and closing parent, and a member. */
    202       if (filename[len-1] == ')')
    203         {
    204           const char *opening = strrchr(filename, '(');
    205           if (opening && opening < (filename+len-2) && strchr(opening+1, '/') == NULL)
    206             module_flags |= RTLD_MEMBER;
    207         }
    208     }
    209 #endif
    210 
    211194  module = dlopen (filename, module_flags);
    212 
    213 #if defined RTLD_MEMBER && defined LT_SHARED_LIB_MEMBER
    214   if (!module && len && !(module_flags & RTLD_MEMBER) && errno == ENOEXEC)
    215     {
    216       /* Loading without a member specified failed with "Exec format error".
    217          So the file is there, but either has wrong bitwidth, or is an
    218          archive eventually containing the default shared archive member.
    219          Retry with default member, getting same error in worst case. */
    220       const char *member = LT_SHARED_LIB_MEMBER;
    221 
    222       char *attempt = MALLOC (char, len + strlen (member) + 1);
    223       if (!attempt)
    224         {
    225           LT__SETERROR (NO_MEMORY);
    226           return module;
    227         }
    228 
    229       sprintf (attempt, "%s%s", filename, member);
    230       module = vm_open (loader_data, attempt, advise);
    231       FREE (attempt);
    232       return module;
    233     }
    234 #endif
    235195
    236196  if (!module)
     
    246206   should be unloaded.  */
    247207static int
    248 vm_close (lt_user_data loader_data LT__UNUSED, lt_module module)
     208vm_close (lt_user_data LT__UNUSED loader_data, lt_module module)
    249209{
    250210  int errors = 0;
     
    263223   a symbol loaded from a particular module.  */
    264224static void *
    265 vm_sym (lt_user_data loader_data LT__UNUSED, lt_module module, const char *name)
     225vm_sym (lt_user_data LT__UNUSED loader_data, lt_module module, const char *name)
    266226{
    267227  void *address = dlsym (module, name);
Note: See TracChangeset for help on using the changeset viewer.