Bug 4715 - gld fails to link Solaris 10/x86 libnsl.so
Summary: gld fails to link Solaris 10/x86 libnsl.so
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.18
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-29 18:50 UTC by Rainer Orth
Modified: 2007-09-26 02:53 UTC (History)
1 user (show)

See Also:
Host: i386-pc-solaris2.10
Target: i386-pc-solaris2.10
Build: i386-pc-solaris2.10
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rainer Orth 2007-06-29 18:50:18 UTC
Consider the following trivial test program:

int
main (void)
{
  gethostbyname();
}

Compiling and linking it with gcc 4.3.0 20070618 configured with gas and gld 2.17
fails:

 ./collect2 -V -m elf_i386 -Y P,/usr/ccs/lib:/usr/lib -Qy -o ghn /usr/lib/crt1.o
/usr/lib/crti.o /usr/lib/values-Xa.o ./crtbegin.o -L. /var/tmp//ccQzeTUf.o -lnsl
-lgcc -lgcc_eh -lc -lgcc -lgcc_eh ./crtend.o /usr/lib/crtn.o
GNU ld version 2.17
  Supported emulations:
   elf_i386_ldso
   elf_i386
   elf_x86_64
/vol/gcc/lib/gld-2.17: warning: libmp.so.2, needed by /usr/lib/libnsl.so, not
found (try using -rpath or -rpath-link)
/vol/gcc/lib/gld-2.17: warning: libmd5.so.1, needed by /usr/lib/libnsl.so, not
found (try using -rpath or -rpath-link)
/vol/gcc/lib/gld-2.17: warning: libscf.so.1, needed by /usr/lib/libnsl.so, not
found (try using -rpath or -rpath-link)
/usr/lib/libnsl.so: undefined reference to `scf_simple_prop_get'
/usr/lib/libnsl.so: undefined reference to `smf_enable_instance'
/usr/lib/libnsl.so: undefined reference to `mp_madd'
/usr/lib/libnsl.so: undefined reference to `mp_sdiv'
/usr/lib/libnsl.so: undefined reference to `scf_simple_prop_free'
/usr/lib/libnsl.so: undefined reference to `MD5Final'
/usr/lib/libnsl.so: undefined reference to `mp_mtox'
/usr/lib/libnsl.so: undefined reference to `mp_mfree'
/usr/lib/libnsl.so: undefined reference to `MD5Init'
/usr/lib/libnsl.so: undefined reference to `mp_itom'
/usr/lib/libnsl.so: undefined reference to `smf_get_state'
/usr/lib/libnsl.so: undefined reference to `MD5Update'
/usr/lib/libnsl.so: undefined reference to `mp_mult'
/usr/lib/libnsl.so: undefined reference to `mp_pow'
/usr/lib/libnsl.so: undefined reference to `scf_simple_prop_next_boolean'
/usr/lib/libnsl.so: undefined reference to `_mp_move'
/usr/lib/libnsl.so: undefined reference to `mp_xtom'
/usr/lib/libnsl.so: undefined reference to `mp_mdiv'
collect2: ld returned 1 exit status

Adding -rpath-link /lib works around this, but given that /lib is a standard
SEARCH_DIR, this seems wrong.  I found that adding -m elf_i386_ldso works, too.
Even GCC 4.3.0 still passes -m elf_i386 by default, so the fact that only
the elf_i386_ldso emulation supports SEARCH_DIRS other than $prefix/...
seems a bug.
Comment 1 Rainer Orth 2007-06-29 19:04:23 UTC
It turns out that gld 2.17.50 (the current CVS version) seems to work.  I'm
currently running a GCC bootstrap with it.
Comment 2 H.J. Lu 2007-08-08 13:39:57 UTC
Does 2.17.50 work on Solaris?
Comment 3 Rainer Orth 2007-09-03 13:13:13 UTC
Subject: Re:  gld fails to link Solaris 10/x86 libnsl.so

hjl at lucon dot org writes:

> Does 2.17.50 work on Solaris?

Yes, it did (don't recall the exact version used).  Sorry for not updating
the PR.

	Rainer
Comment 4 H.J. Lu 2007-09-26 02:53:20 UTC
2.18 should work.