How to make very s÷3mall executables.

How to make very s÷3mall executables.

Post by Mitch Dav » Mon, 28 Feb 1994 12:23:41



Dear Readers:

The following program:

main()
{
  /* Do sweet f-all */

Quote:}

compiles with gcc 2.4.5 and lib.4.4.1 to about 10k.

The /bin/swapon program (and many others in /bin and friends) is less than
4k _and_ does I/O.  Can someone tell me how I can make my executables as
small as possible?  Can someone tell me how swapon, sync and friends were
made so small?

When I do an "nm" on the above C program, I see all these included C++
iostream class functions.  I gather from nm that these are being loaded in from
libc.a/libg.a.  Is there any way to stop this happening?

Any ideas please??

Mitch.

 
 
 

How to make very s÷3mall executables.

Post by Kevin Lent » Wed, 02 Mar 1994 09:46:54



> Dear Readers:
> The following program:
> main()
> {
>   /* Do sweet f-all */
> }
> compiles with gcc 2.4.5 and lib.4.4.1 to about 10k.
> The /bin/swapon program (and many others in /bin and friends) is less than
> 4k _and_ does I/O.  Can someone tell me how I can make my executables as
> small as possible?  Can someone tell me how swapon, sync and friends were
> made so small?

Compile with -O2 and -N

Note that the -N makes the executable smaller by combining segments
together. This means that the generated executable can not be used to swap
off and hence there must be 1 copy in memory for each execution of the
program. Which isn't much of a problem for those types of programs
usually.

--
[==================================================================]
[ Kevin Lentin                   |___/~\__/~\___/~~~~\__/~\__/~\_| ]

[ Macintrash: 'Just say NO!'     |___/~\__/~\___/~~~~\____/~~\___| ]
[==================================================================]

 
 
 

1. GCC not making shared executables.

        My system is a hybrid SlackWare 3.0/RedHat 4.0 system.  I had a
major hard disk crash, and didn't back up my system (good thing I have my
/usr directory mounted to another drive, 'eh?) so I reinstalled my system
from scratch.  Although I ordered the Red Hat 4.0 CD from Cheap*Bytes, I
was anxious to put Linux back on my system.  So I installed just disk sets
A, disk set N, disk set F, and disk set TCL of SlackWare 3.0 (not 3.1 ..
the older one).  I also installed some of disk set D, just not the gcc
compiler (C, C++, and ObjC support) and libraries.  I installed the RPM'd
versions of those instead (since I'm also gonna put in 2.0.x of the Linux
kernel, I figured I might as well install the more recent versions of
those tools right from the get go).

        Now, I am unable to get gcc to produce executables which are
dynamically linked against LibC and other shared libraries.  Doing a
"-shared" on the command line does no good because when I try to run the
resulting executable, I get a "cannot execute binary file" message from
bash and when I do an "ldd" on it, I get "cannot execute prog1 (Exec
format error)".

        Anyone know what is wrong?  The kernel version I'm running right
now is 1.2.13.  I haven't gotten to upgrading the kernel yet.  Maybe
that's it?  Maybe the latest versions of ld.so, libc, etc., don't work
correctly with v.1.2.13?

        Thanks in advance for any help on this!

--
===============================================================================
Arcadio Alivio Sincero, Jr.
Sophomore, Computer Science Major at the University of Maryland at College Park
Amateur competitive bodybuilder

"D.A.R.E. .... to keep cops off donuts."

2. Modifying starting volume in Linux kernel

3. How do gcc(linux) compiled executables compare those made from QuickC?

4. temporary htaccess file

5. gcc stopped making demand-paged executables?

6. IP Precedence and Type of Service

7. making executables do tricks

8. Windows copy problem

9. GCC 2.7.2 making huge executables

10. building static executables from dynamic executables on solaris

11. Making changes to env variables and making them stick

12. Making a new kernel - CVSuped, not made world yet.

13. C compiler cannot create executables