Subject: lib/7435: Redefining one of inet_aton(), inet_pton() causes linker error
To: None <gnats-bugs@gnats.netbsd.org>
From: Andreas Gustafsson <gson@araneus.fi>
List: netbsd-bugs
Date: 04/21/1999 08:12:00
>Number:         7435
>Category:       lib
>Synopsis:       Redefining one of inet_aton(), inet_pton() causes linker error
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people (Library Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Apr 21 08:05:01 1999
>Last-Modified:
>Originator:     Andreas Gustafsson
>Organization:
Araneus Information Systems Oy
>Release:        1.3.2, 1.3I
>Environment:

System: NetBSD guava.araneus.fi 1.3.2 NetBSD 1.3.2 (GUAVA) #0: Wed Feb 17 10:21:50 EET 1999 gson@guava.araneus.fi:/z/src-1.3/sys/arch/i386/compile/GUAVA i386


>Description:

A program that contains its own implementation of inet_aton() but
calls libc's inet_pton(), or vice versa, will fail to link statically.
This happens because libc defines these two functions in a single
object module.

>How-To-Repeat:

    $ cat aton-override-test.c
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <arpa/inet.h>

    int inet_aton(const char *a, struct in_addr *n) {
	/* implementation irrelevant */
    }

    int main(int argc, char **argv) {
	unsigned char addr6[16];
	inet_pton(AF_INET6, "0::0", addr6);
    }
    $ cc -static aton-override-test.c
    /var/tmp/cc11293a1.o: Definition of symbol `_inet_aton' (multiply defined)
    /usr/lib/libc.a(inet_pton.o): Definition of symbol `_inet_aton' (multiply defined)

>Fix:

Splitting /usr/src/lib/libc/net/inet_pton.c into a separate source file for each 
function will probably help.
>Audit-Trail:
>Unformatted: