簡體   English   中英

bash,無法執行二進制文件

[英]bash, can't execute binary file

我目前正在嘗試在Trisquel發行版上學習匯編語言(我猜想是在后台使用Ubuntu?)。 由於某些原因,我停留在創建和執行程序集摘要的第一步。

.section data

.section text
.globl _start
_start:
movl $1, %eax # syscall for exiting a program
movl $0, %ebx # status code to be returned
int $0x80

當我嘗試組裝並鏈接它以創建可執行文件並運行該可執行文件時,我得到如下信息:

> as myexit.s -o myexit.o && ld myexit.o -o myexit
> ./myexit
bash: ./myexit: cannot execute binary file

我不確定這里到底發生了什么。 搜索后,似乎在嘗試在64位OS上執行32位可執行文件時通常會彈出此錯誤,反之亦然,這對我而言並非如此。

這是fileuname命令的輸出:

$ file myexit
myexit: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, not stripped
$ uname -a
Linux user 2.6.35-28-generic #50trisquel2-Ubuntu SMP Tue May 3 00:54:52 UTC 2011 i686 GNU/Linux

有人可以幫助我了解這里到底出了什么問題嗎? 謝謝。

.section text

是不正確的,當您需要將代碼放在.text節中時,會創建一個名為text的節。 替換為:

.data

.text
.globl _start
_start:
  ...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM