I am trying to run arm executable using qemu and I am getting this following error a.out: Invalid ELF image for this architecture. My assemble code hello.s

.global _start
    mov r0, #1
    ldr r1, =message
    ldr r2, =len
    mov r7, #4
    swi 0

    mov r7, #7
    swi 0

    .asciz "Hello, World\n"
len = .-message

I am compiling with the command arm-linux-gnueabihf-as hello.s and file a.out output is

a.out: ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), not stripped

When I run using command qemu-arm a.out, I am getting the following output

a.out: Invalid ELF image for this architecture

I need help on what went wrong.

  • 1
    You need to run the linker arm-linux-gnueabihf-ld on the object file a.out – 0xec Mar 5 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.