Deleting/Unlinking mac 64 位 nasm 程序集中的文件
Deleting/Unlinking a file in nasm assembly on mac 64 bit
我正在尝试删除或取消链接文件。 Unlink 意思是删除,我认为(从我读到的)。
我读了 documentation and another documentation。他们都说取消链接需要 1 个参数。 const char * pathname
.
我已经这样做了,但是,我要删除的文件没有被删除。有谁知道为什么?这是我的代码:
global start
section .text
start:
;This is the deleting/unlinking part
mov rax, 0x2000010; unlinking
mov rdi, file ; contains path and the file. If you look down more in section .data you can see the file and path
syscall
;This part is not important: Its just exiting
mov rax, 0x2000001 ;Exiting
xor rdi, rdi
syscall
section .data
file: db "/Users/daniel.yoffe/desktop/assembly/CoolFile.txt", 0
我也看过 linux 中的一个例子。就是这样。我做错了什么吗?取消链接甚至删除文件吗?我是不是漏掉了什么,也许是另一个论点?
不胜感激。
您使用的是十进制和十六进制数字的不正确混合。对于系统调用 10
你想要:
;This is the deleting/unlinking part
mov rax, 0x200000a; unlinking
mov rdi, file ; contains path and the file. If you look down more in section .data you can see the file and path
syscall
旁注 ret
而不是您的第二个系统退出系统调用应该足以满足现代 Mach-o MacOS 可执行文件的要求。
我正在尝试删除或取消链接文件。 Unlink 意思是删除,我认为(从我读到的)。
我读了 documentation and another documentation。他们都说取消链接需要 1 个参数。 const char * pathname
.
我已经这样做了,但是,我要删除的文件没有被删除。有谁知道为什么?这是我的代码:
global start
section .text
start:
;This is the deleting/unlinking part
mov rax, 0x2000010; unlinking
mov rdi, file ; contains path and the file. If you look down more in section .data you can see the file and path
syscall
;This part is not important: Its just exiting
mov rax, 0x2000001 ;Exiting
xor rdi, rdi
syscall
section .data
file: db "/Users/daniel.yoffe/desktop/assembly/CoolFile.txt", 0
我也看过 linux 中的一个例子。就是这样。我做错了什么吗?取消链接甚至删除文件吗?我是不是漏掉了什么,也许是另一个论点?
不胜感激。
您使用的是十进制和十六进制数字的不正确混合。对于系统调用 10
你想要:
;This is the deleting/unlinking part
mov rax, 0x200000a; unlinking
mov rdi, file ; contains path and the file. If you look down more in section .data you can see the file and path
syscall
旁注 ret
而不是您的第二个系统退出系统调用应该足以满足现代 Mach-o MacOS 可执行文件的要求。