Subject: bin/2153: ld.so references wrong object
To: None <gnats-bugs@NetBSD.ORG>
From: None <leo@marco.de>
List: netbsd-bugs
Date: 03/01/1996 15:25:00
>Number:         2153
>Category:       bin
>Synopsis:       ld.so references wrong object
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Mar  1 09:35:01 1996
>Last-Modified:
>Originator:     Matthias Pfaller
>Organization:
leo@dachau.marco.de			in real life: Matthias Pfaller
marco GmbH, 85221 Dachau, Germany	tel: +49 8131 516142
>Release:        960229
>Environment:
	
System: NetBSD tabatha 1.1_ALPHA NetBSD 1.1_ALPHA (ROBIN) #0: Mon Nov 6 16:27:59 MET 1995 leo@robin:/usr/src/sys/arch/i386/compile/ROBIN i386


>Description:
	When one declares a global variable present in a lib, the library
	code seems to reference the wrong object.
>How-To-Repeat:
	Feed the following into your shell:

cat >tst.c <<EOF
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#ifdef DECLARE_EXTERN
extern
#endif
int optind;
main(argc, argv)
	int argc;
	char **argv;
{
	int c;
	while ((c = getopt(argc, argv, "t")) != EOF)
		;
	printf("optind = %d\n", optind);
	exit(0);
}
EOF
cc -o tst.good -DDECLARE_EXTERN tst.c
cc -o tst.bad tst.c
./tst.good -t
./tst.bad -t

You will get different output for tst.good and tst.bad. I think this is
wrong.

>Fix:
	I didn't have the time to look closer at this. So sorry, no fix
	yet.
>Audit-Trail:
>Unformatted: