-   Programming (
-   -   Assembly, "bash: ./exit: cannot execute binary file" (

User Name. 08-06-2007 10:58 PM

Assembly, "bash: ./exit: cannot execute binary file"
I am learning assembly from the book Programming from the ground up. I typed together the first program they listed, exit.s:

.section .data

 .section .txt
 .globl _start
 movl $1, %eax        # this is the linux kernel command number (system call) for
                #  exiting a program
 movl $0, %ebx        # this is the status number we will return to the operating
                #  system. change this around and it will return different
                #  different things to "echo $?"
 int $0x80        # this wakes up the kernel to run the exit command

I assemble, and link it:

bash-3.1$ as exit.s -o exit.o
bash-3.1$ ld exit.o -o exit

Then I try to execute it:

bash-3.1$ ./exit
bash: ./exit: cannot execute binary file

I was searching on google for this error, but no luck.

I am running slackware 12, have an HP laptop with an intel processor, if that helps.

So, does anyone have any ideas on how to solve this?

thloh85 08-07-2007 12:01 AM

Have you checked the permission?
ls -l

colucix 08-07-2007 02:34 AM

Just a far reminiscence, but I'd put

.section .text
instead of .txt.

Dox Systems - Brian 08-07-2007 09:18 AM

Works fine for me, but I used ".section .text" as listed above...

User Name. 08-07-2007 10:09 AM


Originally Posted by colucix
Just a far reminiscence, but I'd put

.section .text
instead of .txt.

Opps. I am so used to .txt, as in text files.

Thanks for that help.

All times are GMT -5. The time now is 07:18 PM.