arm - Illegal instruction when running simple ELLCC-generated ELF binary on a Raspberry Pi -
i have empty program in llvm ir:
define i32 @main(i32 %argc, i8** %argv) nounwind { entry: ret i32 0 }
i'm cross-compiling on intel x86-64 windows arm linux using ellcc, following command:
ecc++ hw.ll -o hw.o -target arm-linux-engeabihf
it completes without errors , generates elf binary.
when take binary raspberry pi model b+ (running raspbian), following error:
illegal instruction
i don't know how tell what's wrong the disassembled code. tried other arm linux targets behavior same. what's wrong?
the exact same file builds, links , runs fine other targets i386-linux-eng
, x86_64-w64-mingw32
, etc (that test on), again using ellcc toolchain.
assuming library , startup code isn't @ fault, disassembly of main
looks like:
.text:00010188 e24dd008 sub sp, sp, #8 .text:0001018c e3002000 movw r2, #0 .text:00010190 e58d0004 str r0, [sp, #4] .text:00010194 e1a00002 mov r0, r2 .text:00010198 e58d1000 str r1, [sp] .text:0001019c e28dd008 add sp, sp, #8 .text:000101a0 e12fff1e bx lr
i'd guess it's choking on movw
@ 0x0001018c. movw
/movt
encodings can handle full 16-bit immediate values first appeared in armv6t2 version of architecture - arm1176 in original pi models predates that, supporting original armv6*.
you need tell compiler generate code appropriate thing you're running on - don't know ellcc, i'd guess it's modern , up-to-date , defaulting newer armv6t2 or armv7. otherwise, it's akin generating code pentium , hoping works on 80486 - might lucky, might not. said, there's no reason should have chosen encoding in first place - it's not if 0 can't encoded in 'classic' mov
instruction...
the decadent option, however, consider perfect excuse replace pi pi 2 - cortex-a7s in nice capable armv7 cores ;)
* lies clarity. think 1176 might v6k, that's irrelevant here. i'm not sure if exists plain armv6, , various architecture extensions frankly hideous mess
Comments
Post a Comment