0
我在程序集中做了strcpy函數,然後我嘗試啓動幾個程序,如Firefox,emacs,... 但我有一個複製的問題,我不知道在哪裏問題是。關於strcpy啓動Firefox的NASM問題
彙編代碼:
global strcpy
section .text
strcpy:
push rbp
push rdx
mov rbp, rsp
mov rdx, 0
strcpy_loop:
cmp byte [rsi + rdx], 0
je strcpy_end
mov al, byte [rsi + rdx]
mov byte [rdi + rdx], al
inc rdx
jmp strcpy_loop
strcpy_end:
mov rax, rdi
mov rsp, rbp
pop rdx
pop rbp
ret
結果當我試圖用我的共享庫推出了一個小程序:
s1 = hello
s2 before copy =
s2 after copy = hello
結果當我試圖用我的共享庫啓動Firefox:
/usr/bin/firefox: line 52: $'basenamex\326g\002Lame $0`': command not found
/usr/bin/firefox: line 57: bad substitution: no closing "`" in `x�gL
/usr/bin/firefox: line 63: $'[\340\n\002': command not found
/usr/bin/firefox: line 73: fileL: command not found
/usr/bin/firefox: line 75: echoL: command not found
grep: invalid option -- 'g'
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
/usr/bin/firefox: line 78: $'[\351\n\002L': command not found
/usr/bin/firefox: line 83: export: `MOZILLA_FIVE_HOME�gL': not a valid identifier
/usr/bin/firefox: line 91: $'[\257\n\002': command not found
/usr/bin/firefox: line 95: /dev/null�gL: Permission denied
/usr/bin/firefox: line 97: $'[\t\v\002': command not found
/usr/bin/firefox: line 108: $'[\006\v\002': command not found
/usr/bin/firefox: line 131: $'[\023\v\002': command not found
/usr/bin/firefox: line 138: exec: =0
: not found
小程序正在運行,但不是firefox。
從'strcpy'文檔:_「的的strcpy()函數將字符串由src指出,**包括終止空字節**( '\ 0'),至dest指向的緩衝區。「_ – Michael
謝謝你的問題。 問題已解決 –