Unusually large data segments in executables.

The Red Fox ben@proximity.com.au
Mon Jan 12 22:13:00 GMT 1998


Hi,

I've just been trying out the egcs compiler and comparing it with gcc and
have noticed what is possibly a bug (in the linker or compiler).

I am running egcs 1.01  i586-pc-linux-gnulibc1 running Linux 2.0.32 on a
RedHat 4.2 system.

I have a C++ program called xe and when I compile xe with g++ (2.7.2.3)
and link with ld from the binutils package the result of 'size xe' is:

text    data    bss     dec     hex     filename
104292  2208    2152    108652  1a86c   xe

When I compile and link the program using egcs the output of 'size xe' is
now:

text    data    bss     dec     hex     filename
104067  75256   3232    182555  2c91b   xe

The data segment is now 73048 bytes larger than it was when compiled with
gcc! and as a result the executable is that much bigger. Also, the dec
segment is 73903 bytes larger.

I don't know whether this is a bug nor not in the compiler or linker, or
whether it is a necessary result of using egcs. Could someone shed some
light on this?

I did a few more comparisons:

A simple C++ hello world program:

#include <iostream.h>

main()
{
    cout << "Hello World!" << endl;
}

Output of 'size':

g++ (2.7.2.3)
text    data    bss     dec     hex     filename
1498    332     76      1906    772     a.out

egcs 1.01
text    data    bss     dec     hex     filename
1303    220     52      1575    627     a.out

-----
A simple C hello world program:

#include <stdio.h>

main()
{
    printf("Hello World!\n");
}

Output of 'size':

g++ (2.7.2.3)
text    data    bss     dec     hex     filename
1048    188     4       1240    4d8     a.out

egcs 1.01
text    data    bss     dec     hex     filename
4010    1688    32      5730    1662    a.out

In general it seems that gcc 2.7.2.3 creates smaller data segments, but in
particular, when the program is in C the difference in the sizes of the
data segments is much larger than for the C++ programs.

Thanks,
Ben

+---------------------------------------------------------+
|\\ + //   Ben Ross                                \\ ^ //|
| \- -/    ben@proximity.com.au                     \` '/ |
|  \|/     http://www.proximity.com.au/~ben/         \~/  |
+---+-------------------------------------------------+---+




More information about the Gcc mailing list