This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: Huge executable file with gcc version 3.1.1
- From: Douglas Richardson <douglas dot richardson at gaussvip dot com>
- To: "'D.Venkatasubramanian, Noida'" <dvenkat at noida dot hcltech dot com>, Douglas Richardson <douglas dot richardson at gaussvip dot com>, Kazu Hirata <kazu at cs dot umass dot edu>
- Cc: gcc at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org
- Date: Tue, 24 Sep 2002 08:18:34 -0700
- Subject: RE: Huge executable file with gcc version 3.1.1
You're right, it does seem large.
I have gcc configured on a Sun sparc to statically link and I tried out your
test program. After I stripped a.out it was still about 190k. A "Hello,
World" C program was only about 3k after I stripped it.
I also tried compiling the C++ program with different optimizations (-Os,
-O2, -O) but they did not effect the size of a.out.
I then compiled a C++ "Hello, World" program including stdio.h instead of
iostream and using printf instead of cout and the program was about the same
size as the C "Hello, World" program.
I then stripped libstdc++.a and tried to compile your "Hello, World"
program. I got undefined references to some initialization routines (like
std::ios_base::Init::Init()). The Standard Template Library is bringing in a
lot of extra code. That must be why your file is so large.
Even with that explanation, your a.out still seems very large.
Douglas Richardson.
-----Original Message-----
From: D.Venkatasubramanian, Noida [mailto:dvenkat@noida.hcltech.com]
Sent: Tuesday, September 24, 2002 07:31
To: Douglas Richardson; Kazu Hirata
Cc: gcc@gcc.gnu.org; gcc-bugs@gcc.gnu.org
Subject: RE: Huge executable file with gcc version 3.1.1
Hi,
I am using newlib and my target is h8300-elf,
so it always produce a statically linked executable.
The problem is, I stripped the file and still the size is considerable.
If you see the size of the .text section, it is around 253 KB.
There is no --disable-shared also in the -v output.
Isn't this considerable for such a small test case?
Thanks and Regards,
Venky
[venkat@peacock Bugs]$ h8300-elf-g++ -v
Reading specs from
/home/venkat/gcc_release/h8300-elf/tools/bin/../lib/gcc-lib/h8300-elf/3.1.1/
specs
Configured with: /export/niting/WorkArea/gcc-release/src/configure
--prefix=/home/venkat/gcc_release/h8300-elf/tools/ --target=h8300-elf
--with-newlib --enable-languages=c,c++ --with-gnu-ld --with-gnu-as
--with-ld=/home/venkat/gcc_release/h8300-elf/tools/h8300-elf/bin/ld
--with-as=/home/venkat/gcc_release/h8300-elf/tools/h8300-elf/bin/as
--with-headers=/export/niting/WorkArea/gcc-release/src/newlib/libc/include/
Thread model: single
gcc version 3.1.1
[venkat@peacock BugC37]$ readelf -S a.out
There are 15 section headers, starting at offset 0x4189c:
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk
Inf Al
[ 0] NULL 00000000 000000 000000 00 0
0 0
[ 1] .init PROGBITS 00000100 000094 00000a 00 AX 0
0 1
[ 2] .text PROGBITS 0000010c 00009e 03e026 00 AX 0
0 4
[ 3] .fini PROGBITS 0003e132 03e0c4 000006 00 AX 0
0 1
[ 4] .rodata PROGBITS 0003e138 03e0ca 0018b4 00 A 0
0 4
[ 5] .data PROGBITS 0003f9ec 03f97e 001510 00 WA 0
0 4
[ 6] .eh_frame PROGBITS 00040efc 040e8e 000004 00 WA 0
0 4
[ 7] .gcc_except_table PROGBITS 00040f00 040e92 000964 00 WA 0
0 4
[ 8] .ctors PROGBITS 00041864 0417f6 00001c 00 WA 0
0 4
[ 9] .dtors PROGBITS 00041880 041812 000014 00 WA 0
0 4
[10] .jcr PROGBITS 00041894 041826 000004 00 WA 0
0 4
[11] .sbss PROGBITS 00041898 04182a 000000 00 W 0
0 1
[12] .bss NOBITS 00041898 04182a 000ee0 00 WA 0
0 4
[13] .stack PROGBITS 0002fefc 04182a 000004 00 0
0 1
[14] .shstrtab STRTAB 00000000 04182e 00006c 00 0
0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
[venkat@peacock BugC37]$ du -sk -h a.out
268k a.out
[venkat@peacock BugC37]$ file a.out
a.out: ELF 32-bit MSB executable, Hitachi H8/300H, version 1 (SYSV),
statically linked, stripped
-----Original Message-----
From: Douglas Richardson [mailto:douglas.richardson@gaussvip.com]
Sent: Tuesday, September 24, 2002 7:56 PM
To: D.Venkatasubramanian, Noida; Kazu Hirata
Cc: gcc@gcc.gnu.org; gcc-bugs@gcc.gnu.org
Subject: RE: Huge executable file with gcc version 3.1.1
You are probably statically linking with the runtime libraries. Look at the
output of gcc -v. It will tell you how your gcc was configured. Do you see a
--disable-shared anywhere in the output? If so, you are statically linking
with the runtime libraries.
Doug.
-----Original Message-----
From: D.Venkatasubramanian, Noida [mailto:dvenkat@noida.hcltech.com]
Sent: Tuesday, September 24, 2002 06:15
To: Kazu Hirata
Cc: gcc@gcc.gnu.org; gcc-bugs@gcc.gnu.org
Subject: Huge executable file with gcc version 3.1.1
Hi,
I found that even very small test cases like an Hello World Program in C++,
creating huge executable files for h8300-elf architecture.
If you see the output from the shell given below,
you find that for a simple program, the executable was 2.9 MB.
I noticed this happening only when some header file was included.
This causes the simulator to crash, and when I compiled with -g option,
and tried to load it on the debugger, I found the debugger crashing when
I tried to load the executable on the simulator.Seems the debugger crash
must be due to this large size.
I noticed this when I found many test cases failing when I ran make check.
Any help would be appreciated.
Thanks and Regards,
Venky
[venkat@peacock BugC37]$ cat test.C
#include<iostream.h>
int main()
{
std::cout << "Hello World" << endl;
}
[venkat@peacock BugC37]$ h8300-elf-g++ -v
Reading specs from
/home/venkat/gcc_release/h8300-elf/tools/bin/../lib/gcc-lib/h8300-elf/3.1.1/
specs
Configured with: /export/niting/WorkArea/gcc-release/src/configure
--prefix=/home/venkat/gcc_release/h8300-elf/tools/ --target=h8300-elf
--with-newlib --enable-languages=c,c++ --with-gnu-ld --with-gnu-as
--with-ld=/home/venkat/gcc_release/h8300-elf/tools/h8300-elf/bin/ld
--with-as=/home/venkat/gcc_release/h8300-elf/tools/h8300-elf/bin/as
--with-headers=/export/niting/WorkArea/gcc-release/src/newlib/libc/include/
Thread model: single
gcc version 3.1.1
[venkat@peacock BugC37]$ h8300-elf-g++ -mh -mint32 test.C
In file included from
/home/venkat/gcc_release/h8300-elf/tools/include/c++/3.1.1/backward/iostream
.h:31,
from test.C:1:
/home/venkat/gcc_release/h8300-elf/tools/include/c++/3.1.1/backward/backward
_warning.h:32:2: warning: #warning This file includes at least one
deprecated or antiquated header. Please consider using one of the 32 headers
found in section 17.4.1.2 of the C++ standard. Examples include substituting
the <X> header for the <X.h> header for C++ includes, or <sstream> instead
of the deprecated header <strstream.h>. To disable this warning use
-Wno-deprecated.
[venkat@peacock BugC37]$ du -sk -h a.out
2.9M a.out
[venkat@peacock BugC37]$ file a.out
a.out: ELF 32-bit MSB executable, Hitachi H8/300H, version 1 (SYSV),
statically linked, not stripped
[venkat@peacock BugC37]$ ls -al
total 2908
drwxrwxr-x 2 venkat venkat 4096 Sep 24 18:44 .
drwxrwxr-x 65 venkat venkat 4096 Sep 24 17:37 ..
-rwxrwxr-x 1 venkat venkat 2958101 Sep 24 18:44 a.out
-rw-rw-r-- 1 venkat venkat 74 Sep 24 18:42 test.C
[venkat@peacock BugC37]$
_____________________________________________________
"To be or not to be?" is not the question, but "What do you
want to be?" is.
--- Anon