public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Adrian Boeing <aboeing@gmail.com>
To: gcc-help@gcc.gnu.org
Subject: Using GCC to produce small executables (OSX)
Date: Sun, 14 Feb 2010 04:46:00 -0000	[thread overview]
Message-ID: <c024fefc1002130756k48c6d2dcw62557b37e0e408a7@mail.gmail.com> (raw)

Hi,

I am trying to compile a small program with the aim of reducing the
output file size on OSX:

int main(void) {
return 99;
}

I compile with:
gcc tiny.c
and run :
./a.out
echo $?
99

But:
ls -al a.out
Reveals a file of 8664 bytes. (A bit much! Strip reduces this only by
~100 bytes!)

Windows/MSVC does something similar, but if you disable the standard
libraries, you get a executable of 200 or so bytes.

I tried the same with GCC on OSX, but I get:
gcc tiny.c -nostdlib
ld: could not find entry point "start" (perhaps missing crt1.o)
collect2: ld returned 1 exit status

If I try and pass the entry point to LD, I get:
gcc tiny.c -c -nostdlib -m32
ld tiny.o -e main
ld: could not find entry point "main" (perhaps missing crt1.o) for
inferred architecture i386

How can you tell the linker what the entry point function is?
If anyone has any tips on how I can bring the file size down I would
be keen to hear it.

Thanks,
-Adrian

             reply	other threads:[~2010-02-13 15:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-14  4:46 Adrian Boeing [this message]
2010-02-14 11:35 ` John Graham
2010-02-14 15:44   ` Adrian Boeing
2010-02-25 17:07     ` Miles Bader

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c024fefc1002130756k48c6d2dcw62557b37e0e408a7@mail.gmail.com \
    --to=aboeing@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).