Segment violation in Nasm with Debian

1

I did this Hello world with Nasm .. and I'm trying to call C functions by libc .. but the program throws me "segment violation"

; Filename:libc.nasm
; author:me



 extern  printf
 extern  exit

global main



section .text

 main:

    push message
    call printf
    add esp, 0x4 ; adjust the stack

    mov eax, 0xa
    call exit

     section .data

    message: db 'hello world', 0xA, 0x00
    mlen     equ $-message

So compile it:

 nasm -f elf64 -o  $1.o $1.nasm



 gcc  -o libc libc.o
    
asked by TOMAS 04.07.2017 в 01:31
source

1 answer

0

SOLVED:

nasm -f elf -o $ 1.o $ 1.nasm

gcc -m32 -o $ 1 $ 1.o

    
answered by 07.07.2017 в 06:58