SlideShare une entreprise Scribd logo
1  sur  13
Télécharger pour lire hors ligne
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

Programmazione NDK

some

compile once, run everywhere
oppure

oppure

2	
  
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

Sample 1:
HelloJni

6	
  
Differenze tra architettura
ARM e X86
Memory Alignment
struct TestStruct {
int mVar1;
long long mVar2;
int mVar3;
};

GCC flag “-malign-double”
By Default
“Double Margin”

By default
No margin

7	
  
Differenze tra architettura
ARM e X86

Memory

Big	
  or	
  li/le	
  endian	
  order	
  

Alignment

(ARM	
  is	
  bi-­‐endian)	
  

Floating
Point

li/le-­‐endian	
  assembly	
  

ARMv5	
  à	
  So@	
  FP	
  opts	
  

Intel	
  Atom	
  à	
  IA-­‐32	
  

ARMv7	
  à	
  Hardware	
  FPU	
  

instrucJons,	
  Hardware	
  Based	
  

instrucJons	
  (VFP)	
  

FP	
  opts	
  

SIMD

ARMv5	
  à	
  No	
  SIMD	
  ext	
  

Intel	
  Atom	
  à	
  SSSE3	
  (Supplemental	
  

extensions

ARMv7	
  à	
  NEON	
  ext	
  

Streaming	
  SIMD	
  Extensions	
  3)	
  
8	
  
Differenze tra architettura
GCC Flags

Memory

–mlittle-endian

Alignment

–mbig-endian

Floating

-mfloat-abi= soft | softfp | hard

–mfpmath=sse

Point

-mfpu= vfp | vfpv3-d16 | neon | ...

-mavx
-maes

SIMD

-march=armv7-a

extensions

-mtune=cortex-a8

-msse

–DHAVE_NEON=1
9	
  
Porting da ARM a X86

Sample 2:
HelloNeon

10	
  
Utilizzo librerie esterne
Step 1: Porting
librerie esterne

Libreria	
  Esterna	
  
naJva	
  

Codice	
  naJvo	
  
proprietario	
  

Libreria	
  
compilata	
  per	
  
Target	
  

Step 2: Porting
codice nativo
proprietario

JNI

APP	
  Android	
  
(Java)	
  

Step 3: Rebuild
applicazione
11	
  
Porting da ARM a X86

Sample 3:
HelloFFmpeg

12	
  
KALPA

srl

Thanks!
Mail:

massimiliano.torregiani@kalpa.it	
  

Twitter: @maxtorregiani	
  
Linkedin: h/p://www.linkedin.com/pub/massimiliano-­‐torregiani/3/555/550	
  

Contenu connexe

Similaire à Porting Android application from ARM to x86

Thanatos - Parallel & Distributed Computing
Thanatos -  Parallel & Distributed ComputingThanatos -  Parallel & Distributed Computing
Thanatos - Parallel & Distributed ComputingIdriss Riouak
 
.NET & Linux: la strana coppia - DotNetDay 2018
.NET & Linux: la strana coppia - DotNetDay 2018.NET & Linux: la strana coppia - DotNetDay 2018
.NET & Linux: la strana coppia - DotNetDay 2018Fabrizio Bernabei
 
Meetup ASP.NET Core e Kubernetes
Meetup ASP.NET Core e KubernetesMeetup ASP.NET Core e Kubernetes
Meetup ASP.NET Core e Kubernetesdotnetcode
 
Summary of “The Case for Writing Network Drivers in High-Level Programming La...
Summary of “The Case for Writing Network Drivers in High-Level Programming La...Summary of “The Case for Writing Network Drivers in High-Level Programming La...
Summary of “The Case for Writing Network Drivers in High-Level Programming La...LeonardoIurada
 
php day 2008 - Introduzione agli ez components
php day 2008 - Introduzione agli ez componentsphp day 2008 - Introduzione agli ez components
php day 2008 - Introduzione agli ez componentsGaetano Giunta
 
PIT2012: Workshop@UniNA - Compilazione del Kernel Linux
PIT2012: Workshop@UniNA - Compilazione del Kernel LinuxPIT2012: Workshop@UniNA - Compilazione del Kernel Linux
PIT2012: Workshop@UniNA - Compilazione del Kernel LinuxMarco Ferrigno
 
XeDotNet - Source Generator
XeDotNet - Source GeneratorXeDotNet - Source Generator
XeDotNet - Source GeneratorMarco Bortolin
 
