porting android application from arm to x86
Post on 19-Oct-2014
684 views
DESCRIPTION
Presentation from Massimiliano Torregiani (@MaxTorregiani) at the Intel Codefest Milano on February 13th 2014 at Mediateca http://codefestmilano.bemyapp.comTRANSCRIPT
Porting Android application
from ARM to X86
Massimiliano Torregiani
Intel CODEFEST Milan 13 Febbraio 2014
Android SDK e NDK
Programmazione SDK
compile once, run everywhere
2
Programmazione NDK
compile once, run everywhere
some
oppure oppure
Concetti di Xcompilazione
nativa Sistema Host
E’ il sistema dove il compilatore è installato e su cui
avviene la compilazione
Sistema target
E’ il sistema dove l’eseguibile generato su host sara’
eseguito.
Cosa serve per la compilazione?
• Toolchain (compilatore, linker, archiver, assembler, etc)
• Header file delle librerie
• Librerie standard, dei framework e altre librerie
accessorie cross-compilate per il sistema target
3
Pacchetto NDK di Google
Il pacchetto NDK fornito da Google comprende:
Target Architecture
• ARMv5TE & ARMv7-‐A
• MIPS
• X86 -‐ Intel Atom
Target operative system
Tipo e versione compilatore (e.g. GCC 4.8)
4
Supporto Intel per Android:
Beacon Mountain
5
Porting da ARM a X86
6
Sample 1:
HelloJni
Differenze tra architettura
ARM e X86
Memory Alignment
7
struct TestStruct { int mVar1; long long mVar2; int mVar3;
};
By Default
“Double Margin”
By default
No margin
GCC flag “-malign-double”
Differenze tra architettura
ARM e X86
8
Memory
Alignment
Big or li/le endian order
(ARM is bi-‐endian) li/le-‐endian assembly
Floating
Point
ARMv5 à So@ FP opts
ARMv7 à Hardware FPU
instrucJons (VFP)
Intel Atom à IA-‐32
instrucJons, Hardware Based
FP opts
SIMD
extensions
ARMv5 à No SIMD ext
ARMv7 à NEON ext
Intel Atom à SSSE3 (Supplemental
Streaming SIMD Extensions 3)
Differenze tra architettura
GCC Flags
Memory
Alignment
9
–mlittle-endian
–mbig-endian
Floating
Point
SIMD
extensions
-mfloat-abi= soft | softfp | hard
-mfpu= vfp | vfpv3-d16 | neon | ...
–mfpmath=sse
-mavx
-maes
-march=armv7-a
-mtune=cortex-a8
–DHAVE_NEON=1
-msse
Porting da ARM a X86
10
Sample 2:
HelloNeon
Utilizzo librerie esterne
11
Step 1: Porting
librerie esterne
Libreria Esterna naJva
Libreria compilata per
Target
Codice naJvo proprietario
APP Android (Java)
JNI
Step 2: Porting
codice nativo
proprietario
Step 3: Rebuild
applicazione
Porting da ARM a X86
12
Sample 3:
HelloFFmpeg
KALPA srl
Mail: [email protected]
Twitter: @maxtorregiani
Linkedin: h/p://www.linkedin.com/pub/massimiliano-‐torregiani/3/555/550
Thanks!