I'm working on amr speech codec (porting/optimization) I have an arm (for WinCE) optimized version from voiceage and I use it as a reference in performance testing. So far, binary produced with my lib beats the other one by around 20-30%! I use Vs2008 and I have limited access to ARM instruction set I can generate with Microsoft compiler. So I tried to look for alternative compiler to see what would be performance difference. I have RVCT compiler, but it produces elf binaries/object files. However, I run my test on a wince mobile phone (TyTn 2) so I need to find a way to run code compiled with RVCT on WinCE. Some of the options are 1) to produce assembly listing (-S option of armcc), and try to assemble with some other assembler that can create COFF (MS assembler for arm) 2) compile and convert generated ELF object file to COFF object (seems like objcopy of gnu binutils could help me with that) 3) using fromelf utility supplied by RVCT create BIN file and somehow try to mangle the bits so I can execute them ;)
My first attempt is to create a simple c++ file with one exported function, compile it with RVCT and then try to run that function on the smartphone. The emitted assembly cannot be assembled by the ms assembler (not only they are not compatible, but also ms assembler rejects some of the instructions generated with RVCT compiler; ASR opcode in my case) Then I tried to convert ELF object to coff format and I can't find any information on that. There is a gcc port for ce and objcopy from that toolset is supposed to be able to do the task. However, I can't get it working. I tried different switches, but I have no idea what exactly I need to specify as bfdname for input and output format. So, I couldn't get it working either. Dumping with fromelf and using generated bin file seems to be overkill, so I decided to ask you guys if there is anything I should try to do or maybe someone has already done similar task and could help me. Basically, all I want to do is to compile my code with RVCT compiler and see what's the performance difference. My code has zero dependencies on any c runtime functions.
Just an update... I compiled gnu binutils with support for arm-pe and arm-elf. convert arm-elf to arm-coff: objcopy.exe -I elf32-littlearm -O pe-arm-wince-little test.o test.obj
Now test.obj contains the same function: int add(int, int); the problem is that ms compiler rejects the test.obj file: test.obj : fatal error LNK1136: invalid or corrupt file
I also tried another approach. I converted test.o to symbolsrec format (I have no idea about this format, but that's the only one that worked) and then I converted the generated file to arm-pe. In this case ms compiler linked to the generated test.obj, but the generated machine code isn't valid. I also compiled the test.cpp with gcc-ce and tried to link to he generated .obj file and in this case it all worked. Here's the assembly code as shown in VS debugger:
int X2 = add(X, Y); 00012068 ldr r1, Y, #0x28 0001206C ldr r0, X, #0x2C 00012070 bl 00011000
In case when I was able to link to converted obj file it looked like this:
int X2 = add(X, Y); 00011068 ldr r1, Y, #0x28 0001106C ldr r0, X, #0x2C 00011070 bl |WinMain + 0xfffff000 ( 10000h )|
In that last instruction it jumps to some random location that has nothing to do with my int add(int, int); function.