Shared libraries linker error

Juergen Wagner gandalf at csli.stanford.edu
Wed Feb 8 18:23:29 AEST 1989


[I am sending the reply to the entire list because I think there's been
some confusion about the new select(2) syntax.]

In article <615 at dutrun.UUCP> mcvax!duttnph!hans at uunet.uu.net (Hans Buurman) writes:
>...
>One user on a Sun 3/60 that has recently been upgraded to SunOS 4.0 was
>complaining about a function dumping core that should not have been used
>at all. It turned out that he had a function called select() in his
>program.

Hmm... There is also a system call select(2) in SunOS4.0. This isn't
particularly notable but the syntax has changed from 3.x to 4.x. Unless
done deliberately, one shouldn't use names of system call for one's own
functions.

>One of the SunView routines he called (to initialize a panel) also used a
>function called select(), which is in ndet_select.o in libsunwindow.a.  It
>looks like the compiler had linked the sunwindow calls to select() to his
>own program.

/*
 * Ndet_select.c - Notifier's version of select....

And if you look at the declaration:

extern int
select(nfds, readfds, writefds, exceptfds, timeout)
        register int nfds;
        fd_set *readfds, *writefds, *exceptfds;
        struct timeval *timeout;

What the linker did was correct. It used the libsunwindow.a version of
select because this library was mentioned first on the cc line: something
like

	cc -o foo foo.c -lsunwindow -lpixrect

Even if you used the standard version of select, the core dump should
still be there. Consult your man page for select(2) for the changed
syntax.

-- 
Juergen Wagner		   			gandalf at csli.stanford.edu
						 wagner at arisia.xerox.com

[[ On this topic, I have noticed that the old select kernel call was
retained for backward compatibility.  A program that uses "select" and
that is compiled and linked on a 3.x machine will, under most
circumstances, still work correctly under 4.x (because it's using the old
select kernel call).  But before you can compile it on a 4.x machine, you
*must* make some changes.  Read the new manual page for select(2) to see
how it must be changed.  This backward compatibility move was likely
documented, but I'm too busy (or is that "lazy") to go look it up right
now.  To be more specific:  the new select can handle file descriptor
masks longer than 4 bytes (thus it can handle file descriptors >= 32).
The old one assumed that the mask was 4 bytes.  You can use old
executables provided that you never try to "select" on a fd >= 32.
--wnl ]]



More information about the Comp.sys.sun mailing list