日曜日, 4月 05, 2009

Linux Assembler


Assembler Command-Line Syntax
  • Compiling
    1. AT&T-syntax
      as -a --gstabs -o x.o x.s
      -o option specifies what to call the object file, i.e. machine-code file, which is the primary output of the assembler.
      -a option tells the assembler to display to the screen the source code, machine code and segment offsets side-by-side, for easier correlation.
      -gstabs option tells the assembler to retain in x.o the symbol table, a list of the locations of whatever labels are in x.s, in the object file.
    2. Intel syntax
      nasm -f elf -o x.o -l x.l x.s

      -f option instructs the assembler to set up the x.o file so that the
      executable file constructed from it later on will be of the ELF format,
      which is a common executable format on Linux platforms.
      -l option
      plays a similar role to -a in as, in that a side-by-side
      listing of source and machine code will be written to the file
      x.l.
  • Linking
    • ld -o x x.o

  • see the corresponding assembly language of a C program
    • gcc -S y.c


0 件のコメント: