oecheruo@silver.ucs.indiana.edu (Chima Oke Echeruo) (07/16/90)
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 -------------------------------------------------------------------------------
jstone@world.std.com (Jeffrey R Stone) (07/16/90)
One reason for the extra size is the static buffer declaration (whether global or not). Most compiler/linkers seem to include each 0-byte in the .EXE, rather that a place holder for 30,000 of them. If you allocate the buffer from heap at run-time, the .EXE overhead should go away (you'll have some extra for the malloc() code, if you were'nt already using it). -jeff-