LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-06-2007, 09:58 PM   #1
User Name.
Member
 
Registered: Aug 2006
Distribution: Ubuntu 8.04
Posts: 178

Rep: Reputation: 30
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?
 
Old 08-06-2007, 11:01 PM   #2
thloh85
Member
 
Registered: Apr 2006
Location: Earth
Distribution: BLFS customized
Posts: 160

Rep: Reputation: 31
Have you checked the permission?
ls -l
 
Old 08-07-2007, 01:34 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Just a far reminiscence, but I'd put
Code:
 .section .text
instead of .txt.
 
Old 08-07-2007, 08:18 AM   #4
Dox Systems - Brian
Member
 
Registered: Nov 2006
Posts: 344

Rep: Reputation: 31
Works fine for me, but I used ".section .text" as listed above...
 
Old 08-07-2007, 09:09 AM   #5
User Name.
Member
 
Registered: Aug 2006
Distribution: Ubuntu 8.04
Posts: 178

Original Poster
Rep: Reputation: 30
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to write a bash script to replace all "KH" to "K" in file ABC??? cqmyg5 Slackware 4 07-24-2007 09:00 AM
[SOLVED] Installind Slamd64-current. "cannot execute binary file" message about installpkg BrutalMusic Slackware - Installation 1 05-11-2006 09:35 AM
"cannot execute binary file" when install j2sdk jin007 Linux - Software 3 06-27-2005 02:05 PM
SIN linux native - "cannot execute binary file" darkranger Linux - Games 1 06-07-2005 08:34 AM
Mendrake9.2, bash: cannot execute binary file premier_la Mandriva 4 01-22-2004 05:16 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration