EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

size of "Hello World" binary too big?

Started by Gerald Hollfelder June 6, 2008
I compiled a simple "Hello World" using GNUARM & newlib-lpc_rel_5a in
thumb mode. The size of the final binary (after "arm-elf-objcopy -O
binary") is 10k bytes. Any tips getting a lower size binary?

An Engineer's Guide to the LPC2100 Series

> -----Original Message-----
> From: l...
> [mailto:l...] On Behalf Of Gerald Hollfelder
> Sent: 06 June 2008 20:17
> To: l...
> Subject: [lpc2000] size of "Hello World" binary too big?
>
> I compiled a simple "Hello World" using GNUARM &
> newlib-lpc_rel_5a in thumb mode. The size of the final binary
> (after "arm-elf-objcopy -O
> binary") is 10k bytes. Any tips getting a lower size binary?

Try passing "-ffunction-sections" as a compiler option, and "--gc-sections"
as a linker option.

Also try a lean and mean printf formatter. You can look for the file
"printf-stdarg.c" in the FreeRTOS.org download (not written by me and not
part of the FreeRTOS.org code).

Regards,
Richard.

+ http://www.FreeRTOS.org
17 official architecture ports, more than 5000 downloads per month.

+ http://www.SafeRTOS.com
Certified by T as meeting the requirements for safety related systems.

Thx. Using these options results in a 0 byte file. ?-|

But with a void main function the resulting binary file is *only*
1.4kB. So I think referencing any standard lib function simply has a
additional footprint of about 8kB.
At 09:17 PM 6/6/2008 +0200, Gerald Hollfelder wrote:
>I compiled a simple "Hello World" using GNUARM & newlib-lpc_rel_5a in
>thumb mode. The size of the final binary (after "arm-elf-objcopy -O
>binary") is 10k bytes. Any tips getting a lower size binary?

Are you using printf? If so try using something simpler like
write. printf is not a small routine and it brings in a lot of support
functions.

Robert

http://www.aeolusdevelopment.com/

From the Divided by a Common Language File (Edited to protect the guilty)
ME - "I'd like to get Price and delivery for connector Part # XXXXX"
Dist./Rep - "$X.XX Lead time 37 days"
ME - "Anything we can do about lead time? 37 days seems a bit high."
Dist./Rep - "that is the lead time given because our stock is live.... we
currently have stock."
No, I used puts.
--- In l..., Robert Adsett
wrote:
>
> At 09:17 PM 6/6/2008 +0200, Gerald Hollfelder wrote:
> >I compiled a simple "Hello World" using GNUARM & newlib-lpc_rel_5a
in
> >thumb mode. The size of the final binary (after "arm-elf-objcopy -O
> >binary") is 10k bytes. Any tips getting a lower size binary?
>
> Are you using printf? If so try using something simpler like
> write. printf is not a small routine and it brings in a lot of
support
> functions.
>
> Robert
>
> http://www.aeolusdevelopment.com/
>
> From the Divided by a Common Language File (Edited to protect the
guilty)
> ME - "I'd like to get Price and delivery for connector Part # XXXXX"
> Dist./Rep - "$X.XX Lead time 37 days"
> ME - "Anything we can do about lead time? 37 days seems a bit
high."
> Dist./Rep - "that is the lead time given because our stock is
live.... we
> currently have stock."
>

I suggest you check the map file and see what is being included.
Are you using ARM mode or THUMB mode ?
What optimization level are you using?

10K in ARM mode not optimized for space may not be to far out.
It depends on how big your startup code is, interrupt handlers that
sort of thing.

Ben
--- In l..., "gho421" wrote:
> No, I used puts.
> --- In l..., Robert Adsett
> wrote:
> >
> > At 09:17 PM 6/6/2008 +0200, Gerald Hollfelder wrote:
> > >I compiled a simple "Hello World" using GNUARM & newlib-lpc_rel_5a
> in
> > >thumb mode. The size of the final binary (after "arm-elf-objcopy -O
> > >binary") is 10k bytes. Any tips getting a lower size binary?
> >
> > Are you using printf? If so try using something simpler like
> > write. printf is not a small routine and it brings in a lot of
> support
> > functions.
> >
> > Robert
> >
> > http://www.aeolusdevelopment.com/
> >
> > From the Divided by a Common Language File (Edited to protect the
> guilty)
> > ME - "I'd like to get Price and delivery for connector Part # XXXXX"
> > Dist./Rep - "$X.XX Lead time 37 days"
> > ME - "Anything we can do about lead time? 37 days seems a bit
> high."
> > Dist./Rep - "that is the lead time given because our stock is
> live.... we
> > currently have stock."
>
It is for this very reason (large code) that I tend to roll my own
ascii output code if at all possible, as well as reduce the library
usage size (IAR) to tiny, I think it is.

boB

--- In l..., "gho421" wrote:
> No, I used puts.
> --- In l..., Robert Adsett
> wrote:
> >
> > At 09:17 PM 6/6/2008 +0200, Gerald Hollfelder wrote:
> > >I compiled a simple "Hello World" using GNUARM & newlib-lpc_rel_5a
> in
> > >thumb mode. The size of the final binary (after "arm-elf-objcopy -O
> > >binary") is 10k bytes. Any tips getting a lower size binary?
> >
> > Are you using printf? If so try using something simpler like
> > write. printf is not a small routine and it brings in a lot of
> support
> > functions.
> >
> > Robert
> >
> > http://www.aeolusdevelopment.com/
> >
> > From the Divided by a Common Language File (Edited to protect the
> guilty)
> > ME - "I'd like to get Price and delivery for connector Part # XXXXX"
> > Dist./Rep - "$X.XX Lead time 37 days"
> > ME - "Anything we can do about lead time? 37 days seems a bit
> high."
> > Dist./Rep - "that is the lead time given because our stock is
> live.... we
> > currently have stock."
>

The 2024 Embedded Online Conference