GCC ARM assembler to MS ARM Assembler

350 views
Skip to first unread message

Raluca Vartic

unread,
Apr 30, 2015, 11:39:35 AM4/30/15
to discuss...@googlegroups.com


Context: 

  • porting webRTC to WinRT


Problem:

  • Some WebRTC projects include assembly code along with C/C++ code (e.g. libyuvopenmax_dlboringssl).  Most of the assembly code is written for the gcc compiler (gcc syntax, different pseudo instructions than ARM Assembler). We cannot use the gcc compiler for Windows Phone, because the GNU Tools for ARM (https://launchpad.net/gcc-arm-embedded) do not support COFF object file format. Only ELF is supported, and ELF does not work with MS linker. 
  • It doesn't look like there is an easy solution to convert the ARM assembly code to a format compatible with Windows, so the work will involve rewriting code. 
  • libvpx is using the ARM assembler syntax and there are some scripts for conversion to MS assembler syntax. This makes the libvpx assembly code relatively easy to port, but the same cannot be said about the other projects. Before starting to rewrite the ARM assembly code, we wanted to check whether the community already had a solution in mind for these projects. 

 

Questions:

  1. Are we missing some tools that could be used to build those project for WP ARM? e.g. some other tool for conversion ELF -> COFF 
  2. Are we missing some tools that could be used to convert gcc assembler to ARM Assembler (translation of pseudo instructions)? 
  3. Can you think of any other solution that doesn't involve manually rewriting the assembly code?

Thanks,
Raluca

Martin Storsjö

unread,
Apr 30, 2015, 1:21:31 PM4/30/15
to discuss...@googlegroups.com
Hi,

On Thu, 30 Apr 2015, Raluca Vartic wrote:

> 2. Are we missing some tools that could be used to convert gcc assembler to
> ARM Assembler (translation of pseudo instructions)? 

Yes - have a look at gas-preprocessor:
git://git.libav.org/gas-preprocessor.git
https://git.libav.org/?p=gas-preprocessor.git;a=summary

This started out as tool to expand gas macros for use with apple's
assembler, but can nowadays do a full translation from gas style to
armasm. It is done on the fly while compiling, so instead of "arm-foo-gcc
-c asm.s -o asm.o" you do "gas-preprocessor.pl -as-type armasm
-force-thumb -- armasm -nologo -c asm.s -o asm.o". This invokes the cpp
preprocessor to expand all C preprocessor directives, translates the
output into armasm format, and feeds it to the assembler. One example of
using it is within OpenH264:
https://github.com/cisco/openh264/blob/master/build/msvc-common.mk#L12

While gas-preprocessor handles everything in the libav and OpenH264
projects, it isn't necessarily intended to handle every possible gas
syntax, but at least the subset of the syntax used by these projects.
Adapting other projects to use this tool shouldn't hopefully be too hard.
One slightly tricky detail is that you need to run it at build time, so
you need to build in an environment that has got access to a cpp
preprocessor and perl (so on windows, you need to have mingw/msys tools in
the path).

If you really need to do the conversion "offline", not as part of the
actual build, you can probably do something like this:

GASPP_DEBUG=1 gas-preprocessor.pl -as-type armasm -- armasm -c file.s -o foo.o > file.asm

Then you can assemble this file separately later with "armasm file.asm".
(The GASPP_DEBUG macro disables writing something to the file denoted by
-o and instead dumps the converted asm source to stdout.)

// Martin

Raluca Vartic

unread,
May 5, 2015, 1:54:37 PM5/5/15
to discuss...@googlegroups.com
Thanks Martin, we'll try this out.
Reply all
Reply to author
Forward
0 new messages