如何从Win10中的link.exe链接来自NASM的obj文件 [英] How link obj file from NASM with link.exe in Win10
本文介绍了如何从Win10中的link.exe链接来自NASM的obj文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在NASM中有以下代码:
I have the following code in NASM:
;sleep.asm
[SECTION .text]
global _start
_start:
xor eax,eax
mov ebx, 0x00016630 ;address of Sleep
mov ax, 5000 ;pause for 5000ms
push eax
call ebx ;Sleep(ms);
0x00016630是睡眠功能的地址(从kernel32.dll的dumpbin中获取).
Where 0x00016630 is the address of Sleep function (taken from dumpbin from kernel32.dll).
我想制作可执行文件以在Win 10中运行.
I would like to make executable file to run in Win 10. What I did was:
nasm -f win32 sleep.asm
,结果为sleep.obj
.
所以现在我必须链接它.我选择使用以下命令来选择link.exe
So now I have to link it. I choose link.exe Unfortunately with the following command
link sleep.obj /entry:_start /subsystem:windows /nodefaultlib
Microsoft (R) Incremental Linker Version 14.00.24215.1
Copyright (C) Microsoft Corporation. All rights reserved.
LINK : error LNK2001: unresolved external symbol __start
sleep.exe : fatal error LNK1120: 1 unresolved externals
任何人都可以帮助解决此问题吗?
Can anybody help how to fix this issue?
推荐答案
链接器将自动在您使用/entry
在命令行中传递的任何内容前加一个下划线.尝试以下方法:
The linker will automatically pre-pend an underscore to whatever you pass on the command line with /entry
. Try this instead:
link sleep.obj /entry:start /subsystem:windows /nodefaultlib
这篇关于如何从Win10中的link.exe链接来自NASM的obj文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文