相关疑难解决方法(0)

在Mac 0SX上使用x86汇编程序的Hello World

我试图在我的Mac上深入研究一些x86汇编程序,但是在生成可执行文件时遇到了麻烦.这个问题似乎处于联系阶段.

helloWorld.s:

.data

    HelloWorldString:
    .ascii "Hello World\n"

.text

.globl _start

_start:
    # load all the arguments for write()
    movl $4, %eax
    movl $1, %ebx
    movl $HelloWorldString, %ecx
    movl $12, %edx
    # raises software interrupt to call write()
    int $0x80

    # call exit()
    movl $1, %eax
    movl $0, %ebx
    int $0x80
Run Code Online (Sandbox Code Playgroud)

组装程序:

as -o helloWorld.o helloWorld.s
Run Code Online (Sandbox Code Playgroud)

链接目标文件:

ld -o helloWorld helloWorld.o
Run Code Online (Sandbox Code Playgroud)

我在这一点上得到的错误是:

ld: could not find entry point "start" (perhaps missing crt1.o) for inferred architecture x86_64
Run Code Online (Sandbox Code Playgroud)

关于我做错了/遗失的任何建议都会非常有帮助.谢谢

macos x86 assembly linker

15
推荐指数
1
解决办法
1万
查看次数

Linux 64位进程命令行

我在从Linux 64位汇编程序访问进程命令行时遇到问题.为了用最少的代码重现这个,我制作了这个32位程序,打印程序名称的前5个字符:

.section .text

.globl _start
_start:
 movl  %esp, %ebp

 movl $4, %eax        # write
 movl $1, %ebx        # stdout
 movl 4(%ebp), %ecx   # program name address (argv[0])
 movl $5, %edx        # hard-coded length
 int  $0x80

 movl $1, %eax
 movl $0, %ebx
 int  $0x80

这个程序正在运行.当我将其翻译为64位并在Linux 64中运行时,它不会打印任何内容:

.section .text

.globl _start
_start:
 movq  %rsp, %rbp

 movq $4, %rax
 movq $1, %rbx
 movq 8(%rbp), %rcx       # program name address ?
 movq $5, %rdx
 int  $0x80

 movq $1, %rax
 movq $0, %rbx
 int …

linux 64-bit assembly

5
推荐指数
1
解决办法
2520
查看次数

macOS 64位系统调用表

我可以找到一个Linux 64位系统调用表,但是该调用号在macOS上不起作用- Bus Error: 10每当尝试使用它们时,我都会得到一个。

操作的macOS呼叫号码是sys_write什么?

macos assembly x86-64 system-calls

4
推荐指数
3
解决办法
2929
查看次数

标签 统计

assembly ×3

macos ×2

64-bit ×1

linker ×1

linux ×1

system-calls ×1

x86 ×1

x86-64 ×1