www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/11/23/11:59:44

From: elio AT pvax DOT Ico DOT Olivetti DOT Com
>From: elio AT pvax (Elio Tondo)
Subject: Re: HUGE exe
To: OKRA AT max DOT tiac DOT net (Kimberley Burchett)
Date: Wed, 23 Nov 1994 12:32:23 +0100 (MET)
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu

> > I don't see what I should check again.
> 
>   Size said right there that your exe was 138k.  not 15k.  That's what I 
> wanted you to check again.  

As DJ already wrote, that is the size when running, not the file size.
In any case, you are right: the bug is there. More on that later.

> > A simple suggestion: do a gcc -S of your file, and email both the C source
> > and the assembly output to the list; this way we could try to understand
> > what happens on your installation.
> 
>   Okay, here it is.  I erased the original test.cc so I rewrote it.
> 
> -----------SOURCE-----------
>  
> char Map[256][512];
>  
> main() {
> }		// turns out even memset() isn't needed...
>  
> -----------SIZE-----------
> 
> text    data    bss     dec     hex     filename
> 3008    135168  164     138340  21c64   test
> 
> -----------GCC test.cc -S -O2------------
> 
> 	.file	"test.cc"
> gcc2_compiled.:
> ___gnu_compiled_cplusplus:
> .text
> 	.align 2
> .globl _main
> _main:
> 	pushl %ebp
> 	movl %esp,%ebp
> 	call ___main
> 	xorl %eax,%eax
> 	leave
> 	ret
> .globl _Map
> .data
> _Map:
> 	.space 131072
> 

What was not clear from the beginning (or maybe I missed it?) is that you
were comiling a C++ source. I tried a C source, so that the actual compiler
used was different. I did some more tests, and these are the results:

Here is the program source, copied to the files "testc.c" and "testcc.cc":
=========================================================
char Map[256][512];

main() {}
=========================================================

Here is the output of "gcc -O -S testc.c" with DJGPP:
=========================================================
	.file	"testc.c"
gcc2_compiled.:
___gnu_compiled_c:
..text
	.align 2
..globl _main
_main:
	pushl %ebp
	movl %esp,%ebp
	call ___main
	leave
	ret
..comm _Map,131072
=========================================================

Here is the output of "gcc -O -S testcc.cc" with DJGPP:
=========================================================
	.file	"testcc.cc"
gcc2_compiled.:
___gnu_compiled_cplusplus:
..text
	.align 2
..globl _main
_main:
	pushl %ebp
	movl %esp,%ebp
	call ___main
	xorl %eax,%eax
	leave
	ret
..globl _Map
..data
_Map:
	.space 131072
=========================================================

As you can see, while the C compiler uses BSS (.comm directive), the C++
compiler places the array in the initialized data segment.

I tried the same on Linux (gcc 2.5.8 instead of 2.6.0); these are the results.

Here is the output of "gcc -O -S testc.c" on Linux:
=========================================================
	.file	"testc.c"
gcc2_compiled.:
___gnu_compiled_c:
..text
	.align 4
..globl _main
_main:
	pushl %ebp
	movl %esp,%ebp
	call ___main
	movl %ebp,%esp
	popl %ebp
	ret
..comm _Map,131072
=========================================================

Here is the output of "gcc -O -S testcc.cc" on Linux:
=========================================================
	.file	"testcc.cc"
gcc2_compiled.:
___gnu_compiled_cplusplus:
..text
	.align 4
..globl _main
_main:
	pushl %ebp
	movl %esp,%ebp
	call ___main
	xorl %eax,%eax
	movl %ebp,%esp
	popl %ebp
	ret
..comm _Map,131072
=========================================================

As you can see, on Linux the output is correct with both the C and the C++
compiler. I don't have an older DJGCC C++ binary any more to see if the
problem is in the current release, nor I have a Linux C++ 2.6.0 binary to
test with; maybe other folks (or DJ himself?) could try to understand where
the problem is.

   Elio
 _____________________________________________________________________________
|  __           ___                | Olivetti - Viale Gramsci 12 - Pisa, Italy
| |_  | .  _     |  _   _   _|  _  | Tel:  +39-50-516554   Fax:  +39-50-502664
| |__ | | (_)    | (_) | | (_| (_) | elio AT olivetti DOT com | Standard disclaimers.


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019