Implement the weak aliases for private entry points in the inet_*

and res_* modules in a way that works for ELF.  I moved the aliases
out of res_stubs.c and into the individual modules where the entry
points are defined.  Weak aliases don't work in ELF unless that is
the case.  (Actually, I'm surprised it worked for a.out.)

This should fix the undefined "inet_addr" and related symbols in
various applications that fail to include <arpa/inet.h> or
<resolv.h> as they are supposed to do.
This commit is contained in:
John Polstra 1998-09-02 00:53:17 +00:00
parent 5ca6331a4c
commit cb690d1f0b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=38736
20 changed files with 167 additions and 90 deletions

View File

@ -1,5 +1,5 @@
# from @(#)Makefile.inc 8.2 (Berkeley) 9/5/93
# $Id: Makefile.inc,v 1.26 1998/02/20 08:15:55 jb Exp $
# $Id: Makefile.inc,v 1.27 1998/06/11 09:02:30 peter Exp $
# machine-independent net sources
.PATH: ${.CURDIR}/../libc/${MACHINE_ARCH}/net ${.CURDIR}/../libc/net
@ -15,7 +15,7 @@ SRCS+= addr2ascii.c ascii2addr.c base64.c ether_addr.c \
ns_ntoa.c ns_parse.c ns_print.c ns_ttl.c nsap_addr.c \
rcmd.c recv.c res_comp.c res_data.c res_debug.c \
res_init.c res_mkquery.c res_mkupdate.c res_query.c res_send.c \
res_stubs.c res_update.c send.c
res_update.c send.c
# not supported: iso_addr.c
# machine-dependent net sources

View File

@ -55,7 +55,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93";
static char rcsid[] = "$Id$";
static char rcsid[] = "$Id: inet_addr.c,v 1.5 1997/02/22 15:00:16 peter Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@ -178,3 +178,12 @@ inet_aton(cp, addr)
addr->s_addr = htonl(val);
return (1);
}
/*
* Weak aliases for applications that use certain private entry points,
* and fail to include <arpa/inet.h>.
*/
#undef inet_addr
__weak_reference(__inet_addr, inet_addr);
#undef inet_aton
__weak_reference(__inet_aton, inet_aton);

View File

@ -57,3 +57,10 @@ inet_lnaof(in)
else
return ((i)&IN_CLASSC_HOST);
}
/*
* Weak aliases for applications that use certain private entry points,
* and fail to include <arpa/inet.h>.
*/
#undef inet_lnaof
__weak_reference(__inet_lnaof, inet_lnaof);

View File

@ -60,3 +60,10 @@ inet_makeaddr(net, host)
addr = htonl(addr);
return (*(struct in_addr *)&addr);
}
/*
* Weak aliases for applications that use certain private entry points,
* and fail to include <arpa/inet.h>.
*/
#undef inet_makeaddr
__weak_reference(__inet_makeaddr, inet_makeaddr);

View File

@ -17,7 +17,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char orig_rcsid[] = "From Id: inet_net_ntop.c,v 8.2 1996/08/08 06:54:44 vixie Exp";
static const char rcsid[] = "$Id$";
static const char rcsid[] = "$Id: inet_net_ntop.c,v 1.3 1997/02/22 15:00:16 peter Exp $";
#endif
#include <sys/types.h>
@ -138,3 +138,10 @@ inet_net_ntop_ipv4(src, bits, dst, size)
errno = EMSGSIZE;
return (NULL);
}
/*
* Weak aliases for applications that use certain private entry points,
* and fail to include <arpa/inet.h>.
*/
#undef inet_net_ntop
__weak_reference(__inet_net_ntop, inet_net_ntop);

View File

