在 x86-64 Ubuntu 上使用 NASMundefined reference to _printf构建定义自己_start而不是的汇编程序时,我得到了一个main
构建命令:
nasm -f elf64 hello.asm
ld -s -o hello hello.o
hello.o: In function `_start':
hello.asm:(.text+0x1a): undefined reference to `_printf'
MakeFile:4: recipe for target 'compile' failed
make: *** [compile] Error 1
Run Code Online (Sandbox Code Playgroud)
nasm 来源:
extern _printf
section .text
global _start
_start:
mov rdi, format ; argument #1
mov rsi, message ; argument #2
mov rax, 0
call _printf ; call printf
mov rax, 0
ret ; return 0
section …Run Code Online (Sandbox Code Playgroud)