helloworld.asm
extern printf
extern exit
section .data
format db "%d"
section .text
global _start
_start:
push 2
push format
call printf ; printf(format, 2)
push 0
call exit ; exit(0)
nasm -f elf helloworld.asm
ld -m elf_i386 helloworld.o -o helloworld -lc -I /lib/ld-linux.so.2
./helloworld
其中printf方法在/lib/ld-linux.so.2中
输出2