1
.data
msg: .string "hello,world\n"
len = . - msg
.text
.global _start
_start:
    movl $len, %edx
    movl $msg, %ecx
    movl $1,   %ebx
    movl $4, %eax
    int $0x80

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

I compiled this code on ubuntu

as hello.s -o hello.o
ld hello.o -o hello

when I run the program with the command "./hello" the result showed:Segmentation fault (core dumped)

fuz
  • 88,405
  • 25
  • 200
  • 352
Vigiking
  • 11
  • 2
  • 1
    Any chance this is Ubuntu on Windows using WSL? If so WSL doesn't support 32-bit system calls via `int $0x80`, you have to use `syscall` . More on the 64-bit kernel system call convention and table of calls is here: https://blog.rchapman.org/posts/Linux_System_Call_Table_for_x86_64/ – Michael Petch Mar 07 '20 at 05:10
  • 1
    thanks, I am using WSL...!You are great! my English is very poor ,I don't know how to express my thanks toyou @Michael Petch – Vigiking Mar 07 '20 at 05:26
  • @Vigiking Note that WSL only supports 64 bit code. Your code is 32 bit code which will not work. – fuz Mar 07 '20 at 10:44

0 Answers0