dlopen issue with RTLD_LAZY...

tracy@col.hp.com tracy@col.hp.com
Tue Aug 29 09:15:00 GMT 2000


To whom it may concern,


  Thanks for taking the time to look at this issue!  I'm Tracy
  Vandeventer and I am trying to port an application from HPUX to
  Linux (YEA!!).  This application contains over 10 executables and
  ~140 shared libraries with a total of ~1.4 million lines of code.

  My problem is that I have a shared library that has some
  unresolved symbols.  I want to be able to load this library
  and not have it fail because of unresolved symbols. ( at some
  point in the future the symbols will be resolved, but.. I'm not
  done with all the porting...)

  The problem is that the dlopen library call has a parameter flags
  with a possible value being RTLD_LAZY.  When I uses this flag the
  dlopen call still fails with unresolved symbols, when it should
  just load the library and resolve what it can and then return.

  The following code snippet demostrates the problem...
  When you execute the main executable - a message is printed that
  shows the failed dlopen call.  This call should NOT fail...

  These files are located in the shar at the end of this message:

  readme - this file

  main.c - the main program that loads the library and then
		   makes a call into the library - note that the unresolved
		   symbol is not needed for the call...
  lib1.c - the library code with an unresolved symbol
  m      - a quick script that builds the library, the
		   executable, and then executes the program
  lib1.so- the library binary
  main   - the executable binary



  >g++ -v
  Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.2/specs
  gcc version 2.95.2 20000220 (Debian GNU/Linux)

    **** note the specs file is located below....

  >ld --version
  GNU ld 2.9.5
  Copyright 1997 Free Software Foundation, Inc.
  This program is free software; you may redistribute it under the terms
of
  the GNU General Public License.  This program has absolutely no
warranty.
    Supported emulations:
     elf_i386
     i386linux



  Again thanks for all your help ...

  tracy@cos.agilent.com


    ______________________________________________________________________

    Tracy Vandeventer            e-mail:  tracy_vandeventer@agilent.com
    Agilent Technologies         USmail:  1900 Garden of the Gods Road
    R&D Digital Design PGU                PO Box 2197
    Phone : (719) 590-2640                Colorado Springs, CO  80901-2197
    ______________________________________________________________________


  > cat /usr/lib/gcc-lib/i386-linux/2.95.2/specs
  *asm:
  %{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*}

  *asm_final:
  %|

  *cpp:
  %(cpp_cpu) %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__}
%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}

  *cc1:
  %(cc1_cpu) %{profile:-p}

  *cc1plus:


  *endfile:
  %{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s

  *link:
  -m elf_i386 %{shared:-shared}   %{!shared:     %{!ibcs:       %{!static:
%{rdynamic:-export-dynamic} 	%{!dynamic-linker:-dynamic-linker
/lib/ld-linux.so.2}} 	%{static:-static}}}

  *lib:
  %{shared: -lc}    %{!shared: %{mieee-fp:-lieee} %{pthread:-lpthread}
%{profile:-lc_p} %{!profile: -lc}}

  *libgcc:
  -lgcc

  *startfile:
  %{!shared:      %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s}
%{!p:%{profile:gcrt1.o%s} 			 %{!profile:crt1.o%s}}}}    crti.o%s
%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}

  *switches_need_spaces:


  *signed_char:
  %{funsigned-char:-D__CHAR_UNSIGNED__}

  *predefines:
  -D__ELF__ -Dunix -D__i386__ -Dlinux -Asystem(posix)

  *cross_compile:
  0

  *version:
  2.95.2

  *multilib:
  . ;

  *multilib_defaults:


  *multilib_extra:


  *multilib_matches:


  *linker:
  collect2

  *cpp_486:
  %{!ansi:-Di486} -D__i486 -D__i486__

  *cpp_586:
  %{!ansi:-Di586 -Dpentium} 	-D__i586 -D__i586__ -D__pentium -D__pentium__

  *cpp_k6:
  %{!ansi:-Di586 -Dk6} 	-D__i586 -D__i586__ -D__k6 -D__k6__

  *cpp_686:


%{!ansi:-Di686 -Dpentiumpro} 	-D__i686 -D__i686__ -D__pentiumpro -D__penti
umpro__

  *cpp_cpu_default:


  *cpp_cpu:
  -Acpu(i386) -Amachine(i386) %{!ansi:-Di386} -D__i386 -D__i386__
%{mcpu=i486:%(cpp_486)} %{m486:%(cpp_486)} %{mpentium:%(cpp_586)}
%{mcpu=pentium:%(cpp_586)} %{mpentiumpro:%(cpp_686)}
%{mcpu=pentiumpro:%(cpp_686)} %{mcpu=k6:%(cpp_k6)}
%{!mcpu*:%{!m486:%{!mpentium*:%(cpp_cpu_default)}}}

  *cc1_cpu:
  %{!mcpu*: %{m386:-mcpu=i386 -march=i386} %{m486:-mcpu=i486 -march=i486}
%{mpentium:-mcpu=pentium} %{mpentiumpro:-mcpu=pentiumpro}}

  *link_command:
  %{!fsyntax-only:  %{!c:%{!M:%{!MM:%{!E:%{!S:%(linker) %l %X %{o*} %{A}
%{d} %{e*} %{m} %{N} %{n} 			%{r} %{s} %{t} %{u*} %{x} %{z} %{Z}
%{!A:%{!nostdlib:%{!nostartfiles:%S}}}			%{static:} %{L*} %D %o
%{!nostdlib:%{!nodefaultlibs:%G %L %G}}
%{!A:%{!nostdlib:%{!nostartfiles:%E}}}			%{T*}
   }}}}}}


 ******** end of specs file




#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.2.1).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 2000-08-24 09:10 MDT by <tracy@krackle>.
# Source directory was `/home/tracy/test/shl/bug'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#   4854 -rw-r--r-- readme
#    428 -rw-r--r-- main.c
#    194 -rw-r--r-- lib1.c
#    214 -rwxr-xr-x m
#   6159 -rwxr-xr-x lib1.so
#   6027 -rwxr-xr-x main
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
  if test "$gettext_dir" = FAILED && test -f $dir/gettext \
     && ($dir/gettext --version >/dev/null 2>&1)
  then
    set `$dir/gettext --version 2>&1`
    if test "$3" = GNU
    then
      gettext_dir=$dir
    fi
  fi
  if test "$locale_dir" = FAILED && test -f $dir/shar \
     && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
  then
    locale_dir=`$dir/shar --print-text-domain-dir`
  fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
  echo=echo
else
  TEXTDOMAINDIR=$locale_dir
  export TEXTDOMAINDIR
  TEXTDOMAIN=sharutils
  export TEXTDOMAIN
  echo="$gettext_dir/gettext -s"
fi
if touch -am -t 200112312359.59 $$.touch >/dev/null 2>&1 && test ! -f
200112312359.59 -a -f $$.touch; then
  shar_touch='touch -am -t $1$2$3$4$5$6.$7 "$8"'
elif touch -am 123123592001.59 $$.touch >/dev/null 2>&1 && test ! -f
123123592001.59 -a ! -f 123123592001.5 -a -f $$.touch; then
  shar_touch='touch -am $3$4$5$6$1$2.$7 "$8"'
elif touch -am 1231235901 $$.touch >/dev/null 2>&1 && test ! -f
1231235901 -a -f $$.touch; then
  shar_touch='touch -am $3$4$5$6$2 "$8"'
else
  shar_touch=:
  echo
  $echo 'WARNING: not restoring timestamps.  Consider getting and'
  $echo "installing GNU \`touch', distributed in GNU File Utilities..."
  echo
fi
rm -f 200112312359.59 123123592001.59 123123592001.5 1231235901 $$.touch
#
if mkdir _sh01344; then
  $echo 'x -' 'creating lock directory'
else
  $echo 'failed to create lock directory'
  exit 1
fi
# ============= readme ==============
if test -f 'readme' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'readme' '(file already exists)'
else
  $echo 'x -' extracting 'readme' '(binary)'
  sed 's/^X//' << 'SHAR_EOF' | uudecode &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lib1.so
Type: application/x-sharedlib
Size: 6159 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20000829/1687bb95/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.dat
Type: application/x-executable
Size: 6027 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20000829/1687bb95/attachment-0001.bin>
-------------- next part --------------