@ -17,7 +17,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char orig_rcsid[] = "From Id: inet_net_pton.c,v 1.8 1996/11/21 10:28:12 vixie Exp $";
static const char rcsid[] = "$Id: inet_net_pton.c,v 1.3 1997/02/22 15:00:18 peter Exp $";
static const char rcsid[] = "$Id: inet_net_pton.c,v 1.4 1998/06/11 09:02:33 peter Exp $";
#endif
#include <sys/types.h>
@ -205,3 +205,10 @@ inet_net_pton_ipv4(src, dst, size)
errno = EMSGSIZE;
return (-1);
}
/*
* Weak aliases for applications that use certain private entry points,
* and fail to include <arpa/inet.h>.
*/
#undef inet_net_pton
__weak_reference(__inet_net_pton, inet_net_pton);

View File

@ -17,7 +17,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char orig_rcsid[] = "From Id: inet_neta.c,v 8.2 1996/08/08 06:54:44 vixie Exp";
static const char rcsid[] = "$Id: inet_neta.c,v 1.3 1997/02/22 15:00:20 peter Exp $";
static const char rcsid[] = "$Id: inet_neta.c,v 1.4 1998/02/20 08:13:51 jb Exp $";
#endif
#include <sys/types.h>
@ -82,3 +82,10 @@ inet_neta(src, dst, size)
errno = EMSGSIZE;
return (NULL);
}
/*
* Weak aliases for applications that use certain private entry points,
* and fail to include <arpa/inet.h>.
*/
#undef inet_neta
__weak_reference(__inet_neta, inet_neta);

View File

@ -56,3 +56,10 @@ inet_netof(in)
else
return (((i)&IN_CLASSC_NET) >> IN_CLASSC_NSHIFT);
}
/*
* Weak aliases for applications that use certain private entry points,
* and fail to include <arpa/inet.h>.
*/
#undef inet_netof
__weak_reference(__inet_netof, inet_netof);

View File

@ -88,3 +88,10 @@ again:
}
return (val);
}
/*
* Weak aliases for applications that use certain private entry points,
* and fail to include <arpa/inet.h>.
*/
#undef inet_network
__weak_reference(__inet_network, inet_network);

View File

@ -55,3 +55,10 @@ inet_ntoa(in)
(void) inet_ntop(AF_INET, &in, ret, sizeof ret);
return (ret);
}
/*
* Weak aliases for applications that use certain private entry points,
* and fail to include <arpa/inet.h>.
*/
#undef inet_ntoa
__weak_reference(__inet_ntoa, inet_ntoa);

View File

@ -15,7 +15,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char rcsid[] = "$Id: inet_ntop.c,v 1.3 1997/02/22 15:00:21 peter Exp $";
static char rcsid[] = "$Id: inet_ntop.c,v 1.4 1998/06/11 09:02:35 peter Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@ -189,3 +189,10 @@ inet_ntop6(src, dst, size)
strcpy(dst, tmp);
return (dst);
}
/*
* Weak aliases for applications that use certain private entry points,
* and fail to include <arpa/inet.h>.
*/
#undef inet_ntop
__weak_reference(__inet_ntop, inet_ntop);

View File

@ -15,7 +15,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char rcsid[] = "$Id: inet_pton.c,v 1.3 1997/02/22 15:00:22 peter Exp $";
static char rcsid[] = "$Id: inet_pton.c,v 1.4 1998/06/11 09:02:35 peter Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@ -212,3 +212,10 @@ inet_pton6(src, dst)
memcpy(dst, tmp, NS_IN6ADDRSZ);
return (1);
}
/*
* Weak aliases for applications that use certain private entry points,
* and fail to include <arpa/inet.h>.
*/
#undef inet_pton
__weak_reference(__inet_pton, inet_pton);

View File

@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char rcsid[] = "$Id: nsap_addr.c,v 1.4 1997/02/22 15:00:27 peter Exp $";
static char rcsid[] = "$Id: nsap_addr.c,v 1.5 1998/06/11 09:02:45 peter Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@ -103,3 +103,12 @@ inet_nsap_ntoa(binlen, binary, ascii)
*ascii = '\0';
return (start);
}
/*
* Weak aliases for applications that use certain private entry points,
* and fail to include <arpa/inet.h>.
*/
#undef inet_nsap_addr
__weak_reference(__inet_nsap_addr, inet_nsap_addr);
#undef inet_nsap_ntoa
__weak_reference(__inet_nsap_ntoa, inet_nsap_ntoa);

