Results 1 to 2 of 2

Thread: Unable to run 32 bit assembly programs on 64 bit ubuntu Nasm / ld

  1. #1
    Join Date
    Jun 2012
    Beans
    2

    Unable to run 32 bit assembly programs on 64 bit ubuntu Nasm / ld

    I am on Ubuntu 12.10 64 bit.

    I am trying to compile and run a simple hello world program with nasm. The program is 32 bit and I want to run it in 32 bit mode under my 64 bit system. I believe I have all compatibility libraries installed.

    I try these commands.

    Code:
    $ nasm -f elf -g -F stabs easyprint.asm
    $ ld -o easyprint easyprint.o
    ld: i386 architecture of input file `easyprint.o' is incompatible with i386:x86-64 output
    Of course, I can compile the assembly program as 64 bit and it works.

    Code:
    $ nasm -f elf64 -g -F stabs easyprint.asm
    $ ld -o easyprint easyprint.o
    $ ./easyprint 
    The quick brown fox jumps over the lazy dog.
    But I would rather run it in 32 bit mode. I know you can compile it for 32 mode with gcc -m32, but I don't want to use GCC to compile it and I don't need access to any of the C functions.

    I know this problem has probably been asked a million times, but for some reason hours of googling haven't helped me. Thanks in advance.

  2. #2
    Join Date
    Apr 2009
    Location
    Germany
    Beans
    2,134
    Distro
    Ubuntu Development Release

    Re: Unable to run 32 bit assembly programs on 64 bit ubuntu Nasm / ld

    you need to add
    -m elf_i386

    the the ld call
    you need to have a 32 bit linker available (libc6:i386 in newer ubuntus)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •