Tech Support > Computer Hardware > Microprocessors > Making small executables from arm-elf-gcc
Making small executables from arm-elf-gcc
Posted by James Laamnna on July 26th, 2003


Hi.
I'm trying to compile this program:
int main()
{
int i, j;
for (i = 0; i < 100; i++)
{
j = j+1;
}
return 0;
}

arm-elf-gcc -s -Os -o test.elf test.c produces a program with the
following output from arm-elf-size:
text data bss dec hex filename
5484 1872 184 7540 1d74 test.elf

Also, tracing the linking: (arm-elf-gcc -s -Os -Wl,--trace -o test.elf
test.c)
/export/home1/jamesl/arm/arm-elf/bin/ld: mode armelf
/export/home1/jamesl/arm/lib/gcc-lib/arm-elf/2.95.3/crtbegin.o
/export/home1/jamesl/arm/arm-elf/lib/crt0.o
/tmp/cc9r4g2Q.o
(/export/home1/jamesl/arm/lib/gcc-lib/arm-elf/2.95.3/libgcc.a)__main.o
(/export/home1/jamesl/arm/lib/gcc-lib/arm-elf/2.95.3/libgcc.a)_exit.o
(/export/home1/jamesl/arm/arm-elf/lib/libc.a)atexit.o
(/export/home1/jamesl/arm/arm-elf/lib/libc.a)exit.o
(/export/home1/jamesl/arm/arm-elf/lib/libc.a)impure.o
(/export/home1/jamesl/arm/arm-elf/lib/libc.a)malloc.o
(/export/home1/jamesl/arm/arm-elf/lib/libc.a)mallocr.o
(/export/home1/jamesl/arm/arm-elf/lib/libc.a)memset.o
(/export/home1/jamesl/arm/arm-elf/lib/libc.a)mlock.o
(/export/home1/jamesl/arm/arm-elf/lib/libc.a)sbrkr.o
(/export/home1/jamesl/arm/arm-elf/lib/libc.a)syscalls.o
(/export/home1/jamesl/arm/arm-elf/lib/libc.a)errno.o
(/export/home1/jamesl/arm/arm-elf/lib/libc.a)freer.o
(/export/home1/jamesl/arm/lib/gcc-lib/arm-elf/2.95.3/libgcc.a)_udivsi3.o
(/export/home1/jamesl/arm/lib/gcc-lib/arm-elf/2.95.3/libgcc.a)_dvmd_tls.
o
/export/home1/jamesl/arm/lib/gcc-lib/arm-elf/2.95.3/crtend.o

Is there anyway to prevent all these calls?
5484 bytes of code and 1872 bytes of data for a small program like that
is crazy!

I suspect the problem is the _exit() call in crt0.S

Does anyone have a workaround for this.
I'm using newlib-1.8.1 as my libc.

Thanks.

Please CC me for I"m not subscribed to the list.

--James Lamanna

Posted by Tauno Voipio on July 26th, 2003



"James Laamnna" <jamesl@appliedminds.com> wrote in message
news:a091da2f.0307251658.39e01baa@posting.google.c om...
Yes.

Make your own startup module and instruct the linker to ignore the default
startup code. The bulk is coming in due to the startup modules crtbegin.o
and crt0.o.

I'm using a module to create an ARM AIF header to the executable and do the
necessary initialisation for the C runtime. It needs also a tailored linker
script (which is needed for stand-alone code anyway).

BTW, you ought to get a compiler warning about uninitialised variable 'j'.

In my experience, -O2 produces code best suited for embedded use.

HTH

Tauno Voipio
tauno voipio @ iki fi




Posted by Lewin A.R.W. Edwards on July 27th, 2003


Well, I wrote a book about it, does that help?
Seriously, email me privately and I'll dig into my backups and send
you the code (Monday).

All the I/O is memory mapped. You just coerce a pointer into
containing the correct address. The sample source I'll send you
illustrates it simply.

Posted by Tauno Voipio on July 27th, 2003



"Rich Webb" <bbew.ar@mapson.nozirev.ten> wrote in message
news:89k6ivg2ruiqbdtm15j5hjd271jr9jhdvv@4ax.com...
There seems to be a social request for a very simple ARM board, e.g. an
AT91R40008 with a single Flash chip (e.g. AM29DL163) , crystal, RS-232
buffers, reset chip and connectors for the PIO and JTAG pins.

I could provide a draft schematic, if somebody is interested to make the
thing.

Tauno Voipio
tauno voipio @ iki fi




Posted by Lewin A.R.W. Edwards on July 27th, 2003


I recommended the AT91EB40 in my book, for that specific reason. It
was $179 at the time (it's now more expensive!). It has been
superseded by the EB40A, which costs $198.00 at Digi-Key (cat
#AT91EB40A-ND). Very reasonably priced kits, I highly recommend them.

Of course, it is almost trivial to make up a simple demo board for
these cheap ARMs. Personally I'd like to make a little board with a
Cirrus EP7312 or Sharp LH79520, a socket for a DIP flash chip, and a
socket for a standard RAM DIMM, and everything else brought out to
headers. The production cost of such an item would be about $100-$120
(in tiny quantity). But I never seem to find time to sit down and
finalize such a project.

Oh, by the way: also look at <http://www.earthlcd.com/marmalade.htm>,
but it still doesn't appear to be shipping yet and there's no
guarantee as to support/availability. So the EB40A is still a safer
bet.

Posted by James Laamnna on July 27th, 2003


I've done a lot of PCB designs before, so I could make up the PCB
design and everything, and then I could release it to whoever wants it
and give them the names of a few reasonably priced PCB-manufacture
companies.

Also, like one of the previous posters, I was looking to step way up
from a Atmel AVR. I'm looking at the AT91s, but also there is a new
chip coming out from TI, the TMS320F281x series. Pretty fast chip, for
about $20 each. Problem is you have to pay for development tools,
etc....

Posted by Martin Maurer on July 27th, 2003


I searched on the Atmel website and found a few different AT91 eval boards
like AT91EB42, AT91EB55, AT91EB63.

Does someone know the differences ?
What are the prices of them ? Perhaps buying is cheaper than making it
ourself
(especially if you add to get all the parts, perhaps from different
distributors ?).

Can someone point me to a (up-to-date) website,
where i can download the arm-gcc ?

Greetings,

Martin


Posted by Lewin A.R.W. Edwards on July 28th, 2003


You can try mine, of course My goal is to get in the top 25,000
selling SKUs on amazon, and I've got a long way to go yet (currently
#70,711 - up a long way from where I started at 2,000,000th!). But at
least I outsell bulk packs of Oberto beef jerky, and also such
memorable tomes as "DB2 Universal Database for OS/390: An Introduction
to DB2 for OS/390 Version 7" and "Squids Will Be Squids: Fresh Morals,
Beastly Fables".

I have made the sourcecode for the book example projects available at
http://www.zws.com/downloads/sourcecode.tar.gz - this source is
intended for the EB40 but should easily be adaptable to the 40A. I
have NOT yet analyzed exactly what would need to be changed (I don't
own an EB40A) so please don't ask

(I haven't linked this file on zws.com yet; I'll do that when I get
time to write some decent text; patience!).

Posted by rickman on July 29th, 2003


Martin Maurer wrote:
I bought an AT91EB55 and it was about $200 or maybe $250. You need to
check with distribution or Atmel for pricing. This stuff can vary and
they obsolete boards from time to time.

I believe different CPU chips. I know the AT91EB55 uses the AT91M55800A
which has a lot of IO functions on chip.


Building your own board is a PITA. Some of the more commone boards like
the EB40 are defacto standards with a lot of third party support like
board support packages for OS, etc.

Try this link...

http://www.sharpsma.com/sma/Products...ibrary.htm#TOF

You will have to register. I normally use a yahoo account for this sort
of thing.

--

Rick "rickman" Collins

rick.collins@XYarius.com
Ignore the reply address. To email me use the above address with the XY
removed.

Arius - A Signal Processing Solutions Company
Specializing in DSP and FPGA design URL http://www.arius.com
4 King Ave 301-682-7772 Voice
Frederick, MD 21701-3110 301-682-7666 FAX

Posted by Lewin A.R.W. Edwards on July 30th, 2003


Stupid! The URL is actually:

http://www.zws.com/publications/down...rcecode.tar.gz

Sorry, all!

Posted by Rich Webb on August 5th, 2003


On 4 Aug 2003 17:43:15 -0700, Greg Holdren <gregh@wx.rose.hp.com> wrote:

Dang -- might have to take a short trip at lunchtime tomorrow. Thanks
for the pointer, looks like a good hack (in the original sense).

--
Rich Webb Norfolk, VA

Posted by Martin Maurer on August 5th, 2003


Hello,


Great idea ! Can you give me the manufacturer and perhaps complete name of
this part ? I am from Germany and want to try to get it in Germany.

Do someone know of equivalent things containing an ARM processor
and flash memory ?

Greetings,

Martin (mailto:newsgroup_05082003@clibb.de)





Posted by Greg Holdren on August 5th, 2003


Martin Maurer <capiman@clibb.de> wrote:

: Great idea ! Can you give me the manufacturer and perhaps complete name of
: this part ? I am from Germany and want to try to get it in Germany.

: Do someone know of equivalent things containing an ARM processor
: and flash memory ?

Item number 290331
Cable/DSL Broadband Router w/4 port 10/100Mbps Switch

Direct Link:
http://www.compusa.com/products/prod...331&pfp=BROWSE

You can order it online with the link above.

--
Greg Holdren
greg <dot> holdren <at> <initials of company> <dot> com


Similar Posts