LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Assembly, "bash: ./exit: cannot execute binary file" (http://www.linuxquestions.org/questions/programming-9/assembly-bash-exit-cannot-execute-binary-file-575248/)

User Name. 08-06-2007 09: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:
Code:

.section .data

 .section .txt
 .globl _start
_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:
Code:

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

Then I try to execute it:
Code:

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-06-2007 11:01 PM

Have you checked the permission?
ls -l

colucix 08-07-2007 01:34 AM

Just a far reminiscence, but I'd put
Code:

.section .text
instead of .txt.

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

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

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

Quote:

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

.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 05:35 AM.