In message <mpro.mpih8n0288sww01qh.lists@stevefryatt.org.uk>
Steve Fryatt <lists@stevefryatt.org.uk> wrote:
> Is there anything like a "beginners' guide" to using Asasm to assemble code
> (on Linux, if that makes any difference)? Google's failed to turn anything
> up.
I'm not aware of such guide.
> I've got a set of ObjAsm files for a couple of RISC OS projects, which at
> present I have to assemble and link using the DDE on RISC OS. Given that I
> don't use the DDE for much else, that's always been a hassle.
>
> From Asasm's --help option, I can see that I should probably be assembling
> to ELF and then linking. A simple ObjAsm version of what I'm attempting to
> do looks a bit like this:
>
> ObjAsm s.SourceFile -NoCache -desktop ^ -ABSolute -o o.ObjectFile
> Link o.ObjectFile -bin -c++ -o OutputFile
>
> Can anyone suggest how it would convert across? What is the equivalent to
> Link in this case?
If you have a pure assembler project and not using any runtime library
like SCL, I suggest to use the binutils linker directly, i.e.
arm-unknown-riscos-ld when using GCCSDK cross-compiler or ld when using
the GCC GCCSDK release under RISC OS. That's the same ELF based linker
used by GCCSDK.
If you would be using one or more assembler files with your C/C++ project,
then continue to use the normal (arm-unknown-riscos-)gcc linker as
that makes sure the right runtime libraries are being used in the linking
process.
I guess from your example you just want to produce an AIF binary assembled
from one or more assembler files. As an example:
--8<--
AREA |.text|, CODE, READONLY
% 24 ; Make some extra room for the AIF header
EXPORT _start ; _start is the default symbol used by
_start ; the ld linker to start its link process.
SWI 1
= "Hello World", 0
SWI 3
SWI &11
END
--8<--
$ asasm -o main.o main.s
$ arm-unknown-riscos-ld -o hello_world,ff8 main.o
$ elf2aif hello_world,ff8
_start is the entry point which will be called as entry point and that
symbol is also used by the linker to start its link process. If you want
to use another symbol, use -u option for ld.
elf2aif converts the ELF binary to an AIF image but it can't do that
for every ELF binary. For this example you need 24 extra bytes in
the first CODE area you're giving to the linker (a silly limitation which
we better get rid of).
While trying out this example myself, I noticed a small issue in elf2aif.
It can't deal with read-write and zero initialised segments missing.
I've fixed that with r6485. So if you're using the cross-compiler do:
$ svn update
$ make -C builddir/cross/elf2aif/src
$ make -C builddir/cross/elf2aif/src install
and then the above example should work.
Hope this helps a bit,
John.
--
John Tytgat, in his comfy chair at home
John.Tytgat@aaug.net
_______________________________________________
GCCSDK mailing list gcc@gccsdk.riscos.info
Bugzilla: http://www.riscos.info/bugzilla/index.cgi
List Info: http://www.riscos.info/mailman/listinfo/gcc
Main Page: http://www.riscos.info/index.php/GCCSDK
No comments:
Post a Comment