0
我想用Linux系統調用寫一個非常簡單的宏定義標籤:宏+ Linux系統調用(NASM)
%macro hello_macro 1
section .rodata
%%string1: dd "hello: ",0
section .bss
%%string2: resd 1
section .text
;global %%_start1
%%_start1:
mov dword[%%string1],%1 ;mov argument to string
;system call write in stdout
mov eax,4
mov ebx,1
mov ecx,dword[%%string1]
mov edx,6
int 80h
;same
mov eax,4
mov ebx,1
mov ecx,dword[%%string2]
mov edx,4 ;it's 4 bytes so I assume it's 4 chars length.
int 80h
%endmacro
我這樣調用它(在.text段):
hello_macro 0x00613233
問題是,它什麼都不做(甚至錯誤)!
我編譯它這樣(沒有生成文件):
nasm -f elf -o 2.o 2.s
gcc -o 2 2.o
2.C是文件。 TNX!
這是因爲我只複製程序(讓我們說這是%%字符串2,而不是%%字符串標籤。 – Aladin
在節目中你有一個'_start'切入點somwhere? –
同樣的其餘部分,你有沒有試過用'ld -o 2 2.o'連接而不是gcc? –