[unix-pc.bugs] Suddenly a *Large* Binary

gene@zeno.MN.ORG (Gene H. Olson) (10/07/88)

While debugging, I noticed that one of my unix-pc program
binaries was inappropriately *large*.  It contained something
like the following program:

	main()
	{
		int x ;
		x <<= 1000000 ;
		}

This program (prog.c) is 38 bytes long, and its assembly output
file (prog.s) is 259 bytes (Release 3.51).   However its object
file (prog.o) is 250330 bytes.

The reason?  One of the instructions generated by the
compiler was:

	lsl.l	&1000000,%d0

Which looks strange, but not outrageous.  Problem is the
68010 can shift at most 8 bits with an immediate shift count.
The assembler generates as many shift instructions as
necessary to fulfil the count.

There is apparently no sanity check, so in my program the
assembler silently generates 125,000 left shifts by 8.

Of course there is no evidence of this in the (prog.s)
assembly file, and the assember cannot produce a tell-tale
listing.   The evidence must be found with a debugger.

Gene H. Olson
Smartware Consulting
gene@zeno.mn.org
amdahl!bungia!zeno!gene