I'm trying to make a task work, but even the example I'm not able to run, the code is as follows:
section .data
SYS_exit equ 60
EXIT_SUCCESS equ 0
yourage db "How old are you: ",0
willbe db "You will be %d years old in ten years.",0xa,0
input db "%d", 0
age dq 0
section .text
extern printf
extern scanf
global main
main:
mov rax, 0
mov rdi, yourage
call printf
mov rax, 0
mov rdi, input
mov rsi, age
call scanf
mov r15, [age]
add r15, 10
mov [age],r15
mov rax, 0
mov rdi, willbe
mov rsi, [age]
call printf
mov rax, 0
mov rdi, 0
last:
mov rax,SYS_exit
mov rbx,EXIT_SUCCESS
syscall
To join I'm using the following commands
>yasm -g dwaf2 -f elf64 fonte.asm
>gcc -g -o fonte fonte.o
>.\fonte
But soon after gcc I'm always getting the following error:
/usr/bin/ld: fonte.o: relocation R_X86_64_32 against '.data' can not be used when making a shared object; recompilar com -fPIC
/usr/bin/ld: falha no link final: Seção não representável na saída
collect2: error: ld returned 1 exit status
Does anyone give me a light? I'm really lost in this one but I need to get through this matter!