[net.bugs.v7] ld

borman@decvax.UUCP (Dave borman) (07/02/84)

Subject: V7 ld bug
Newsgroups: net.bugs.2bsd net.bugs.v7

Have you seen the annoying message "local symbol botch" coming from ld?
We recently ran into a program that was consistent in producing this
error, so I was able to track down this instance of it.  Seems the
problem is in ld.c where it declares what an a.out header looks like.
About 100 lines down in ld.c we have:
	struct {
		int	fmagic;
		int	tsize;
		int	dsize;
		int	bsize;
		int	ssize;
		int	entry;
		int	pad;
		int	relflg;
	}
This should be changed to:
	struct {
		int		fmagic;
		unsigned	tsize;
		unsigned	dsize;
		unsigned	bsize;
		unsigned	ssize;
		unsigned	entry;
		unsigned	pad;
		unsigned	relflg;
	}
which is how it is declared in a.out.h.  The problem occures
when an individual module has a text or data size that wraps
around and goes negative.  In load2() we have the line
	dseek(&text, loc + filhdr.tsize + filhdr.dsize, filhdr.ssize);
Well, if filhdr.dsize or filhdr.tsize is negative, it will get sign
extended before being added, dseek then gets the wrong value and
eventually you wind up with the "local symbol botch" message.

This problem is known to exist in V7, 2.9BSD (and probably 2.8BSD).
I have no idea if it is in SYSIII or SYSV, I don't have online sources
to look at.

		-Dave Borman, Digital UNIX Engineering Group
		decvax!borman