I have problem with assembly program on my VirtualBox.
On VB I have Linux Mint(64 bit). I tried to compile this assembler code(in file my_file.asm
):
extern printf
extern scanf
section .data
format: db "%d",0
napis: db "a/b=%d",10,0
section .bss
a: resd 1
b: resd 1
global main
section .text
main:
mov rdi, format
mov rsi, a
xor rax, rax
call scanf
mov rdi, format
mov rsi, b
xor rax, rax
call scanf
mov eax, [a]
xor edx, edx
div dword[b]
ret
At first I type: nasm -f elf64 myfile.asm
Then I type: gcc myfile.o -o myfile
And after this i have this error message:
"/usr/bin/ld: plik.o: relocation R_X86_64_32S against .bss' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
"
So i add -no-pie
to gcc command: gcc -o test test.o -no-pie
Now, when I use ./my_file
I have this error: Segmentation fault (core dumped)
and I don't know what to do.