MITM Attack with Patching Binaries on the Fly by Adding Shellcodes
MITM Attack with Patching Binaries on the Fly by Adding ShellcodesMITM Attack with Patching Binaries on the Fly by Adding Shellcodes
MITM Attack with Patching Binaries on the Fly by Adding ShellcodesGianluca Gabrielli
 
Angelo Impedovo, Linux Day 2016, Programmazione Parallela in openCL
Angelo Impedovo, Linux Day 2016, Programmazione Parallela in openCLAngelo Impedovo, Linux Day 2016, Programmazione Parallela in openCL
Angelo Impedovo, Linux Day 2016, Programmazione Parallela in openCLAngelo Impedovo
 
Writing apps for android with .net
Writing apps for android with .net Writing apps for android with .net
Writing apps for android with .net Leonardo Alario
 
Node.js - Server Side Javascript
Node.js - Server Side JavascriptNode.js - Server Side Javascript
Node.js - Server Side JavascriptMatteo Napolitano
 
MySQL Tech Tour 2016 - Database-as-a-Service con MySQL e Oracle Openstack
MySQL Tech Tour 2016 - Database-as-a-Service con MySQL e Oracle OpenstackMySQL Tech Tour 2016 - Database-as-a-Service con MySQL e Oracle Openstack
MySQL Tech Tour 2016 - Database-as-a-Service con MySQL e Oracle OpenstackPar-Tec S.p.A.
 
Linux Kernel, driver e compilazione
Linux Kernel, driver e compilazioneLinux Kernel, driver e compilazione
Linux Kernel, driver e compilazioneFulvio Corno
 
OpenHardware : Arduino
OpenHardware : ArduinoOpenHardware : Arduino
OpenHardware : ArduinoNaLUG
 

Similaire à Porting Android application from ARM to x86 (20)

Thanatos - Parallel & Distributed Computing
Thanatos -  Parallel & Distributed ComputingThanatos -  Parallel & Distributed Computing
Thanatos - Parallel & Distributed Computing
 
Thanatos
ThanatosThanatos
Thanatos
 
GNU Linux Programming introduction
GNU Linux Programming introductionGNU Linux Programming introduction
GNU Linux Programming introduction
 
Corso linux base
Corso linux baseCorso linux base
Corso linux base
 
.NET & Linux: la strana coppia - DotNetDay 2018
.NET & Linux: la strana coppia - DotNetDay 2018.NET & Linux: la strana coppia - DotNetDay 2018
.NET & Linux: la strana coppia - DotNetDay 2018
 
Meetup ASP.NET Core e Kubernetes
Meetup ASP.NET Core e KubernetesMeetup ASP.NET Core e Kubernetes
Meetup ASP.NET Core e Kubernetes
 
Summary of “The Case for Writing Network Drivers in High-Level Programming La...
Summary of “The Case for Writing Network Drivers in High-Level Programming La...Summary of “The Case for Writing Network Drivers in High-Level Programming La...
Summary of “The Case for Writing Network Drivers in High-Level Programming La...
 
php day 2008 - Introduzione agli ez components
php day 2008 - Introduzione agli ez componentsphp day 2008 - Introduzione agli ez components
php day 2008 - Introduzione agli ez components
 
Docker & DevOps
Docker  & DevOpsDocker  & DevOps
Docker & DevOps
 
Introduzione a Docker
Introduzione a DockerIntroduzione a Docker
Introduzione a Docker
 
PIT2012: Workshop@UniNA - Compilazione del Kernel Linux
PIT2012: Workshop@UniNA - Compilazione del Kernel LinuxPIT2012: Workshop@UniNA - Compilazione del Kernel Linux
PIT2012: Workshop@UniNA - Compilazione del Kernel Linux
 
XeDotNet - Source Generator
XeDotNet - Source GeneratorXeDotNet - Source Generator
XeDotNet - Source Generator
 
MITM Attack with Patching Binaries on the Fly by Adding Shellcodes
MITM Attack with Patching Binaries on the Fly by Adding ShellcodesMITM Attack with Patching Binaries on the Fly by Adding Shellcodes
MITM Attack with Patching Binaries on the Fly by Adding Shellcodes
 
Angelo Impedovo, Linux Day 2016, Programmazione Parallela in openCL
Angelo Impedovo, Linux Day 2016, Programmazione Parallela in openCLAngelo Impedovo, Linux Day 2016, Programmazione Parallela in openCL
Angelo Impedovo, Linux Day 2016, Programmazione Parallela in openCL
 