View File

@ -71,7 +71,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)res_comp.c 8.1 (Berkeley) 6/4/93";
static char orig_rcsid[] = "From: Id: res_comp.c,v 8.11 1997/05/21 19:31:04 halley Exp $";
static char rcsid[] = "$Id: res_comp.c,v 1.13 1998/05/02 13:10:56 peter Exp $";
static char rcsid[] = "$Id: res_comp.c,v 1.14 1998/06/11 09:02:46 peter Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@ -256,3 +256,12 @@ void __putshort(u_int16_t src, u_char *dst) { ns_put16(src, dst); }
u_int32_t _getlong(const u_char *src) { return (ns_get32(src)); }
u_int16_t _getshort(const u_char *src) { return (ns_get16(src)); }
#endif /*BIND_4_COMPAT*/
/*
* Weak aliases for applications that use certain private entry points,
* and fail to include <resolv.h>.
*/
#undef dn_comp
__weak_reference(__dn_comp, dn_comp);
#undef dn_expand
__weak_reference(__dn_expand, dn_expand);

View File

@ -95,7 +95,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93";
static char rcsid[] = "$Id: res_debug.c,v 8.20 1998/02/13 01:11:34 halley Exp $";
static char rcsid[] = "$Id: res_debug.c,v 1.15 1998/06/11 09:02:53 peter Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@ -964,3 +964,24 @@ p_secstodate (u_long secs) {
time->tm_hour, time->tm_min, time->tm_sec);
return (output);
}
/*
* Weak aliases for applications that use certain private entry points,
* and fail to include <resolv.h>.
*/
#undef fp_resstat
__weak_reference(__fp_resstat, fp_resstat);
#undef p_query
__weak_reference(__p_query, p_query);
#undef p_fqnname
__weak_reference(__p_fqnname, p_fqnname);
#undef sym_ston
__weak_reference(__sym_ston, sym_ston);
#undef sym_ntos
__weak_reference(__sym_ntos, sym_ntos);
#undef sym_ntop
__weak_reference(__sym_ntop, sym_ntop);
#undef dn_count_labels
__weak_reference(__dn_count_labels, dn_count_labels);
#undef p_secstodate
__weak_reference(__p_secstodate, p_secstodate);

View File

@ -71,7 +71,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
static char orig_rcsid[] = "From: Id: res_init.c,v 8.7 1996/11/18 09:10:04 vixie Exp $";
static char rcsid[] = "$Id: res_init.c,v 1.14 1997/09/01 01:19:20 brian Exp $";
static char rcsid[] = "$Id: res_init.c,v 1.15 1998/06/11 09:02:54 peter Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@ -478,3 +478,10 @@ res_randomid()
gettimeofday(&now, NULL);
return (0xffff & (now.tv_sec ^ now.tv_usec ^ getpid()));
}
/*
* Weak aliases for applications that use certain private entry points,
* and fail to include <resolv.h>.
*/
#undef res_init
__weak_reference(__res_init, res_init);

View File

@ -71,7 +71,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)res_mkquery.c 8.1 (Berkeley) 6/4/93";
static char orig_rcsid[] = "From: Id: res_mkquery.c,v 8.9 1997/04/24 22:22:36 vixie Exp $";
static char rcsid[] = "$Id: res_mkquery.c,v 1.12 1997/02/22 15:00:33 peter Exp $";
static char rcsid[] = "$Id: res_mkquery.c,v 1.13 1998/06/11 09:02:55 peter Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@ -197,3 +197,10 @@ res_mkquery(op, dname, class, type, data, datalen, newrr_in, buf, buflen)
}
return (cp - buf);
}
/*
* Weak aliases for applications that use certain private entry points,
* and fail to include <resolv.h>.
*/
#undef res_mkquery
__weak_reference(__res_mkquery, res_mkquery);

