Friday, 18 September 2015

Re: [gccsdk] Data synchronization and SWIs

In message <55FC6759.9090809@aaug.net>
John Tytgat <John.Tytgat@aaug.net> wrote:


>This corrupts r0-r3, possibly r14 when this gets executed in SVC. You
>need to tell gcc this. Inline assembler does not follow the APCS-32 ABI
>calling conventions (which I think you seem to assume here).

I was. That probably explains a lot.

>Aside, it is very easy to get things subtly wrong with inline
>assembler. Even when it seems to be working and you got it wrong in the
>first place, one day it will bite you when changing optimization level,
>ask for global optimisation or doing simply a minor version upgrade.
>
>A much safer approach for SWI calling and with additional C type safety
>is to use OSLib (http://ro-oslib.sf.net/).

Thanks for this tip. Looking at the assembly listing of bits of the
elf output I soon realized that GCC was playing fast and loose
with my chosen register assignments - fine for optimizing compiled
C code, not so jolly for calling SWIs.

@Lee

> I think your operand numbering is a bit out:

I now realize that I had been totally misconstruing the ARM GCC
Inline Assembler Cookbook.

I started using the inline assembler because I did not know how to
setup GCC to compile a dynamically loadable file by statically
linking two files, one compiled from C source, the other from
assembly source. I had been assuming APCS-32 calling conventions.
So I think I will now revert to separate source files for C
and assembler. Where do I read up the calling conventions for
linking with GCC output?

Thanks again for the advice.
--
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/

_______________________________________________
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