linux - 在 Windows Bash 上执行程序?

标签 linux bash assembly windows-10

我写了一个小 .s 程序,它必须在监视器上打印一个小字符串。 然后我在 Windows 10 上打开了 linux bash 并完成了:

as -o file.o file.s
ld -o file file.o
./file

但它不打印任何东西 为什么?我在 linux 虚拟机上尝试了相同的代码并且它有效

该文件是一个简单的“hello world”,用于在学校学习汇编

.section .data

hello:
    .ascii "Hello, World!\n"

hello_len:
    .long . - hello


.section .text
    .global _start

_start:

    movl $4, %eax
    movl $1, %ebx
    leal hello, %ecx
    movl hello_len, %edx
    int $0x80
    movl $1, %eax
    xor %ebx, %ebx
    int $0x80

最佳答案

由于 WSL 目前处于测试阶段,因此某些功能尚不可用。运行 32 位 ELF 二进制文件是缺失功能的一部分(问题记录在 WSL githubuservoice 上)。

目前,要执行您想要的操作,您可以等到开发人员发布此功能或使用可在 here 中找到的 x86_64 指令集重新编写您的程序。 .

关于linux - 在 Windows Bash 上执行程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42855363/

相关文章:

c - C linux 中的信号量与客户端/服务器

linux - bash中的整数比较错误

assembly - x86 IO 映射 IO 端口保护和 DOS 扩展器

assembly - 为什么逻辑右移和算术右移的移位范围是1-32

linux - 如何在分隔符出现时对字符串开始的行进行排序 (linux)

linux - Firefox Flash 插件无法在 Linux Mint 上运行

bash - 在 bash 循环中使用对数(浮点)增量

assembly - 汇编程序中的低级网络(兼容 x86)

c - 使用c从linux中的串口获取二进制数据

php - 远程端ssh2执行生命周期