Re: Using GCC to produce small executables (OSX)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi John,

Thanks! You were infact correct, it does prefix with an '_'. This
produces an executable of only 4kb now. (a 50% saving)

When I try to execute the program I get a 'bus error', presumably
because the cleanup/startup code is not run.
I know this is getting a bit off the topic of GCC, but does anyone
know what the stdlib does / what I need to do to make the program
startup/cleanup nicely?

Thanks,
-Adrian

On Sun, Feb 14, 2010 at 4:59 PM, John Graham
<johngavingraham@xxxxxxxxxxxxxx> wrote:
>> 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
>
> On my machine, that would work just fine - maybe gcc mangles function
> names slightly on OSX, like prefixing with an '_'? Try running nm on
> tiny.o and you'll see all its symbols - from your source, you should
> only see one, the symbol marking the start of main(). Use the name of
> that symbol as the -e argument to ld.
>

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux