我对ASM很新。我正在调用sys_open
并尝试打印该系统调用的返回值(我想查看fd或错误)。但是,我的代码无效。非常感谢任何正确方向的帮助。谢谢!
asm: test.o
ld -o asm test.o
test.o: test.asm
nasm -f elf64 -g test.asm
SECTION .text
GLOBAL _start
_start: mov rax, 2 ; sys_open
mov rdi, file ; get file name address
mov rsi, 0 ; read only
syscall
sub al, '0' ; load fd
mov byte [buf], al ; move fd to buf
mov rsi, buf ; set address of buf
mov rdx, 64 ; set length of buf QWORD
call print
.exit: mov rax, 60 ; sys_exit
mov rdi, 0 ; exit success
syscall
; rsi address of buffer
; rdx length of buffer
print: push rax
push rdi
mov rax, 1 ; sys_write
mov rdi, 1 ; stdout
syscall
pop rdi
pop rax
ret
SECTION .data
file DB `test.asm\0`
SECTION .bss
buf RESQ 1
execve("./asm", ["./asm"], [/* 26 vars */]) = 0
open("test.asm", O_RDONLY) = 3
write(1, "\323\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 64Ó) = 64
exit(0) = ?
+++ exited with 0 +++
答案 0 :(得分:2)
您需要-g -F stabs来调试符号
nasm -f elf64 -g -F stabs test.asm
答案 1 :(得分:0)
此阻止不正确:
String script = "for (var prop in ___grecaptcha_cfg.clients[0])" +"{" +" return '___grecaptcha_cfg.clients[0].' + prop" +"}"; System.out.println(script); Object objects = (Object) js.executeScript(script); System.out.printl(objects);
由于sub al, '0' ; load fd
mov byte [buf], al ; move fd to buf
mov rsi, buf ; set address of buf
mov rdx, 64 ; set length of buf QWORD
call print
返回sys_open
,因此应使用int
代替eax
。另外,将int转换为等效的ASCII字符时,al
应该为sub
(在本例中,可以假设fd <10)。最后,add
应该为mov rdx, 64
,移动8个字节(64位)。
这是修改后的方块:
mov rdx, 8
这将显示add eax, '0' ; load fd
mov dword [buf], eax ; move fd to buf
mov rsi, buf ; set address of buf
mov rdx, 8 ; set length of buf QWORD
call print
返回的fd:
sys_open