Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build android ELF binary with nasm?

Tags:

android

arm

nasm

I'm trying to write some assemble code for Android. Usually I'd do with nasm, but it doesn't seem to support Android (ARM) at all:

valid output formats for -f are (`*' denotes default):
  * bin       flat-form binary files (e.g. DOS .COM, .SYS)
    ith       Intel hex
    srec      Motorola S-records
    aout      Linux a.out object files
    aoutb     NetBSD/FreeBSD a.out object files
    coff      COFF (i386) object files (e.g. DJGPP for DOS)
    elf32     ELF32 (i386) object files (e.g. Linux)
    elf64     ELF64 (x86_64) object files (e.g. Linux)
    elfx32    ELFX32 (x86_64) object files (e.g. Linux)
    as86      Linux as86 (bin86 version 0.3) object files
    obj       MS-DOS 16-bit/32-bit OMF object files
    win32     Microsoft Win32 (i386) object files
    win64     Microsoft Win64 (x86-64) object files
    rdf       Relocatable Dynamic Object File Format v2.0
    ieee      IEEE-695 (LADsoft variant) object file format
    macho32   NeXTstep/OpenStep/Rhapsody/Darwin/MacOS X (i386) object files
    macho64   NeXTstep/OpenStep/Rhapsody/Darwin/MacOS X (x86_64) object files
    dbg       Trace of all info passed to output stage
    elf       ELF (short name for ELF32)
    macho     MACHO (short name for MACHO32)
    win       WIN (short name for WIN32)

None of them seems to be ARM related, am I wrong?

like image 310
daisy Avatar asked Jun 20 '14 01:06

daisy


2 Answers

You are right : NASM does not support ARM.

There is a very simple reason : ARM assembly has nothing to do with any x86 assembly. An assembly is linked to the hardware architecture it is made for. Assembly instructions are mnemonics for actual processor instruction set, and ARM instruction set has nothing in common with x86 instruction, because ARM architecture isn't x86 compatible.

Any assembly code written for x86 can't be used on ARM. This is why higher level languages (such as C) were developed.

like image 56
Jacen Avatar answered Nov 03 '22 10:11

Jacen


NASM only supports the x86/64 architectures. ARM is a totally different architecture. The list you refer to is a list of file formats that NASM is capable of storing the assembled x86/64 code into.

like image 25
shebaw Avatar answered Nov 03 '22 11:11

shebaw