1

Hey I have a helloworld assembler program in GAS. Now I was meant to compile it in 64 Bit and it throws the error

"./helloworld: cannot execute binary file: Exec format error"

Assembling: as --32 -o helloworld.o helloworld-a.asm

Linking: ld -m elf_i386 -o helloworld helloworld.o

When I make that without "--32" and "-m elf_i386" I get segmentation fault.

.section .data

str:    .ascii  "Hello world!\n"
    strlen = . - str

num:    .long   1337

.section .text

.global _start

_start:
    movl    $4, %eax
    movl    $1, %ebx
    movl    $str, %ecx
    movl    $strlen, %edx
    int $0x80

    movl    $1, %eax
    movl    $0, %ebx
    int $0x80

That's my program by the way :)

Thank you for any help ;)

Jan Wolfram
  • 145
  • 8

0 Answers0