[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gm2] Compiling for stand-alone programs on the RPi
From: |
JD |
Subject: |
[Gm2] Compiling for stand-alone programs on the RPi |
Date: |
Mon, 27 Apr 2015 22:00:25 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
Gaius,
I've got back to trying to compile stand-alone programs for the
Raspberry Pi, but I'm still having no success with more than one
module. I'd appreciate any ideas of yours.
I'm using the native compiler, built about a month ago.
If I do a "standard" compile, e.g..
gm2 -fmakeall main.mod
then I get a clean compile and about 300Kb of binary for the approx 20
lines of M2.
This binary has in it many calls to the runtime support modules such as
Storage, System, M2RTS and RTExceptions and many library calls, mainly
for I/O. At the moment I don't need any of these and I'd like to get
rid of them (no offence!) and then put them in explicitly when I use
them. Of course, it doesn't run without Linux.
I tried the option -nostartfiles and that reduced the binary to
1.5Kb(!) But there was a very simple trick to that reduction: there was
no code at all, just data.
Those calls (the _init's and _finish's) clutter up the binary but
presumably are benign if I don't use them. I that case I could live
with them included.
The big stumbling block is the same one as a few months ago: setting up
the registers, crucially the sp, before my code runs. I would also like
to zero the bss section.
Presumably I don't need the 3 C runtime binaries (crt?.o) and so I have
tried replacing crt1.o with my own code that sets up the sp. The result
of the full compilation is a 4.7Kb binary that contains my crt1.s code
but no other code.
Do you know of other gcc options that would help me? Up to now I must
admit that I've avoided looking at such a long list.
Would a different binutils be appropriate?
I look forward to your thoughts!
Regards,
John
- [Gm2] Compiling for stand-alone programs on the RPi,
JD <=