小编lon*_*ack的帖子

汇编部分 .code 和 .text 的行为不同

我是汇编新手,从我了解到的情况.code与 相同.text,但下面的代码将使用.code.

segment .data
    msg db "hello, world", 0xa
    len equ $ - msg

section .text
    global _start

_start:
    mov edx, len
    mov ecx, msg

    mov ebx, 1
    mov eax, 4
    int 0x80

    mov ebx, 0
    mov eax, 1
    int 0x80

Run Code Online (Sandbox Code Playgroud)
nasm -f elf64 -o hello.o hello.s 
ld -s -o hello hello.o
hello, world

sed -i s/.text/.code/ ./hello.s
nasm -f elf64 -o hello.o hello.s 
ld -s -o hello hello.o
./stack.sh: line 8:  4621 Segmentation …
Run Code Online (Sandbox Code Playgroud)

assembly x86-64 nasm elf

0
推荐指数
1
解决办法
378
查看次数

标签 统计

assembly ×1

elf ×1

nasm ×1

x86-64 ×1