I have the following assembly code
global main extern println section .textmain: mov rdi, message call println retmessage: db "Hello, world!", 0
I am linking it with some C code
#include <stdio.h>void println(char *line) { puts(line);}
I run the following commands to compile and link these two programs
nasm -f elf64 helloWorld.asm -o helloWorld.asm.ogcc -c helloWorld.c -o helloWorld.c.ogcc -static helloWorld.c.o helloWorld.asm.o -o helloWorld
then I run my finished program with
./helloWorld
If I remove -static
from the gcc
options, I get a seg-fault! Why is this??