ASP.NET Core essentials
ASP.NET Core essentialsASP.NET Core essentials
ASP.NET Core essentials
 
Writing apps for android with .net
Writing apps for android with .net Writing apps for android with .net
Writing apps for android with .net
 
Node.js - Server Side Javascript
Node.js - Server Side JavascriptNode.js - Server Side Javascript
Node.js - Server Side Javascript
 
MySQL Tech Tour 2016 - Database-as-a-Service con MySQL e Oracle Openstack
MySQL Tech Tour 2016 - Database-as-a-Service con MySQL e Oracle OpenstackMySQL Tech Tour 2016 - Database-as-a-Service con MySQL e Oracle Openstack
MySQL Tech Tour 2016 - Database-as-a-Service con MySQL e Oracle Openstack
 
Linux Kernel, driver e compilazione
Linux Kernel, driver e compilazioneLinux Kernel, driver e compilazione
Linux Kernel, driver e compilazione
 
OpenHardware : Arduino
OpenHardware : ArduinoOpenHardware : Arduino
OpenHardware : Arduino
 

Plus de BeMyApp

Introduction to epid
Introduction to epidIntroduction to epid
Introduction to epidBeMyApp
 
Introduction ciot workshop premeetup
Introduction ciot workshop premeetupIntroduction ciot workshop premeetup
Introduction ciot workshop premeetupBeMyApp
 
Présentation des APIs cognitives IBM Watson
Présentation des APIs cognitives IBM WatsonPrésentation des APIs cognitives IBM Watson
Présentation des APIs cognitives IBM WatsonBeMyApp
 
Crédit Agricole S.A. Personae et Parcours
Crédit Agricole S.A. Personae et ParcoursCrédit Agricole S.A. Personae et Parcours
Crédit Agricole S.A. Personae et ParcoursBeMyApp
 
Cisco Paris DevNet Hackathon slideshow - Intro
Cisco Paris DevNet Hackathon slideshow - IntroCisco Paris DevNet Hackathon slideshow - Intro
Cisco Paris DevNet Hackathon slideshow - IntroBeMyApp
 
Tumeurs Neuroendocrines : une vue d'ensemble
Tumeurs Neuroendocrines : une vue d'ensembleTumeurs Neuroendocrines : une vue d'ensemble
Tumeurs Neuroendocrines : une vue d'ensembleBeMyApp
 
Building your first game in Unity 3d by Sarah Sexton
Building your first game in Unity 3d  by Sarah SextonBuilding your first game in Unity 3d  by Sarah Sexton
Building your first game in Unity 3d by Sarah SextonBeMyApp
 
Using intel's real sense to create games with natural user interfaces justi...
Using intel's real sense to create games with natural user interfaces   justi...Using intel's real sense to create games with natural user interfaces   justi...
Using intel's real sense to create games with natural user interfaces justi...BeMyApp
 
Introduction to using the R200 camera & Realsense SDK in Unity3d - Jon Collins
Introduction to using the R200 camera & Realsense SDK in Unity3d - Jon CollinsIntroduction to using the R200 camera & Realsense SDK in Unity3d - Jon Collins
Introduction to using the R200 camera & Realsense SDK in Unity3d - Jon CollinsBeMyApp
 
Audio Mixer in Unity5 - Andy Touch
Audio Mixer in Unity5 - Andy TouchAudio Mixer in Unity5 - Andy Touch
Audio Mixer in Unity5 - Andy TouchBeMyApp
 
Shaders - Claudia Doppioslash - Unity With the Best
Shaders - Claudia Doppioslash - Unity With the BestShaders - Claudia Doppioslash - Unity With the Best
Shaders - Claudia Doppioslash - Unity With the BestBeMyApp
 
[HACKATHON CISCO PARIS] Slideshow du workshop Smart City
[HACKATHON CISCO PARIS] Slideshow du workshop Smart City[HACKATHON CISCO PARIS] Slideshow du workshop Smart City
[HACKATHON CISCO PARIS] Slideshow du workshop Smart CityBeMyApp
 
Tools to Save Time
Tools to Save TimeTools to Save Time
Tools to Save TimeBeMyApp
 
[Workshop e résidents] présentation intent, craft ai, dalkia et incubateur
[Workshop e résidents] présentation intent, craft ai, dalkia et incubateur[Workshop e résidents] présentation intent, craft ai, dalkia et incubateur
[Workshop e résidents] présentation intent, craft ai, dalkia et incubateurBeMyApp
 
