Cygwin:兼容性问题 [英] Cygwin: Compatibility Issue

查看:302
本文介绍了Cygwin:兼容性问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好StackOverFlowers!

Hello StackOverFlowers!

对于整个linux来说,我还是一个新手,我正在使用Cygwin尝试执行以下操作.

I'm extremely new to the whole linux thing and I'm using Cygwin to try to do the following..

通过解析器放置测试文件...

Put a test file through a parser...

./parser < test.c > test.asm//工作并生成ASM代码

./parser < test.c > test.asm //Works and generates ASM code

按照本教程中的描述执行此行,我不确定它到底是做什么的...

Do this line as described in the tutorial which I'm not sure exactly what it does...

nasm -f elf test.asm//工作

最后一行可以创建可执行文件(如果我正确理解了本教程)

And finally this line to create the exectuable(If I am understanding the tutorial correctly)

ld -s -o test test.o

此行出现错误ld: i386 architecture of input file test.o' is incompatible with i386:x86-64 output.我知道这是因为我正在尝试从32位升级到64位,但是我不知道如何解决这个问题.我尝试使用elf_i386,但得到ld: unrecognised emulation mode: elf_i386. Supported emulations: i386pep i386pe.

I'm getting an error of ld: i386 architecture of input file test.o' is incompatible with i386:x86-64 output on this line. I know it's because I'm trying to go from a 32-bit to a 64-bit, but I can't figure out how to combat this. I've tried using elf_i386, but I get ld: unrecognised emulation mode: elf_i386. Supported emulations: i386pep i386pe.

任何人和所有建议都将不胜感激!

Any and all suggestions are much appreciated!!

Test.asm文件

Test.asm file

section .data
numbers db "0123456789", 0xA
inputchar db 0
section .text
global F_124565444
F_124565444:
push    ebp
mov ebp, esp
sub esp, 4
mov dword [ebp-4], 0
jmp G2
G1:
add dword [ebp-4], 1
push edx
G2:
mov edx, 0
mov eax, [ebp+8]
mov ebx, 10
div ebx
mov [ebp+8], eax
cmp eax, 0
jnz G1
push edx
add dword [ebp-4], 1
jmp G3
G4:
sub dword [ebp-4], 1
pop edx
mov eax, 4
mov ebx, 1
mov ecx, numbers
add ecx, edx
mov edx, 1
int 80h
G3:
cmp dword [ebp-4], 0
jnz G4
mov eax, 4
mov ebx, 1
lea ecx, [numbers+10]
mov edx, 1
int 80h
leave
ret
global F_7362500
F_7362500:
push    ebp
mov ebp, esp
sub esp, 4
mov dword [ebp-4], 0
mov byte [inputchar], 0
jmp G6
G5:
mov dword eax, [ebp-4]
mov ebx, 10
mul ebx
xor ecx, ecx
mov byte cl, [inputchar]
sub ecx, 48
add eax, ecx
mov dword [ebp-4], eax
G6:
mov eax, 03h
mov ebx, 00h
mov ecx, inputchar
mov edx, 01h
int 80h
cmp byte [inputchar], 0ah
jne G5
mov dword eax, [ebp-4]
leave
ret
global F_28052
F_28052:
push    ebp
mov ebp, esp
push    dword [ebp+8]
push    dword 0
pop ebx
pop eax
cmp eax, ebx
sete    al
movzx   eax, al
push    dword eax
pop eax
cmp eax, 0
je  L1
push    dword [ebp+12]
pop eax
leave
ret
jmp L2
L1:
push    dword [ebp+8]
push    dword [ebp+12]
push    dword [ebp+12]
push    dword [ebp+8]
pop ebx
pop eax
mov edx, eax
sar edx, 31
idiv    ebx
push    dword eax
push    dword [ebp+8]
pop ebx
pop eax
imul    eax, ebx
push    dword eax
pop ebx
pop eax
sub eax, ebx
push    dword eax
call    F_28052
add esp, 8
push    dword eax
pop eax
leave
ret
L2:
leave
ret
global _start
_start:
push    ebp
mov ebp, esp
sub esp, 4
sub esp, 4
call    F_7362500
add esp, 0
push    dword eax
lea ebx, [ebp-4]
pop eax
mov dword [ebx], eax
call    F_7362500
add esp, 0
push    dword eax
lea ebx, [ebp-8]
pop eax
mov dword [ebx], eax
push    dword [ebp-4]
push    dword [ebp-8]
call    F_28052
add esp, 8
push    dword eax
call    F_124565444
add esp, 8
push    dword 0
pop eax
leave
mov ebx, eax
mov eax,1
int 80h
leave
mov ebx, eax
mov eax,1
int 80h

推荐答案

从您的问题和评论中看来,您可能已经被认为相信

It appears from your question and comments that you may have been lead to believe that Cygwin was the same as Linux. That isn't the case. Cygwin is a unix-like posix compatible environment that runs natively on Windows:

Cygwin是Microsoft Windows的类Unix环境和命令行界面. Cygwin提供基于Windows的应用程序,数据和其他系统资源与类Unix环境的应用程序,软件工具和数据的本地集成.因此,可以从Cygwin环境中启动Windows应用程序,以及在Windows操作上下文中使用Cygwin工具和应用程序.

Cygwin is a Unix-like environment and command-line interface for Microsoft Windows. Cygwin provides native integration of Windows-based applications, data, and other system resources with applications, software tools, and data of the Unix-like environment. Thus it is possible to launch Windows applications from the Cygwin environment, as well as to use Cygwin tools and applications within the Windows operating context.

尤其是在Windows上运行时,所有使用int 80h系统调用的特定于Linux的代码都将失败,因为它不适用于Windows环境.

In particular all the Linux specific code that uses int 80h system call will fail when run on Windows, as it doesn't apply to the Windows environment.

如果要创建在Linux上运行的代码,则需要安装Linux.您可以通过在Windows上运行虚拟机软件并在其中安装一种Linux来实现(Ubuntu是很多人的选择).

If you want to create code that runs on Linux, then you'll need to install Linux. You can do that by running Virtual Machine software on Windows and install a flavor of Linux into it (Ubuntu is the choice for a lot of people).

这篇关于Cygwin:兼容性问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