this is the code:
;hello3.asm
;27/06/2024
extern printf
section .data
msg db "this is a message", 0
fmtstr db "%s", 0
section .bss
section .text
global main
main:
mov rdi, fmtstr
mov rsi, msg
mov rax, 0
call printf
mov rax, 60
mov rdi, 0
syscall
I got after compiling with nasm and linking using gcc on linux(ubuntu) “segmentation fault” I though that this happens if the program tries to access a wrong memory address but this is not the case
here is the content of the makefile:
hello3:hello3.o
gcc -o hello3 hello3.o --no-pie -no-pie
hello3.o:hello3.asm
nasm -f elf64 -o hello3.o -l hello3.lst -g -F dwarf hello3.asm
I was expecting hello world as an output but it didn’t work I tried debugging using gdb but it didn’t help that much, what I discovered it that the issue is with the printf function
adam naanaa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.