Description
Armv7 android spec do not ensure NEON support, even if most actual devices have it. The simulator does not support the extensions.
When running rust executable in the android emulator, jemalloc triggers Invalid instructions errors as its code contains vmov.i32 (among others) instructions.
64cdc: 0a0000c6 beq 64ffc <je_tcache_boot+0x3d4>
64ce0: e59f1394 ldr r1, [pc, #916] ; 6507c <je_tcache_boot+0x454>
64ce4: f2c12055 vmov.i32 q9, #21 ; 0x00000015
64ce8: f3c44058 vmov.i32 q10, #200 ; 0x000000c8
64cec: e3a07000 mov r7, #0
64cf0: f2c16054 vmov.i32 q11, #20 ; 0x00000014
64cf4: e3a050c8 mov r5, #200 ; 0xc8
64cf8: e79f1001 ldr r1, [pc, r1]
64cfc: e2812080 add r2, r1, #128 ; 0x80
64d00: e2813e16 add r3, r1, #352 ; 0x160
This issue is only visible when 1/ running a rust binary (as in, not a library) and 2/ on the simulator or one of the very rare devices that do not actually have support.
to reproduce:
avdmanager create avd -n test -k "system-images;android-21;google_apis;armeabi-v7a"
$ANDROID_SDK_ROOT/emulator/emulator @test
TC=path/to/toolchain
echo "fn main(){}" | rustc -Clinker=$TC/bin/arm-linux-androideabi-gcc --target armv7-linux-androideabi -o foo -
$ANDROID_SDK_ROOT/platform-tools/adb push foo /data/local/tmp/foo
$ANDROID_SDK_ROOT/platform-tools/adb shell /data/local/tmp/foo
adb logcat should point to a tombstone...
backtrace:
#00 pc 0003e5b4 /data/local/tmp/foo
#01 pc 000292d8 /data/local/tmp/foo
invalid op:
$TC/bin/arm-linux-androideabi-objdump -d foo | grep 3e5b4
3e5b4: f2c12055 vmov.i32 q9, #21 ; 0x00000015
We know for sure that this code comes from jemalloc, but we suspect at last backtrace contains some NEON instructions has well. (we grepped vmov in objdump output, and some functions (like read_attribute) containing them come from backtrace.