[buug] cannot execute binary file or use printf

John de la Garza john at jjdev.com
Mon Apr 13 18:16:29 PDT 2009


Last week I was able to build simple assembly language programs and run them.

It seems like all of a sudden I can't run my programs.

any ideas on what could cause this?  I can't think of anything that has changed

This program assembles and links ok but when I run it I get an error

----------------------------------------------------------------
john at ldev:~/asm/test$ cat jump.s
.section text
.globl _start
_start:
        nop
        movl $1, %eax
        movl $10, %ebx
        int $0x80
john at ldev:~/asm/test$ make
as -gstabs -o jump.o jump.s
ld -o jump jump.o
john at ldev:~/asm/test$ ./jump
-sh: ./jump: cannot execute binary file
john at ldev:~/asm/test$
---------------------------------------------------------------

If I try to use printf I can't link:

-------------------------------
john at ldev:~/asm/test$ cat add.s
.section .data
output:
        .asciz "%d = %d + %d\n"
.section .text
.globl _start
_start:
        nop
        movl $9, %eax
        movl $22, %ebx
        pushl %ebx
        pushl %eax
        xadd %eax, %ebx
        pushl %ebx
        pushl $output
        call printf
        call exit
john at ldev:~/asm/test$ as ./add.s -o add.o
john at ldev:~/asm/test$ ld -dynamic-linker /lib/ld-linux.so.2 -o add add.o
add.o: In function `_start':
(.text+0x17): undefined reference to `printf'
add.o: In function `_start':
(.text+0x1c): undefined reference to `exit
john at ldev:~/asm/test$
------------------------------------



More information about the buug mailing list