[Webinar E-résidents #1] Présentation des différents métiers du bâtiment conn...
[Webinar E-résidents #1] Présentation des différents métiers du bâtiment conn...[Webinar E-résidents #1] Présentation des différents métiers du bâtiment conn...
[Webinar E-résidents #1] Présentation des différents métiers du bâtiment conn...BeMyApp
 
[IoT World Forum Webinar] Review of CMX Cisco technology
[IoT World Forum Webinar] Review of CMX Cisco technology[IoT World Forum Webinar] Review of CMX Cisco technology
[IoT World Forum Webinar] Review of CMX Cisco technologyBeMyApp
 
HP Helion Episode 6: Cloud Foundry Summit Recap
HP Helion Episode 6: Cloud Foundry Summit RecapHP Helion Episode 6: Cloud Foundry Summit Recap
HP Helion Episode 6: Cloud Foundry Summit RecapBeMyApp
 
Webinar UI/UX by Francesco Marcellino
Webinar UI/UX by Francesco MarcellinoWebinar UI/UX by Francesco Marcellino
Webinar UI/UX by Francesco MarcellinoBeMyApp
 
HP Helion Webinar #5 - Security Beyond Firewalls
HP Helion Webinar #5 - Security Beyond FirewallsHP Helion Webinar #5 - Security Beyond Firewalls
HP Helion Webinar #5 - Security Beyond FirewallsBeMyApp
 
HP Helion Webinar #4 - Open stack the magic pill
HP Helion Webinar #4 - Open stack the magic pillHP Helion Webinar #4 - Open stack the magic pill
HP Helion Webinar #4 - Open stack the magic pillBeMyApp
 

Plus de BeMyApp (20)

Introduction to epid
Introduction to epidIntroduction to epid
Introduction to epid
 
Introduction ciot workshop premeetup
Introduction ciot workshop premeetupIntroduction ciot workshop premeetup
Introduction ciot workshop premeetup
 
Présentation des APIs cognitives IBM Watson
Présentation des APIs cognitives IBM WatsonPrésentation des APIs cognitives IBM Watson
Présentation des APIs cognitives IBM Watson
 
Crédit Agricole S.A. Personae et Parcours
Crédit Agricole S.A. Personae et ParcoursCrédit Agricole S.A. Personae et Parcours
Crédit Agricole S.A. Personae et Parcours
 
Cisco Paris DevNet Hackathon slideshow - Intro
Cisco Paris DevNet Hackathon slideshow - IntroCisco Paris DevNet Hackathon slideshow - Intro
Cisco Paris DevNet Hackathon slideshow - Intro
 
Tumeurs Neuroendocrines : une vue d'ensemble
Tumeurs Neuroendocrines : une vue d'ensembleTumeurs Neuroendocrines : une vue d'ensemble
Tumeurs Neuroendocrines : une vue d'ensemble
 
Building your first game in Unity 3d by Sarah Sexton
Building your first game in Unity 3d  by Sarah SextonBuilding your first game in Unity 3d  by Sarah Sexton
Building your first game in Unity 3d by Sarah Sexton
 
Using intel's real sense to create games with natural user interfaces justi...
Using intel's real sense to create games with natural user interfaces   justi...Using intel's real sense to create games with natural user interfaces   justi...
Using intel's real sense to create games with natural user interfaces justi...
 
Introduction to using the R200 camera & Realsense SDK in Unity3d - Jon Collins
Introduction to using the R200 camera & Realsense SDK in Unity3d - Jon CollinsIntroduction to using the R200 camera & Realsense SDK in Unity3d - Jon Collins
Introduction to using the R200 camera & Realsense SDK in Unity3d - Jon Collins
 
Audio Mixer in Unity5 - Andy Touch
Audio Mixer in Unity5 - Andy TouchAudio Mixer in Unity5 - Andy Touch
Audio Mixer in Unity5 - Andy Touch
 
Shaders - Claudia Doppioslash - Unity With the Best
Shaders - Claudia Doppioslash - Unity With the BestShaders - Claudia Doppioslash - Unity With the Best
Shaders - Claudia Doppioslash - Unity With the Best
 
[HACKATHON CISCO PARIS] Slideshow du workshop Smart City
[HACKATHON CISCO PARIS] Slideshow du workshop Smart City[HACKATHON CISCO PARIS] Slideshow du workshop Smart City
[HACKATHON CISCO PARIS] Slideshow du workshop Smart City
 
Tools to Save Time
Tools to Save TimeTools to Save Time
Tools to Save Time
 
[Workshop e résidents] présentation intent, craft ai, dalkia et incubateur
[Workshop e résidents] présentation intent, craft ai, dalkia et incubateur[Workshop e résidents] présentation intent, craft ai, dalkia et incubateur
[Workshop e résidents] présentation intent, craft ai, dalkia et incubateur
 
[Webinar E-résidents #1] Présentation des différents métiers du bâtiment conn...
[Webinar E-résidents #1] Présentation des différents métiers du bâtiment conn...[Webinar E-résidents #1] Présentation des différents métiers du bâtiment conn...
[Webinar E-résidents #1] Présentation des différents métiers du bâtiment conn...
 
[IoT World Forum Webinar] Review of CMX Cisco technology
[IoT World Forum Webinar] Review of CMX Cisco technology[IoT World Forum Webinar] Review of CMX Cisco technology
[IoT World Forum Webinar] Review of CMX Cisco technology
 
HP Helion Episode 6: Cloud Foundry Summit Recap
HP Helion Episode 6: Cloud Foundry Summit RecapHP Helion Episode 6: Cloud Foundry Summit Recap
HP Helion Episode 6: Cloud Foundry Summit Recap
 
Webinar UI/UX by Francesco Marcellino
Webinar UI/UX by Francesco MarcellinoWebinar UI/UX by Francesco Marcellino
Webinar UI/UX by Francesco Marcellino
 
HP Helion Webinar #5 - Security Beyond Firewalls
HP Helion Webinar #5 - Security Beyond FirewallsHP Helion Webinar #5 - Security Beyond Firewalls
HP Helion Webinar #5 - Security Beyond Firewalls
 
HP Helion Webinar #4 - Open stack the magic pill
HP Helion Webinar #4 - Open stack the magic pillHP Helion Webinar #4 - Open stack the magic pill
HP Helion Webinar #4 - Open stack the magic pill
 

Porting Android application from ARM to x86

  • 1. Porting Android application from ARM to X86 Massimiliano Torregiani Intel CODEFEST Milan 13 Febbraio 2014
  • 2. Android SDK e NDK Programmazione SDK compile once, run everywhere Programmazione NDK some compile once, run everywhere oppure oppure 2  
  • 3. 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  
  • 4. 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  
  • 5. Supporto Intel per Android: Beacon Mountain 5  
  • 6. Porting da ARM a X86 Sample 1: HelloJni 6  
  • 7. Differenze tra architettura ARM e X86 Memory Alignment struct TestStruct { int mVar1; long long mVar2; int mVar3; }; GCC flag “-malign-double” By Default “Double Margin” By default No margin 7  
  • 8. Differenze tra architettura ARM e X86 Memory Big  or  li/le  endian  order   Alignment (ARM  is  bi-­‐endian)   Floating Point li/le-­‐endian  assembly   ARMv5  à  So@  FP  opts   Intel  Atom  à  IA-­‐32   ARMv7  à  Hardware  FPU   instrucJons,  Hardware  Based   instrucJons  (VFP)   FP  opts   SIMD ARMv5  à  No  SIMD  ext   Intel  Atom  à  SSSE3  (Supplemental   extensions ARMv7  à  NEON  ext   Streaming  SIMD  Extensions  3)   8  
  • 9. Differenze tra architettura GCC Flags Memory –mlittle-endian Alignment –mbig-endian Floating -mfloat-abi= soft | softfp | hard –mfpmath=sse Point -mfpu= vfp | vfpv3-d16 | neon | ... -mavx -maes SIMD -march=armv7-a extensions -mtune=cortex-a8 -msse –DHAVE_NEON=1 9  
  • 10. Porting da ARM a X86 Sample 2: HelloNeon 10  
  • 11. Utilizzo librerie esterne Step 1: Porting librerie esterne Libreria  Esterna   naJva   Codice  naJvo   proprietario   Libreria   compilata  per   Target   Step 2: Porting codice nativo proprietario JNI APP  Android   (Java)   Step 3: Rebuild applicazione 11  
  • 12. Porting da ARM a X86 Sample 3: HelloFFmpeg 12  
  • 13. KALPA srl Thanks! Mail: massimiliano.torregiani@kalpa.it   Twitter: @maxtorregiani   Linkedin: h/p://www.linkedin.com/pub/massimiliano-­‐torregiani/3/555/550