<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://sourceware.org/bugzilla/bugzilla.dtd">

<bugzilla version="4.0.10"
          urlbase="http://sourceware.org/bugzilla/"
          
          maintainer="overseers@sourceware.org"
>

    <bug>
          <bug_id>1031</bug_id>
          
          <creation_ts>2005-06-22 14:14:00 +0000</creation_ts>
          <short_desc>linker errors on Solaris 10 (symbol versioning?)</short_desc>
          <delta_ts>2005-07-16 15:48:29 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>binutils</product>
          <component>ld</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>1021</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Niki W. Waibel">niki.waibel</reporter>
          <assigned_to>unassigned</assigned_to>
          <cc>bug-binutils</cc>
    
    <cc>ebotcazou</cc>
    
    <cc>funtoos</cc>
          <cf_gcchost>sparc-sun-solaris2.10</cf_gcchost>
          <cf_gcctarget>sparc-sun-solaris2.10</cf_gcctarget>
          <cf_gccbuild>sparc-sun-solaris2.10</cf_gccbuild>
          

      

      

      

          <long_desc isprivate="0">
            <commentid>3915</commentid>
            <who name="Niki W. Waibel">niki.waibel</who>
            <bug_when>2005-06-22 14:14:34 +0000</bug_when>
            <thetext>i get linker errors when compiling openssl on solaris10.
