From cb690d1f0b2725c6a9edfc5f5f3890a610f2927c Mon Sep 17 00:00:00 2001 From: John Polstra Date: Wed, 2 Sep 1998 00:53:17 +0000 Subject: [PATCH] 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 or as they are supposed to do. --- lib/libc/net/Makefile.inc | 4 +- lib/libc/net/inet_addr.c | 11 +++++- lib/libc/net/inet_lnaof.c | 7 ++++ lib/libc/net/inet_makeaddr.c | 7 ++++ lib/libc/net/inet_net_ntop.c | 9 ++++- lib/libc/net/inet_net_pton.c | 9 ++++- lib/libc/net/inet_neta.c | 9 ++++- lib/libc/net/inet_netof.c | 7 ++++ lib/libc/net/inet_network.c | 7 ++++ lib/libc/net/inet_ntoa.c | 7 ++++ lib/libc/net/inet_ntop.c | 9 ++++- lib/libc/net/inet_pton.c | 9 ++++- lib/libc/net/nsap_addr.c | 11 +++++- lib/libc/net/res_comp.c | 11 +++++- lib/libc/net/res_debug.c | 23 ++++++++++- lib/libc/net/res_init.c | 9 ++++- lib/libc/net/res_mkquery.c | 9 ++++- lib/libc/net/res_query.c | 13 ++++++- lib/libc/net/res_send.c | 11 +++++- lib/libc/net/res_stubs.c | 75 ------------------------------------ 20 files changed, 167 insertions(+), 90 deletions(-) delete mode 100644 lib/libc/net/res_stubs.c diff --git a/lib/libc/net/Makefile.inc b/lib/libc/net/Makefile.inc index 18dca25178f0..f21c58ece51c 100644 --- a/lib/libc/net/Makefile.inc +++ b/lib/libc/net/Makefile.inc @@ -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 diff --git a/lib/libc/net/inet_addr.c b/lib/libc/net/inet_addr.c index a1ac89951970..7b027daed3a2 100644 --- a/lib/libc/net/inet_addr.c +++ b/lib/libc/net/inet_addr.c @@ -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 @@ -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 . + */ +#undef inet_addr +__weak_reference(__inet_addr, inet_addr); +#undef inet_aton +__weak_reference(__inet_aton, inet_aton); diff --git a/lib/libc/net/inet_lnaof.c b/lib/libc/net/inet_lnaof.c index 406be300343d..99024d94643b 100644 --- a/lib/libc/net/inet_lnaof.c +++ b/lib/libc/net/inet_lnaof.c @@ -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 . + */ +#undef inet_lnaof +__weak_reference(__inet_lnaof, inet_lnaof); diff --git a/lib/libc/net/inet_makeaddr.c b/lib/libc/net/inet_makeaddr.c index 7976188ea5f1..8af7770a3687 100644 --- a/lib/libc/net/inet_makeaddr.c +++ b/lib/libc/net/inet_makeaddr.c @@ -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 . + */ +#undef inet_makeaddr +__weak_reference(__inet_makeaddr, inet_makeaddr); diff --git a/lib/libc/net/inet_net_ntop.c b/lib/libc/net/inet_net_ntop.c index 4c7893d417ff..d273d4d6195d 100644 --- a/lib/libc/net/inet_net_ntop.c +++ b/lib/libc/net/inet_net_ntop.c @@ -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 @@ -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 . + */ +#undef inet_net_ntop +__weak_reference(__inet_net_ntop, inet_net_ntop); diff --git a/lib/libc/net/inet_net_pton.c b/lib/libc/net/inet_net_pton.c index 6718329b8472..be2d69d32721 100644 --- a/lib/libc/net/inet_net_pton.c +++ b/lib/libc/net/inet_net_pton.c @@ -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 @@ -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 . + */ +#undef inet_net_pton +__weak_reference(__inet_net_pton, inet_net_pton); diff --git a/lib/libc/net/inet_neta.c b/lib/libc/net/inet_neta.c index 2dc76942fd0c..21b2749a9798 100644 --- a/lib/libc/net/inet_neta.c +++ b/lib/libc/net/inet_neta.c @@ -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 @@ -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 . + */ +#undef inet_neta +__weak_reference(__inet_neta, inet_neta); diff --git a/lib/libc/net/inet_netof.c b/lib/libc/net/inet_netof.c index d6de694243d1..37063f713822 100644 --- a/lib/libc/net/inet_netof.c +++ b/lib/libc/net/inet_netof.c @@ -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 . + */ +#undef inet_netof +__weak_reference(__inet_netof, inet_netof); diff --git a/lib/libc/net/inet_network.c b/lib/libc/net/inet_network.c index a62efc7185ca..2f38be2c0d95 100644 --- a/lib/libc/net/inet_network.c +++ b/lib/libc/net/inet_network.c @@ -88,3 +88,10 @@ inet_network(cp) } return (val); } + +/* + * Weak aliases for applications that use certain private entry points, + * and fail to include . + */ +#undef inet_network +__weak_reference(__inet_network, inet_network); diff --git a/lib/libc/net/inet_ntoa.c b/lib/libc/net/inet_ntoa.c index 4fdceeed4873..c2105455615a 100644 --- a/lib/libc/net/inet_ntoa.c +++ b/lib/libc/net/inet_ntoa.c @@ -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 . + */ +#undef inet_ntoa +__weak_reference(__inet_ntoa, inet_ntoa); diff --git a/lib/libc/net/inet_ntop.c b/lib/libc/net/inet_ntop.c index c44a973467f8..9e011c393034 100644 --- a/lib/libc/net/inet_ntop.c +++ b/lib/libc/net/inet_ntop.c @@ -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 @@ -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 . + */ +#undef inet_ntop +__weak_reference(__inet_ntop, inet_ntop); diff --git a/lib/libc/net/inet_pton.c b/lib/libc/net/inet_pton.c index 19f28fb578c4..6c8afd93e04e 100644 --- a/lib/libc/net/inet_pton.c +++ b/lib/libc/net/inet_pton.c @@ -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 @@ -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 . + */ +#undef inet_pton +__weak_reference(__inet_pton, inet_pton); diff --git a/lib/libc/net/nsap_addr.c b/lib/libc/net/nsap_addr.c index 1db7dd775926..714c2c90222e 100644 --- a/lib/libc/net/nsap_addr.c +++ b/lib/libc/net/nsap_addr.c @@ -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 @@ -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 . + */ +#undef inet_nsap_addr +__weak_reference(__inet_nsap_addr, inet_nsap_addr); +#undef inet_nsap_ntoa +__weak_reference(__inet_nsap_ntoa, inet_nsap_ntoa); diff --git a/lib/libc/net/res_comp.c b/lib/libc/net/res_comp.c index de14f072c2f1..a85e36d835ee 100644 --- a/lib/libc/net/res_comp.c +++ b/lib/libc/net/res_comp.c @@ -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 @@ -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 . + */ +#undef dn_comp +__weak_reference(__dn_comp, dn_comp); +#undef dn_expand +__weak_reference(__dn_expand, dn_expand); diff --git a/lib/libc/net/res_debug.c b/lib/libc/net/res_debug.c index d2e94cc03063..2d1d7e0dd19e 100644 --- a/lib/libc/net/res_debug.c +++ b/lib/libc/net/res_debug.c @@ -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 @@ -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 . + */ +#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); diff --git a/lib/libc/net/res_init.c b/lib/libc/net/res_init.c index b9eddaa47ca6..b94e7c1c517d 100644 --- a/lib/libc/net/res_init.c +++ b/lib/libc/net/res_init.c @@ -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 @@ -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 . + */ +#undef res_init +__weak_reference(__res_init, res_init); diff --git a/lib/libc/net/res_mkquery.c b/lib/libc/net/res_mkquery.c index 55c024e59556..a06fc5417707 100644 --- a/lib/libc/net/res_mkquery.c +++ b/lib/libc/net/res_mkquery.c @@ -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 @@ -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 . + */ +#undef res_mkquery +__weak_reference(__res_mkquery, res_mkquery); diff --git a/lib/libc/net/res_query.c b/lib/libc/net/res_query.c index 4de8a0e60fd4..d7d7b28e8dea 100644 --- a/lib/libc/net/res_query.c +++ b/lib/libc/net/res_query.c @@ -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 @@ -408,3 +408,14 @@ hostalias(name) fclose(fp); return (NULL); } + +/* + * Weak aliases for applications that use certain private entry points, + * and fail to include . + */ +#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); diff --git a/lib/libc/net/res_send.c b/lib/libc/net/res_send.c index c06e26a2b80b..13e830fab445 100644 --- a/lib/libc/net/res_send.c +++ b/lib/libc/net/res_send.c @@ -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 . + */ +#undef res_close +__weak_reference(__res_close, _res_close); +#undef res_send +__weak_reference(__res_send, res_send); diff --git a/lib/libc/net/res_stubs.c b/lib/libc/net/res_stubs.c deleted file mode 100644 index 056bc6c9438e..000000000000 --- a/lib/libc/net/res_stubs.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 1996 Peter Wemm . - * 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 -#include - -__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);