NDK does not work with assembly files -- not switching from GCC to GAS

268 views
Skip to first unread message

Russell

unread,
Sep 26, 2010, 4:56:30 PM9/26/10
to android-ndk
The NDK toolchain is not correctly recognizing *.S files as assembly
files, and so it is failing.

When I execute the ndk-build V=1, it shows it is executing "arm-eabi-
gcc" for both the *.c and *.S files.

As a consequence, it reports "Error: bad instruction" for every line
of the *.S file.

It should instead be executing arm-eabi-as, ie GAS.


Russell

unread,
Sep 26, 2010, 5:39:06 PM9/26/10
to android-ndk
the problem may be that the assembly is in ARM ADS format, rather than
GCC format.

is it possible to compile ARM ADS assembly code with the NDK?

Or does it have to be converted into GCC format?

Doug Schaefer

unread,
Sep 26, 2010, 5:59:26 PM9/26/10
to andro...@googlegroups.com
On Sun, Sep 26, 2010 at 5:39 PM, Russell <rtil...@gmail.com> wrote:
> the problem may be that the assembly is in ARM ADS format, rather than
> GCC format.

Yes, gcc will call as for .S files.

> is it possible to compile ARM ADS assembly code with the NDK?
>
> Or does it have to be converted into GCC format?

It's standard binutils. Whatever gas accepts, it should be the same for the ndk.

>
>
> On Sep 26, 1:56 pm, Russell <rtill...@gmail.com> wrote:
>> The NDK toolchain is not correctly recognizing *.S files as assembly
>> files, and so it is failing.
>>
>> When I execute the ndk-build V=1, it shows it is  executing "arm-eabi-
>> gcc" for both the *.c and  *.S files.
>>
>> As a consequence, it reports "Error: bad instruction" for every line
>> of the *.S file.
>>
>> It should instead be executing arm-eabi-as, ie GAS.
>

> --
> You received this message because you are subscribed to the Google Groups "android-ndk" group.
> To post to this group, send email to andro...@googlegroups.com.
> To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
>
>

David Turner

unread,
Sep 27, 2010, 4:24:37 AM9/27/10
to andro...@googlegroups.com
On Sun, Sep 26, 2010 at 11:39 PM, Russell <rtil...@gmail.com> wrote:
the problem may be that the assembly is in ARM ADS format, rather than
GCC format.

is it possible to compile ARM ADS assembly code with the NDK?

No, we only support GCC as a toolchain. If gas does not support it, you're out of luck.
 
Or does it have to be converted into GCC format?



On Sep 26, 1:56 pm, Russell <rtill...@gmail.com> wrote:
> The NDK toolchain is not correctly recognizing *.S files as assembly
> files, and so it is failing.
>
> When I execute the ndk-build V=1, it shows it is  executing "arm-eabi-
> gcc" for both the *.c and  *.S files.
>
> As a consequence, it reports "Error: bad instruction" for every line
> of the *.S file.
>
> It should instead be executing arm-eabi-as, ie GAS.

Russell

unread,
Oct 9, 2010, 2:14:13 PM10/9/10
to android-ndk
Thanks for your response.

I verified the problem is that the assembly code uses ADS syntax, not
GNU syntax. When I manually modify the code to GNU syntax, the NDK
works as expected.

Does anyone know of a tool that will convert ADS to GNU?

If not -- the only other option, I believe, is to use ARM's RealView
tool chain to create a static lib, and link to it using the NDK. Has
anyone else does this (link a lib compiled using RVTC) into the NDK
workspace?

I assume its reasonably self-evident, but if someone wouldn't mind
providing a tip, much appreciated.

Also, I assume the lib needs to use EABI calling convention to be
compatible with GCC. I believe EABI is the default of RVTC.

Russell



On Sep 27, 1:24 am, David Turner <di...@android.com> wrote:
> On Sun, Sep 26, 2010 at 11:39 PM, Russell <rtill...@gmail.com> wrote:
> > the problem may be that the assembly is in ARM ADS format, rather than
> > GCC format.
>
> > is it possible to compile ARM ADS assembly code with the NDK?
>
> > No, we only support GCC as a toolchain. If gas does not support it, you're
>
> out of luck.
>
> > Or does it have to be converted into GCC format?
>
> > On Sep 26, 1:56 pm, Russell <rtill...@gmail.com> wrote:
> > > The NDK toolchain is not correctly recognizing *.S files as assembly
> > > files, and so it is failing.
>
> > > When I execute the ndk-build V=1, it shows it is  executing "arm-eabi-
> > > gcc" for both the *.c and  *.S files.
>
> > > As a consequence, it reports "Error: bad instruction" for every line
> > > of the *.S file.
>
> > > It should instead be executing arm-eabi-as, ie GAS.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "android-ndk" group.
> > To post to this group, send email to andro...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > android-ndk...@googlegroups.com<android-ndk%2Bunsu...@googlegroups.com>
> > .

Onur Cinar

unread,
Oct 11, 2010, 12:54:24 AM10/11/10
to andro...@googlegroups.com

Hi Russell,

I had the same problem also. Using RVCT to compiling the assembly files as a static library, and then linking it with the NDK  worked well.  For the C/C++ compilation, take a look at the --arm_linux, --gnu, parameters as well.

Regards,

-onur


To unsubscribe from this group, send email to android-ndk...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


Russell Tillitt

unread,
Nov 26, 2010, 11:02:50 AM11/26/10
to andro...@googlegroups.com
For anyone still looking for a solution for this, I found the following on this thread: http://forums.arm.com/index.php?/topic/14560-using-arms-openmax-dl-with-gnu-compiler/

"The following might be a good starting point for understanding the GNU assembler syntax:
http://microcross.co...y-Quick-Ref.pdf

The following would be a good starting point for understanding the ARM assembler syntax:
http://infocenter.arm.com/help/topic/com.a...473b/index.html

I understand there are a few scripts out there that can help translate from ARM to GAS. Search for ads2gas.pl and you should be able to find one, but note they aren't perfect and you will probably need to check and alter the resulting source file. "


Russell
--
Russell Tillitt
CEO & Co-Founder
Embee Mobile, Inc
Facebook: http://apps.facebook.com/mobilewallet
Website: http://www.embeemobile.com
Reply all
Reply to author
Forward
0 new messages