OAR

RTEMS 4.5.0 On-Line Library


Why is my executable so big?

PREV UP NEXT Bookshelf RTEMS Frequently Asked Questions

6.1.1: Why is my executable so big?

There are two primary causes for this. The most common is that you are doing an ls -l and looking at the actual file size -- not the size of the code in the target image. This file could be in an object format such as ELF or COFF and contain debug information. If this is the case, it could be an order of magnitude larger than the required code space. Use the strip command in your cross toolset to remove debugging information.

The following example was done using the i386-rtems cross toolset and the pc386 BSP. Notice that with symbolic information included the file hello.exe is almost a megabyte and would barely fit on a boot floppy. But there is actually only about 93K of code and initialized data. The other 800K is symbolic information which is not required to execute the application.

$ ls -l hello.exe
-rwxrwxr-x    1 joel     users      930515 May  2 09:50 hello.exe
$ i386-rtems-size hello.exe
   text	   data	    bss	    dec	    hex	filename
  88605	   3591	  11980	 104176	  196f0	hello.exe
$ i386-rtems-strip hello.exe
$ ls -l hello.exe
-rwxrwxr-x    1 joel     users      106732 May  2 10:02 hello.exe
$ i386-rtems-size hello.exe
   text	   data	    bss	    dec	    hex	filename
  88605	   3591	  11980	 104176	  196f0	hello.exe

Another alternative is that the executable file is in an ASCII format such as Motorola Srecords. In this case, there is no debug information in the file but each byte in the target image requires two bytes to represent. On top of that, there is some overhead required to specify the addresses where the image is to be placed in target memory as well as checksum information. In this case, it is not uncommon to see executable files that are between two and three times larger than the actual space required in target memory.

Remember, the debugging information is required to do symbolic debugging with gdb. Normally gdb obtains its symbolic information from the same file that it gets the executable image from. However, gdb does not require that the executable image and symbolic information be obtained from the same file. So you might want to create a hello_with_symbols.exe, copy that file to hello_without_symbols.exe, and strip hello_without_symbols.exe. Then gdb would have to be told to read symbol information from hello_with_symbols.exe. The gdb command line option -symbols or command symbol-file may be used to specify the file read for symbolic information.


PREV UP NEXT Bookshelf RTEMS Frequently Asked Questions

Copyright © 1988-2000 OAR Corporation