在x64 macbookpro上运行helloworld x86-assembler

时间:2015-05-01 17:46:41

标签: macos assembly reverse-engineering

我正在尝试编译并链接以下我在运行linux debian7的macbook pro上的第一个汇编程序代码:

section .text
    global _start

section .data
    hello: db 'Hello world!', 10
    helloLen: equ $-hello

start:
    mov eax, 4
    mov ebx, 1
    mov ecx, hello
    mov edx, helloLen

    int 80h

    mov eax,1
    mov ebx,0
    int 80h

我(1)将其保存到名为main.s的文件,(2)已运行nasm -f elf main.s -o main,最后保存到已链接(3)nasm -f elf main.s -o main 我得到了:

ld: i386 architecture of input file `main.o' is incompatible with i386:x86-64 output
ld: warning: cannot find entry symbol _start; defaulting to 0000000000400080

我知道上面的汇编代码是针对x86 arch的。我怎样才能解决这个问题?试图编辑nasmld的两个参数,但它仍然不起作用!

我所知道的是,如果可以编译该代码而无需先使用gcc -m32...进行编译,那么请获取代码。我愿意练习x86汇编程序,因为在我进入x86-x64世界之前它更容易使用。 非常非常感谢!

0 个答案:

没有答案
相关问题