To whom it may concern,


  Thanks for taking the time to look at this issue!  I'm Tracy
  Vandeventer and I am trying to port an application from HPUX to
  Linux (YEA!!).  This application contains over 10 executables and 
  ~140 shared libraries with a total of ~1.4 million lines of code.

  My problem is that I have a shared library that has some 
  unresolved symbols.  I want to be able to load this library
  and not have it fail because of unresolved symbols. ( at some
  point in the future the symbols will be resolved, but.. I'm not
  done with all the porting...)

  The problem is that the dlopen library call has a parameter flags
  with a possible value being RTLD_LAZY.  When I uses this flag the
  dlopen call still fails with unresolved symbols, when it should 
  just load the library and resolve what it can and then return.

  The following code snippet demostrates the problem...
  When you execute the main executable - a message is printed that
  shows the failed dlopen call.  This call should NOT fail...

  These files are located in the shar at the end of this message:

  readme - this file

  main.c - the main program that loads the library and then
		   makes a call into the library - note that the unresolved
		   symbol is not needed for the call...
  lib1.c - the library code with an unresolved symbol
  m      - a quick script that builds the library, the 
		   executable, and then executes the program
  lib1.so- the library binary
  main   - the executable binary



  >g++ -v
  Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.2/specs
  gcc version 2.95.2 20000220 (Debian GNU/Linux)

    **** note the specs file is located below....

  >ld --version
  GNU ld 2.9.5
  Copyright 1997 Free Software Foundation, Inc.
  This program is free software; you may redistribute it under the terms of
  the GNU General Public License.  This program has absolutely no warranty.
    Supported emulations:
     elf_i386
     i386linux



  Again thanks for all your help ...

  tracy@cos.agilent.com
  

    ______________________________________________________________________

    Tracy Vandeventer            e-mail:  tracy_vandeventer@agilent.com
    Agilent Technologies         USmail:  1900 Garden of the Gods Road
    R&D Digital Design PGU                PO Box 2197
    Phone : (719) 590-2640                Colorado Springs, CO  80901-2197
    ______________________________________________________________________


  > cat /usr/lib/gcc-lib/i386-linux/2.95.2/specs
  *asm:
  %{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*}

  *asm_final:
  %|

  *cpp:
  %(cpp_cpu) %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}
  
  *cc1:
  %(cc1_cpu) %{profile:-p}

  *cc1plus:


  *endfile:
  %{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s

  *link:
  -m elf_i386 %{shared:-shared}   %{!shared:     %{!ibcs:       %{!static: 	%{rdynamic:-export-dynamic} 	%{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} 	%{static:-static}}}
  
  *lib:
  %{shared: -lc}    %{!shared: %{mieee-fp:-lieee} %{pthread:-lpthread} 	%{profile:-lc_p} %{!profile: -lc}}
  
  *libgcc:
  -lgcc

  *startfile:
  %{!shared:      %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} 		       %{!p:%{profile:gcrt1.o%s} 			 %{!profile:crt1.o%s}}}}    crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}
  
  *switches_need_spaces:
  
  
  *signed_char:
  %{funsigned-char:-D__CHAR_UNSIGNED__}
  
  *predefines:
  -D__ELF__ -Dunix -D__i386__ -Dlinux -Asystem(posix)
  
  *cross_compile:
  0
  
  *version:
  2.95.2
  
  *multilib:
  . ;
  
  *multilib_defaults:


  *multilib_extra:


  *multilib_matches:


  *linker:
  collect2

  *cpp_486:
  %{!ansi:-Di486} -D__i486 -D__i486__
  
  *cpp_586:
  %{!ansi:-Di586 -Dpentium} 	-D__i586 -D__i586__ -D__pentium -D__pentium__
  
  *cpp_k6:
  %{!ansi:-Di586 -Dk6} 	-D__i586 -D__i586__ -D__k6 -D__k6__
  
  *cpp_686:
  %{!ansi:-Di686 -Dpentiumpro} 	-D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__
  
  *cpp_cpu_default:
  
  
  *cpp_cpu:
  -Acpu(i386) -Amachine(i386) %{!ansi:-Di386} -D__i386 -D__i386__ %{mcpu=i486:%(cpp_486)} %{m486:%(cpp_486)} %{mpentium:%(cpp_586)} %{mcpu=pentium:%(cpp_586)} %{mpentiumpro:%(cpp_686)} %{mcpu=pentiumpro:%(cpp_686)} %{mcpu=k6:%(cpp_k6)} %{!mcpu*:%{!m486:%{!mpentium*:%(cpp_cpu_default)}}}
  
  *cc1_cpu:
  %{!mcpu*: %{m386:-mcpu=i386 -march=i386} %{m486:-mcpu=i486 -march=i486} %{mpentium:-mcpu=pentium} %{mpentiumpro:-mcpu=pentiumpro}}

  *link_command:
  %{!fsyntax-only:  %{!c:%{!M:%{!MM:%{!E:%{!S:%(linker) %l %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} 			%{r} %{s} %{t} %{u*} %{x} %{z} %{Z}			%{!A:%{!nostdlib:%{!nostartfiles:%S}}}			%{static:} %{L*} %D %o			%{!nostdlib:%{!nodefaultlibs:%G %L %G}}			%{!A:%{!nostdlib:%{!nostartfiles:%E}}}			%{T*}			
   }}}}}}


 ******** end of specs file






More information about the Gcc-bugs mailing list