View File

@ -71,7 +71,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93";
static char orig_rcsid = "From: Id: res_query.c,v 8.14 1997/06/09 17:47:05 halley Exp $";
static char rcsid[] = "$Id: res_query.c,v 1.15 1997/09/01 01:19:21 brian Exp $";
static char rcsid[] = "$Id: res_query.c,v 1.16 1998/06/11 09:03:00 peter Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@ -408,3 +408,14 @@ hostalias(name)
fclose(fp);
return (NULL);
}
/*
* Weak aliases for applications that use certain private entry points,
* and fail to include <resolv.h>.
*/
#undef res_query
__weak_reference(__res_query, res_query);
#undef res_search
__weak_reference(__res_search, res_search);
#undef res_querydomain
__weak_reference(__res_querydomain, res_querydomain);

View File

@ -71,7 +71,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93";
static char orig_rcsid[] = "From: Id: res_send.c,v 8.20 1998/04/06 23:27:51 halley Exp $";
static char rcsid[] = "$Id: res_send.c,v 1.23 1998/06/11 09:03:01 peter Exp $";
static char rcsid[] = "$Id: res_send.c,v 1.24 1998/06/14 11:25:46 peter Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@ -898,3 +898,12 @@ res_close()
vc = 0;
}
}
/*
* Weak aliases for applications that use certain private entry points,
* and fail to include <resolv.h>.
*/
#undef res_close
__weak_reference(__res_close, _res_close);
#undef res_send
__weak_reference(__res_send, res_send);

View File

@ -1,75 +0,0 @@
/*
* Copyright (C) 1996 Peter Wemm <peter@freebsd.org>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: res_stubs.c,v 1.6 1997/06/27 08:35:13 peter Exp $
*/
/*
* This file is for FreeBSD-3.0 that has a bind-4.9.5-P1 derived
* resolver in the libc. It provides aliases for functions that
* have moved since 4.9.4-P1.
*
* I'll save everybody the trouble and say it now: *THIS IS A HACK*!
*
* Yes, many of these are private functions to the resolver, but some are
* needed as there is no other way to provide the functionality and they've
* turned up all over the place. :-(
*/
#include <sys/types.h>
#include <sys/cdefs.h>
__weak_reference(__inet_addr, inet_addr);
__weak_reference(__inet_aton, inet_aton);
__weak_reference(__inet_lnaof, inet_lnaof);
__weak_reference(__inet_makeaddr, inet_makeaddr);
__weak_reference(__inet_neta, inet_neta);
__weak_reference(__inet_netof, inet_netof);
__weak_reference(__inet_network, inet_network);
__weak_reference(__inet_net_ntop, inet_net_ntop);
__weak_reference(__inet_net_pton, inet_net_pton);
__weak_reference(__inet_ntoa, inet_ntoa);
__weak_reference(__inet_pton, inet_pton);
__weak_reference(__inet_ntop, inet_ntop);
__weak_reference(__inet_nsap_addr, inet_nsap_addr);
__weak_reference(__inet_nsap_ntoa, inet_nsap_ntoa);
__weak_reference(__sym_ston, sym_ston);
__weak_reference(__sym_ntos, sym_ntos);
__weak_reference(__sym_ntop, sym_ntop);
__weak_reference(__fp_resstat, fp_resstat);
__weak_reference(__p_query, p_query);
__weak_reference(__p_fqnname, p_fqnname);
__weak_reference(__p_secstodate, p_secstodate);
__weak_reference(__dn_count_labels, dn_count_labels);
__weak_reference(__dn_comp, dn_comp);
__weak_reference(__res_close, _res_close);
__weak_reference(__dn_expand, dn_expand);
__weak_reference(__res_init, res_init);
__weak_reference(__res_query, res_query);
__weak_reference(__res_search, res_search);
__weak_reference(__res_querydomain, res_querydomain);
__weak_reference(__res_mkquery, res_mkquery);
__weak_reference(__res_send, res_send);