openssl-0.9.7g:
===
gcc -o openssl -DMONOLITH -I.. -I../include -DOPENSSL_SYSNAME_ULTRASPARC -fPIC
-DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H
-DOPENSSL_NO_KRB5 -DDEVRANDOM_EGD=NULL -m32 -mcpu=ultrasparc -O3
-fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W -DMD5_ASM openssl.o verify.o
asn1pars.o req.o dgst.o dh.o dhparam.o enc.o passwd.o gendh.o errstr.o ca.o
pkcs7.o crl2p7.o crl.o rsa.o rsautl.o dsa.o dsaparam.o x509.o genrsa.o gendsa.o
s_server.o s_client.o speed.o s_time.o apps.o s_cb.o s_socket.o app_rand.o
version.o sess_id.o ciphers.o nseq.o pkcs12.o pkcs8.o spkac.o smime.o rand.o
engine.o ocsp.o prime.o -L.. -lssl -L.. -lcrypto
-L/misc/sparc-sun-solaris2.10/lib -lsocket -lnsl -ldl -lz
LD_LIBRARY_PATH=..:
../libcrypto.so: undefined reference to `dlclose@SISCD_2.3&apos;
../libcrypto.so: undefined reference to `dlsym@SISCD_2.3&apos;
../libcrypto.so: undefined reference to `dlopen@SISCD_2.3&apos;
../libcrypto.so: undefined reference to `dlerror@SISCD_2.3&apos;
collect2: ld returned 1 exit status
make[1]: *** [openssl] Error 1
make[1]: Leaving directory `/tmp/openssl-0.9.7g/apps&apos;
===

i&apos;ve already sent a this to a sun solaris 10 forum:
http://forum.sun.com/thread.jsp?forum=271&amp;thread=24107
people there have same trouble with other software (libapr, heartbeat, opensp,
etc) but no solution.

this might be solaris related, but i am sure that you guys know what this is about.

i am using binutils 2.16.90.0.3 and gcc-4.0.0.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>3957</commentid>
            <who name="Sunil">funtoos</who>
            <bug_when>2005-07-01 05:41:09 +0000</bug_when>
            <thetext>libtool seems to add -lc to creating shared libraries.
change:

# Whether or not to add -lc for building shared libraries.
build_libtool_need_lc=yes

to:

# Whether or not to add -lc for building shared libraries.
build_libtool_need_lc=no

and see if this makes any difference.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>3958</commentid>
            <who name="Sunil">funtoos</who>
            <bug_when>2005-07-01 05:44:53 +0000</bug_when>
            <thetext>remember you must recreate libcrypto.so after this.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>3959</commentid>
            <who name="Niki W. Waibel">niki.waibel</who>
            <bug_when>2005-07-01 12:31:09 +0000</bug_when>
            <thetext>hmmm, libtool is *not* used when building openssl.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>3965</commentid>
            <who name="Sunil">funtoos</who>
            <bug_when>2005-07-01 20:56:56 +0000</bug_when>
            <thetext>oops, sorry. a similar problem was resolved with this fix.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>3966</commentid>
            <who name="Sunil">funtoos</who>
            <bug_when>2005-07-01 21:52:10 +0000</bug_when>
            <thetext>I hit this error in openssl with gcc 4 and binutils 2.16.1:

../libcrypto.so: undefined reference to `dlopen@SUNW_0.7&apos;
../libcrypto.so: undefined reference to `dlclose@SUNW_0.7&apos;
../libcrypto.so: undefined reference to `dlsym@SUNW_0.7&apos;
../libcrypto.so: undefined reference to `dlerror@SUNW_0.7&apos;

And the workaround I mentioned about libtool actually works. just remove &apos;-lc
-ldl&apos; from link line of libcrypto.so and other links work fine after that. it
seems that -shared and -lc (or -ldl) are not playing nice together on solaris,
only on 10+ though. solaris 9 has no such problem. Why does linking shared
library require -lc on link line?

also, I should mention that same openssl package compiles fine on solaris 10
with gcc using /usr/ccs/ tools instead of binutils. original gcc 3.4.3 on the
install was built with /usr/ccs/bin/ld.
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>3998</commentid>
            <who name="Niki W. Waibel">niki.waibel</who>
            <bug_when>2005-07-05 14:39:30 +0000</bug_when>
            <thetext>okay. if -lc and -ldl is removed from the openssl makefile then
openssl compiles fine.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>4021</commentid>
            <who name="Sunil">funtoos</who>
            <bug_when>2005-07-09 01:00:48 +0000</bug_when>
            <thetext>please also see bug 1021</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>4057</commentid>
            <who name="Eric Botcazou">ebotcazou</who>
            <bug_when>2005-07-12 19:50:28 +0000</bug_when>
            <thetext>I can reproduce with GCC 4.0.1 and Binutils 2.16.1.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>4058</commentid>
            <who name="Eric Botcazou">ebotcazou</who>
            <bug_when>2005-07-12 20:09:05 +0000</bug_when>
            <thetext>Output of nm on /usr/lib/libdl.so.1:

Solaris 10:

[Index]   Value      Size    Type  Bind  Other Shndx   Name

[34]    |         0|       0|FUNC |GLOB |0    |ABS    |dlclose
[32]    |         0|       0|FUNC |GLOB |0    |ABS    |dldump
[27]    |         0|       0|FUNC |GLOB |0    |ABS    |dlerror
[35]    |         0|       0|FUNC |GLOB |0    |ABS    |dlinfo
[28]    |         0|       0|FUNC |GLOB |0    |ABS    |dlmopen
[18]    |         0|       0|FUNC |GLOB |0    |ABS    |dlopen
[20]    |         0|       0|FUNC |GLOB |0    |ABS    |dlsym

Solaris 7, 8 and 9:

[Index]   Value      Size    Type  Bind  Other Shndx   Name

[40]    |      1828|       8|FUNC |WEAK |0    |7      |dlclose
[38]    |      1860|       8|FUNC |WEAK |0    |7      |dldump
[32]    |      1836|       8|FUNC |WEAK |0    |7      |dlerror
[41]    |      1796|       8|FUNC |WEAK |0    |7      |dlinfo
[33]    |      1804|       8|FUNC |WEAK |0    |7      |dlmopen
[23]    |      1812|       8|FUNC |WEAK |0    |7      |dlopen
[25]    |      1820|       8|FUNC |WEAK |0    |7      |dlsym


Output of nm on /usr/lib/libc.so.1:

Solaris 10:

[6053]  |         0|       0|FUNC |GLOB |0    |ABS    |dlclose
[7698]  |         0|       0|FUNC |GLOB |0    |ABS    |dldump
[8132]  |         0|       0|FUNC |GLOB |0    |ABS    |dlerror
[7686]  |         0|       0|FUNC |GLOB |0    |ABS    |dlinfo
[6797]  |         0|       0|FUNC |GLOB |0    |ABS    |dlmopen
[6142]  |         0|       0|FUNC |GLOB |0    |ABS    |dlopen
[8293]  |         0|       0|FUNC |GLOB |0    |ABS    |dlsym


Solaris 7, 8 and 9:

[empty]


Output of &quot;man dlopen&quot;:

Solaris 10:

NAME
     dlopen, dlmopen - gain access to an executable object file

SYNOPSIS
     #include &lt;dlfcn.h&gt;
     #include &lt;link.h&gt;

     void * dlopen(const char *pathname, int mode);

     void * dlmopen(Lmid_t lmid, const char *pathname, int mode);

Solaris 7, 8 and 9:

NAME
     dlopen, dlmopen - gain access to an executable object file

SYNOPSIS
     cc [ flag... ] file... -ldl [ library... ]
     #include &lt;dlfcn.h&gt;
     #include &lt;link.h&gt;

     void * dlopen(const char *pathname, int mode);

     void * dlmopen(Lmid_t lmid, const char *pathname, int mode)
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>4072</commentid>
            <who name="Eric Botcazou">ebotcazou</who>
            <bug_when>2005-07-14 16:22:49 +0000</bug_when>
            <thetext>What has changed in libdl between Solaris 9 and Solaris 10 is that the stubs for
dlopen, dlclose, etc present on Solaris 9:

poog% /opt/build/eric/local/bin/objdump -T /usr/lib/libdl.so.1

/usr/lib/libdl.so.1:     file format elf32-sparc

DYNAMIC SYMBOL TABLE:
00000714  w   DF .text  00000008  SISCD_2.3   dlopen
0000072c g    DF .text  00000008  SUNWprivate_1.1 _dlerror
0000071c  w   DF .text  00000008  SISCD_2.3   dlsym
000001b8 g    DO .dynamic       00000000  Base        _DYNAMIC
00000744 g    DF .text  00000008  SUNWprivate_1.1 _dldump
0000070c g    DF .text  00000008  SUNWprivate_1.1 _dlmopen
00000000 g    DO *ABS*  00000000  SUNW_1.1    SUNW_1.1
00000704 g    DF .text  00000008  SUNWprivate_1.1 _dlinfo
00000000 g    DO *ABS*  00000000  SUNW_1.2    SUNW_1.2
0000072c  w   DF .text  00000008  SISCD_2.3   dlerror
0000070c  w   DF .text  00000008  SUNW_1.1    dlmopen
00000000 g    DO *ABS*  00000000  SUNW_1.3    SUNW_1.3
00000000 g    DO *ABS*  00000000  SUNW_0.7    SUNW_0.7
00000000 g    DO *ABS*  00000000  SUNW_1.4    SUNW_1.4
00000000 g    DO *ABS*  00000000  SUNW_0.8    SUNW_0.8
00000744  w   DF .text  00000008  SUNW_1.1    dldump
00000734 g    DF .text  00000008  SUNWprivate_1.1 _dladdr
00000724  w   DF .text  00000008  SISCD_2.3   dlclose
00000704  w   DF .text  00000008  SUNW_1.1    dlinfo
00000000 g    DO *ABS*  00000000  SUNWprivate_1.1 SUNWprivate_1.1
0000073c g    DF .text  00000008  SUNWprivate_1.1 _dladdr1
00000000 g    DO *ABS*  00000000  Base        _edata
00000724 g    DF .text  00000008  SUNWprivate_1.1 _dlclose
00000714 g    DF .text  00000008  SUNWprivate_1.1 _dlopen
00000766 g    DO .bss   00000000  Base        _etext
0000074c g    DF .text  00000008  SUNWprivate_1.1 _ld_concurrency
00000754 g    DF .text  00000008  SUNWprivate_1.1 _ld_libc
00000000 g    DO *ABS*  00000000  SISCD_2.3   SISCD_2.3
00000734  w   DF .text  00000008  SUNW_0.8    dladdr
0000076c g    DO .bss   00000000  Base        _end
0000071c g    DF .text  00000008  SUNWprivate_1.1 _dlsym
0000073c  w   DF .text  00000008  SUNW_1.4    dladdr1
00000000 g    DO *ABS*  00000000  Base        _PROCEDURE_LINKAGE_TABLE_

have been turned into mere dummy symbols on Solaris 10:

hikaru% /opt/build/eric/local/bin/objdump -T /usr/lib/libdl.so.1

/usr/lib/libdl.so.1:     file format elf32-sparc

DYNAMIC SYMBOL TABLE:
00000000 g    DF *ABS*  00000000  SISCD_2.3   dlopen
00000000 g    DF *ABS*  00000000  SUNWprivate_1.1 _dlerror
00000000 g    DF *ABS*  00000000  SISCD_2.3   dlsym
00000094 g    DO .dynamic       00000000  Base        _DYNAMIC
00000000 g    DF *ABS*  00000000  SUNWprivate_1.1 _dldump
00000000 g    DF *ABS*  00000000  SUNWprivate_1.1 _dlmopen
00000000 g    DF *ABS*  00000000  SUNWprivate_1.1 _dlinfo
00000000 g    DO *ABS*  00000000  SUNW_1.1    SUNW_1.1
00000000 g    DO *ABS*  00000000  SUNW_1.2    SUNW_1.2
00000000 g    DF *ABS*  00000000  SISCD_2.3   dlerror
00000000 g    DF *ABS*  00000000  SUNW_1.1    dlmopen
00000000 g    DO *ABS*  00000000  SUNW_1.3    SUNW_1.3
00000000 g    DO *ABS*  00000000  SUNW_1.4    SUNW_1.4
00000000 g    DO *ABS*  00000000  SUNW_0.7    SUNW_0.7
00000000 g    DF *ABS*  00000000  SUNW_1.1    dldump
00000000 g    DO *ABS*  00000000  SUNW_0.8    SUNW_0.8
00000000 g    DF *ABS*  00000000  SISCD_2.3   dlclose
00000000 g    DF *ABS*  00000000  SUNW_1.1    dlinfo
00000000 g    DF *ABS*  00000000  SUNWprivate_1.1 _dladdr
00000000 g    DO *ABS*  00000000  SUNWprivate_1.1 SUNWprivate_1.1
00000000 g    DF *ABS*  00000000  SUNWprivate_1.1 _dladdr1
00000000 g    DO *ABS*  00000000  Base        _edata
00000000 g    DF *ABS*  00000000  SUNWprivate_1.1 _dlopen
00000000 g    DF *ABS*  00000000  SUNWprivate_1.1 _dlclose
000006c3 g    DO .bss   00000000  Base        _etext
00000000 g    DF *ABS*  00000000  SUNWprivate_1.1 _ld_concurrency
00000000 g    DF *ABS*  00000000  SUNWprivate_1.1 _ld_libc
00000000 g    DO *ABS*  00000000  SISCD_2.3   SISCD_2.3
000006c3 g    DO .bss   00000000  Base        _end
00000000 g    DF *ABS*  00000000  SUNW_0.8    dladdr
00000000 g    DF *ABS*  00000000  SUNWprivate_1.1 _dlsym
00000000 g    DF *ABS*  00000000  SUNW_1.4    dladdr1
00000000 g    DO *ABS*  00000000  Base        _PROCEDURE_LINKAGE_TABLE_


The key here is the section of the symbols: it is .text on Solaris 9 and the
absolute section on Solaris 10.  This runs afoul of the following FIXME in
elf_link_add_object_symbols:

	  /* If this is a hidden symbol, or if it is not version
	     1, we append the version name to the symbol name.
	     However, we do not modify a non-hidden absolute
	     symbol, because it might be the version symbol
	     itself.  FIXME: What if it isn&apos;t?  */
	  if ((iver.vs_vers &amp; VERSYM_HIDDEN) != 0
	      || (vernum &gt; 1 &amp;&amp; ! bfd_is_abs_section (sec)))


The following patch lets me build OpenSSL on SPARC/Solaris 10:

Index: elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.136.2.3
diff -u -p -r1.136.2.3 elflink.c
--- elflink.c   27 Apr 2005 16:47:24 -0000      1.136.2.3
+++ elflink.c   14 Jul 2005 16:21:05 -0000
@@ -3683,11 +3683,12 @@ elf_link_add_object_symbols (bfd *abfd,

          /* If this is a hidden symbol, or if it is not version
             1, we append the version name to the symbol name.
-            However, we do not modify a non-hidden absolute
-            symbol, because it might be the version symbol
-            itself.  FIXME: What if it isn&apos;t?  */
+            However, we do not modify a non-hidden absolute symbol
+            if it is not a function, because it might be the version
+            symbol itself.  FIXME: What if it isn&apos;t?  */
          if ((iver.vs_vers &amp; VERSYM_HIDDEN) != 0
-             || (vernum &gt; 1 &amp;&amp; ! bfd_is_abs_section (sec)))
+             || (vernum &gt; 1 &amp;&amp; (! bfd_is_abs_section (sec)
+                                || ELF_ST_TYPE (isym-&gt;st_info) == STT_FUNC)))
            {
              const char *verstr;
              size_t namelen, verlen, newlen;</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>4077</commentid>
            <who name="Eric Botcazou">ebotcazou</who>
            <bug_when>2005-07-15 10:02:14 +0000</bug_when>
            <thetext>&gt; The following patch lets me build OpenSSL on SPARC/Solaris 10:

And libjava from GCC 4.0.x, both 32-bit and 64-bit, testsuite results are OK.
I&apos;m going to submit it and try to have it installed on the 2.16 branch too.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>4078</commentid>
            <who name="Niki W. Waibel">niki.waibel</who>
            <bug_when>2005-07-15 11:49:33 +0000</bug_when>
            <thetext>i&apos;d like to prove that Eric Botcazou patch on binutils-2.16.91.0.1 on solaris10
(5.10 Generic_118822-02) works very well. i can compile openssl using gcc-4.0.1
and the mentioned gnu binutils!!!

eric, thank you!!!</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <commentid>4085</commentid>
            <who name="Eric Botcazou">ebotcazou</who>
            <bug_when>2005-07-16 15:48:29 +0000</bug_when>
            <thetext>http://sourceware.org/ml/binutils-cvs/2005-07/msg00121.html
http://sourceware.org/ml/binutils-cvs/2005-07/msg00122.html
</thetext>
          </long_desc>
      
      

    </bug>

</bugzilla>