Bug 1031 - linker errors on Solaris 10 (symbol versioning?)
Summary: linker errors on Solaris 10 (symbol versioning?)
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks: 1021
  Show dependency treegraph
 
Reported: 2005-06-22 14:14 UTC by Niki W. Waibel
Modified: 2014-05-28 19:43 UTC (History)
3 users (show)

See Also:
Host: sparc-sun-solaris2.10
Target: sparc-sun-solaris2.10
Build: sparc-sun-solaris2.10
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Niki W. Waibel 2005-06-22 14:14:34 UTC
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'
../libcrypto.so: undefined reference to `dlsym@SISCD_2.3'
../libcrypto.so: undefined reference to `dlopen@SISCD_2.3'
../libcrypto.so: undefined reference to `dlerror@SISCD_2.3'
collect2: ld returned 1 exit status
make[1]: *** [openssl] Error 1
make[1]: Leaving directory `/tmp/openssl-0.9.7g/apps'
===

i've already sent a this to a sun solaris 10 forum:
http://forum.sun.com/thread.jsp?forum=271&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.
Comment 1 Sunil 2005-07-01 05:41:09 UTC
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.
Comment 2 Sunil 2005-07-01 05:44:53 UTC
remember you must recreate libcrypto.so after this.
Comment 3 Niki W. Waibel 2005-07-01 12:31:09 UTC
hmmm, libtool is *not* used when building openssl.
Comment 4 Sunil 2005-07-01 20:56:56 UTC
oops, sorry. a similar problem was resolved with this fix.
Comment 5 Sunil 2005-07-01 21:52:10 UTC
I hit this error in openssl with gcc 4 and binutils 2.16.1:

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

And the workaround I mentioned about libtool actually works. just remove '-lc
-ldl' 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.
Comment 6 Niki W. Waibel 2005-07-05 14:39:30 UTC
okay. if -lc and -ldl is removed from the openssl makefile then
openssl compiles fine.
Comment 7 Sunil 2005-07-09 01:00:48 UTC
please also see bug 1021
Comment 8 Eric Botcazou 2005-07-12 19:50:28 UTC
I can reproduce with GCC 4.0.1 and Binutils 2.16.1.
Comment 9 Eric Botcazou 2005-07-12 20:09:05 UTC
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 "man dlopen":

Solaris 10:

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

SYNOPSIS
     #include <dlfcn.h>
     #include <link.h>

     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 <dlfcn.h>
     #include <link.h>

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

     void * dlmopen(Lmid_t lmid, const char *pathname, int mode)
Comment 10 Eric Botcazou 2005-07-14 16:22:49 UTC
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't?  */
	  if ((iver.vs_vers & VERSYM_HIDDEN) != 0
	      || (vernum > 1 && ! 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'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't?  */
          if ((iver.vs_vers & VERSYM_HIDDEN) != 0
-             || (vernum > 1 && ! bfd_is_abs_section (sec)))
+             || (vernum > 1 && (! bfd_is_abs_section (sec)
+                                || ELF_ST_TYPE (isym->st_info) == STT_FUNC)))
            {
              const char *verstr;
              size_t namelen, verlen, newlen;
Comment 11 Eric Botcazou 2005-07-15 10:02:14 UTC
> 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'm going to submit it and try to have it installed on the 2.16 branch too.
Comment 12 Niki W. Waibel 2005-07-15 11:49:33 UTC
i'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!!!
Comment 14 Jackie Rosen 2014-02-16 17:02:02 UTC Comment hidden (spam)