🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.ibm.pc.programmer
Article #978

Abnormal .EXE size with Turbo C 2.0

#978
From: Chima Oke Echeruo
Date: Mon, 16 Jul 1990 01:20
62 lines
3740 bytes
Hi guys and gals, I have a problem with Turvbo C 2.0 . I have an encryption
program that i compiled and linked in the IDE and it comes to about 15 KB of
.EXE code - that is with the IDE debugging switch set.

Later I began playing with some window and comm libraries and being to lazy
to create a .PRJ file for each test application (ie hello world stuff) , I
merged these thirdparty libraries into CS.LIB using TLIB. I then fine-tuned my
program by re-arranging sections of code into functions. Later I began having
problems so I reinstalled the original CS.LIB from the distribution disks and
then proceded to recompile the encryption program. This time the .EXE was over
53 KB! I was stumped! I went through all the compilation and linking options
trying to see i it would help. It did not. 

Out of desperation I recompiled the original code and it remained at 15 KB. 
There was little difference between the two versions yet one was almost 4 times
the size of the other. I then used XTREE to view (HEX) the large file and
discovered lots of 00 bytes in the .EXE file. At the end, there were lots of
lables and variable names. I compiled the program again and set the MAP option
to detailed: I saw that the BSS (uninitialized data??) was over 27KB in length
and was probably the culprit. 

My program creates a buffer like this: char buffer[BUFF_SIZE] - where BUFF_SIZE
was defined as about 30 KB. By reducing it, the size of the .EXE grew smaller.
The problem was that this buffer was defined globally and so I moved it into
another function. I recompiled and the size dropped to 14KB reflecting the fact
that i had cleaned up the code. I did not want the buffer to be created every
time I called the function so I tried: static char buffer[BUFF_SIZE], the
resultant .EXE was as big as ever.

Now, I cannot easily debug my program (small model) because the .EXE is close
to 55 KB and if I compile it without ANY debug info, it drops to 15 KB. Since
I am debugging it now, I can't do without debug info. Several times I have had
to reboot the machine before the code would run.It compiles about 10 times then
I have to reboot before it will compile and be debuggable.

This same program in the early stages of development refused to be debugged by
Turbo 'C'. The debug hilite would be at the wrong line numbers and so I could
neither trace or breakpoint the code. I spent several days on that and I would
not like to consume my time with buggy compilers. Can someone explain the large
.EXE problem which I think is the cause of my problems.

Also, the code is "very" highlevel, no dirty stuff and I use printf, dos 
function calls as well as a windowing library which comes with the source. If
needed, I can post my source code as well.Any pointers?

Thanks.

Chima Echeruo

PS:
	
	char buffer[BUFF_SIZE]  (when global .EXE = 53KB)
	char buffer[BUFF_SIZE]  (when in main() .EXE = 15KB)
	char buffer[BUFF_SIZE]  (when at translate() .EXE = 15KB)
 static char buffer[BUFF_SIZE]	(when at translate() .EXE = 53KB)

	I did not try malloc()
-------------------------------------------------------------------------------
	        	----- Chima Oke Echeruo -----
   oecheruo@silver.ucs.indiana.edu   ++++++   oecheruo@amber.ucs.indiana.edu
-------------------------------------------------------------------------------
Technical Details
Message-ID: <50987@iuvax.cs.indiana.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!tut.cis.ohio-state.edu!cica!iuvax!silver!oecheruo

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!tut.cis.ohio-state.edu!cica!iuvax!silver!oecheruo
From: oecheruo@silver.ucs.indiana.edu (Chima Oke Echeruo)
Newsgroups: comp.sys.ibm.pc.programmer
Subject: Abnormal .EXE size with Turbo C 2.0
Message-ID: <50987@iuvax.cs.indiana.edu>
Date: 16 Jul 90 01:20:13 GMT
Sender: news@iuvax.cs.indiana.edu
Distribution: comp
Lines: 62