Hello, I am having some trouble writing a shared library.
func1.s
SECTION .text
GLOBAL func1
func1:
mov rax, rdi
ret
func2.s
SECTION .text
EXTERN func1
GLOBAL func2
func2:
call func1
add rax, rsi
ret
huy@xguard:~/shared$ nasm -f elf64 func1.s
huy@xguard:~/shared$ nasm -f elf64 func2.s
huy@xguard:~/shared$ ld -shared -o libfunc.so func1.o func2.o
ld: func2.o: relocation R_X86_64_PC32 against symbol `func1' can not be used when making a shared object; recompile with -fPIC
ld: final link failed: Bad value
Under mac os x when I do ld -dylib, I don't have any issue. But with linux, I have this error. Could you help me with this issue ?