[13845] in Athena Bugs
Re: cygnus 94q2
daemon@ATHENA.MIT.EDU (Theodore Ts'o)
Tue Sep 12 22:09:20 1995
Date: Tue, 12 Sep 1995 22:09:01 -0400
From: Theodore Ts'o <tytso@MIT.EDU>
To: Jonathon Weiss <jweiss@MIT.EDU>
Cc: reidmp@MIT.EDU, f_l@MIT.EDU, bugs@MIT.EDU
In-Reply-To: Jonathon Weiss's message of Tue, 12 Sep 1995 21:16:54 EDT,
<199509130116.VAA12905@the-other-woman.MIT.EDU>
From: Jonathon Weiss <jweiss@MIT.EDU>
Date: Tue, 12 Sep 1995 21:16:54 EDT
It appears that there is a bug in the 95q3 cygnus release, so for now,
please do not delete the 94q2 version. I believe Ted is planning on
sending a bug report, but the explantion is rather, uh, involved. The
short version is that the linker does not always find the correct
version of libraries.
The bug is present in both the 95q3 and 95q2 versions, but isn't present
in the 94q2 version.
The specific form of the lossage is that if you specify command line
such as:
gcc -O -o resolve resolve.c -L/usr/athena/lib -lresolv -lnsl -lsocket
... you get the incorrect version of the resolv library; instead of
getting the one in /usr/athena/lib directory, you get the one in
/usr/lib. This is wrong, since the directories specified using the -L
option should take precedence over the directories in the default
library search path. The 94q2 version does not have this problem.
A shar file which demonstrates this file follows at the end of this
message. Unpack the file in /tmp on an Athena workstation, and then run
"sh test_script". A sample output of the test script can be found in
test_script.output.
-------------------------------------------------------
The above should suffice as a functional description of the bug. For
people wishing to debug the problem, here's a further, more technical
explanation of what the first order cause of the problem seems to be:
Jonathon and I traced the problem down further, and it appears the cause
is that when gcc is executing the linker (which you can see if you pass
the -v option to gcc), it is passing the "-Y P,/usr/ccs/lib:/usr/lib"
option to the linker. This option is undocumented in the GNU
documentation, but if you look at the SunSoft ld documentation, this
option is documented as setting the default library search path to
/usr/ccs/lib:/usr/lib.
As it turns out, this option is also passed to the linker, but in 94q2,
the linker which is used is /usr/ccs/bin/ld, *not* the GNU ld. The
SunSoft ld is accepting this option properly, and merely setting the
default library search path. In contrast, the GNU ld (which is used in
the 95q2 and 95q3 versions) is taking the directories passed to it using
the "-Y P," option, and putting them at the beginning of the library
search path. This is broken.
It is possible to prove this is the problem; if you run:
gcc -v -o resolve resolve.o -L/usr/athena/lib -lresolv -lnsl -lsocket
GCC wil tell you that it is actually running:
/mit/cygnus-95q3/sun4/lib/gcc-lib/sparc-sun-solaris2/2.6-95q3/../../../../sparc-sun-solaris2/bin/ld -V -R /usr/athena/lib -Y P,/usr/ccs/lib:/usr/lib -Qy -o resolve /mit/cygnus-95q3/sun4/lib/gcc-lib/sparc-sun-solaris2/2.6-95q3/crt1.o /mit/cygnus-95q3/sun4/lib/gcc-lib/sparc-sun-solaris2/2.6-95q3/crti.o /usr/ccs/lib/values-Xa.o /mit/cygnus-95q3/sun4/lib/gcc-lib/sparc-sun-solaris2/2.6-95q3/crtbegin.o -L/usr/athena/lib -L/mit/cygnus-95q3/sun4/lib/gcc-lib/sparc-sun-solaris2/2.6-95q3 -L/mit/cygnus-95q3/sun4/lib/gcc-lib -L/mit/cygnus-95q3/sun4/lib -L/mit/cygnus-95q3/sun4/lib/gcc-lib/sparc-sun-solaris2/2.6-95q3/../../../../sparc-sun-solaris2/lib -L/usr/ccs/bin -L/usr/ccs/lib -L/mit/cygnus-95q3/sun4/lib/gcc-lib/../../.. resolve.o -lresolv -lnsl -lsocket -lgcc -lc -lgcc /mit/cygnus-95q3/sun4/lib/gcc-lib/sparc-sun-solaris2/2.6-95q3/crtend.o /mit/cygnus-95q3/sun4/lib/gcc-lib/sparc-sun-solaris2/2.6-95q3/crtn.o
If you remove "-Y P,/usr/ccs/lib:/usr/lib" from the above line, the
linker will find the correct version of the library:
<tytso@dcl> {/tmp}, Level 2
38% /mit/cygnus-95q3/sun4/lib/gcc-lib/sparc-sun-solaris2/2.6-95q3/../../../../sparc-sun-solaris2/bin/ld -V -R /usr/athena/lib -Qy -o resolve /mit/cygnus-95q3/sun4/lib/gcc-lib/sparc-sun-solaris2/2.6-95q3/crt1.o /mit/cygnus-95q3/sun4/lib/gcc-lib/sparc-sun-solaris2/2.6-95q3/crti.o /usr/ccs/lib/values-Xa.o /mit/cygnus-95q3/sun4/lib/gcc-lib/sparc-sun-solaris2/2.6-95q3/crtbegin.o -L/usr/athena/lib -L/mit/cygnus-95q3/sun4/lib/gcc-lib/sparc-sun-solaris2/2.6-95q3 -L/mit/cygnus-95q3/sun4/lib/gcc-lib -L/mit/cygnus-95q3/sun4/lib -L/mit/cygnus-95q3/sun4/lib/gcc-lib/sparc-sun-solaris2/2.6-95q3/../../../../sparc-sun-solaris2/lib -L/usr/ccs/bin -L/usr/ccs/lib -L/mit/cygnus-95q3/sun4/lib/gcc-lib/../../.. resolve.o -lresolv -lnsl -lsocket -lgcc -lc -lgcc /mit/cygnus-95q3/sun4/lib/gcc-lib/sparc-sun-solaris2/2.6-95q3/crtend.o /mit/cygnus-95q3/sun4/lib/gcc-lib/sparc-sun-solaris2/2.6-95q3/crtn.o
<tytso@dcl> {/tmp}, Level 2
39% ./resolve
Hostname: dcl
Host address: 18.172.1.4
FQDN: DCL.MIT.EDU
Resolve library appears to have passed the test
- Ted
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: test_script test_script.output resolve.c
# Wrapped by tytso@dcl on Tue Sep 12 22:05:13 1995
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'test_script' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'test_script'\"
else
echo shar: Extracting \"'test_script'\" \(992 characters\)
sed "s/^X//" >'test_script' <<'END_OF_FILE'
X#!/bin/sh
X
Xgcc -O -c resolve.c
X
Xecho Using gcc -o resolve resolve.o /usr/lib/libresolv.so -lnsl -lsocket
Xgcc -o resolve resolve.o /usr/lib/libresolv.so -lnsl -lsocket
X./resolve
Xecho " "
Xecho "Note that the Solaris 2.3 resolve library is broken. No surprise here."
Xecho " "
Xecho "----------------------------------------------------------------"
Xecho " "
X
Xecho Using gcc -o resolve resolve.o /usr/athena/lib/libresolv.so -lnsl -lsocket
Xgcc -o resolve resolve.o /usr/athena/lib/libresolv.so -lnsl -lsocket
X./resolve
Xecho " "
Xecho "Note that the Athena version of the resolve library works."
Xecho " "
Xecho "----------------------------------------------------------------"
Xecho " "
X
Xecho Using gcc -o resolve resolve.o -L/usr/athena/lib -lresolv -lnsl -lsocket
Xgcc -o resolve resolve.o -L/usr/athena/lib -lresolv -lnsl -lsocket
X./resolve
Xecho " "
Xecho "Note that we didn't get the Athena version of the resolve library,"
Xecho "even though we specified -L/usr/athena/lib!"
Xecho " "
X
X
X
X
END_OF_FILE
if test 992 -ne `wc -c <'test_script'`; then
echo shar: \"'test_script'\" unpacked with wrong size!
fi
# end of 'test_script'
fi
if test -f 'test_script.output' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'test_script.output'\"
else
echo shar: Extracting \"'test_script.output'\" \(1343 characters\)
sed "s/^X//" >'test_script.output' <<'END_OF_FILE'
XScript started on Tue Sep 12 21:54:32 1995
X<tytso@dcl> {/tmp}, Level 3
X1% sh test_script
XUsing gcc -o resolve resolve.o /usr/lib/libresolv.so -lnsl -lsocket
XHostname: dcl
XHost address: 18.172.1.4
XFQDN: dcl
X
XResolve library did not return a fully qualified domain name
XYou may have to reconfigure the kerberos distribution to select a
Xdifferent set of libraries using --with-netlib[=libs]
X
XNote that the Solaris 2.3 resolve library is broken. No surprise here.
X
X----------------------------------------------------------------
X
XUsing gcc -o resolve resolve.o /usr/athena/lib/libresolv.so -lnsl -lsocket
XHostname: dcl
XHost address: 18.172.1.4
XFQDN: DCL.MIT.EDU
XResolve library appears to have passed the test
X
XNote that the Athena version of the resolve library works.
X
X----------------------------------------------------------------
X
XUsing gcc -o resolve resolve.o -L/usr/athena/lib -lresolv -lnsl -lsocket
XHostname: dcl
XHost address: 18.172.1.4
XFQDN: dcl
X
XResolve library did not return a fully qualified domain name
XYou may have to reconfigure the kerberos distribution to select a
Xdifferent set of libraries using --with-netlib[=libs]
X
XNote that we didn't get the Athena version of the resolve library,
Xeven though we specified -L/usr/athena/lib!
X
X<tytso@dcl> {/tmp}, Level 3
X2%
Xscript done on Tue Sep 12 21:54:45 1995
END_OF_FILE
if test 1343 -ne `wc -c <'test_script.output'`; then
echo shar: \"'test_script.output'\" unpacked with wrong size!
fi
# end of 'test_script.output'
fi
if test -f 'resolve.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'resolve.c'\"
else
echo shar: Extracting \"'resolve.c'\" \(3494 characters\)
sed "s/^X//" >'resolve.c' <<'END_OF_FILE'
X/*
X * test/resolve/resolve.c
X *
X * Copyright 1995 by the Massachusetts Institute of Technology.
X * All Rights Reserved.
X *
X * Export of this software from the United States of America may
X * require a specific license from the United States Government.
X * It is the responsibility of any person or organization contemplating
X * export to obtain such a license before exporting.
X *
X * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
X * distribute this software and its documentation for any purpose and
X * without fee is hereby granted, provided that the above copyright
X * notice appear in all copies and that both that copyright notice and
X * this permission notice appear in supporting documentation, and that
X * the name of M.I.T. not be used in advertising or publicity pertaining
X * to distribution of the software without specific, written prior
X * permission. M.I.T. makes no representations about the suitability of
X * this software for any purpose. It is provided "as is" without express
X * or implied warranty.
X *
X * A simple program to test the functionality of the resolver library.
X * It simply will try to get the IP address of the host, and then look
X * up the name from the address. If the resulting name does not contain the
X * domain name, then the resolve library is broken.
X *
X * Warning: It is possible to fool this program into thinking everything is
X * alright byt a clever use of /etc/hosts - but this is better than nothing.
X *
X * Usage:
X * resolve [hostname]
X *
X * When invoked with no arguments, gethostname is used for the local host.
X *
X */
X
X/* This program tests the resolve library and sees if it is broken... */
X
X#include <stdio.h>
X
X#include <string.h>
X#include <sys/param.h>
X#include <sys/socket.h>
X#include <netdb.h>
X
Xint
Xmain(argc, argv)
X int argc;
X char **argv;
X{
X char myname[MAXHOSTNAMELEN+1];
X char *ptr;
X char addrcopy[4];
X struct hostent *host;
X int quiet = 0;
X int err;
X
X argc--; argv++;
X while (argc) {
X if ((strcmp(*argv, "--quiet") == 0) ||
X (strcmp(*argv, "-q") == 0)) {
X quiet++;
X } else
X break;
X argc--; argv++;
X }
X
X if (argc > 0) {
X strncpy(myname, *argv, MAXHOSTNAMELEN);
X } else {
X if(gethostname(myname, MAXHOSTNAMELEN)) {
X perror("gethostname failure");
X exit(1);
X }
X }
X
X myname[MAXHOSTNAMELEN] = '\0'; /* for safety */
X
X /* Look up the address... */
X if (!quiet)
X printf("Hostname: %s\n", myname);
X
X
X /* Set the hosts db to close each time - effectively rewinding file */
X sethostent(0);
X
X if((host = gethostbyname (myname)) == NULL) {
X fprintf(stderr, "Could not look up hostname - fatal\n");
X exit(2);
X }
X
X ptr = host->h_addr_list[0];
X#define UC(a) (((int)a)&0xff)
X if (!quiet)
X printf("Host address: %d.%d.%d.%d\n",
X UC(ptr[0]), UC(ptr[1]), UC(ptr[2]), UC(ptr[3]));
X
X memcpy(addrcopy, ptr, 4);
X
X /* Convert back to full name */
X if((host = gethostbyaddr(addrcopy, 4, AF_INET)) == NULL) {
X fprintf(stderr, "Error looking up IP address - fatal\n");
X exit(2);
X }
X
X if (quiet)
X printf("%s\n", host->h_name);
X else
X printf("FQDN: %s\n", host->h_name);
X
X if(strchr(host->h_name, '.') == NULL) {
X fprintf(stderr, "\nResolve library did not return a fully qualified domain name\n");
X fprintf(stderr, "You may have to reconfigure the kerberos distribution to select a\ndifferent set of libraries using --with-netlib[=libs]\n");
X exit(3);
X }
X
X if (!quiet)
X printf("Resolve library appears to have passed the test\n");
X
X /* All ok */
X exit(0);
X
X}
X
X
END_OF_FILE
if test 3494 -ne `wc -c <'resolve.c'`; then
echo shar: \"'resolve.c'\" unpacked with wrong size!
fi
# end of 'resolve.c'
fi
echo shar: End of shell archive.
exit 0